edu.harvard.deas.hyperenc
Class MessageParser

java.lang.Object
  extended by edu.harvard.deas.hyperenc.MessageParser
Direct Known Subclasses:
PlainTextMessageParser

public abstract class MessageParser
extends Object

Parses the contents of protocol messages.


Constructor Summary
MessageParser()
           
 
Method Summary
abstract  String mrecToString(List<Pair<Integer,byte[]>> lst)
          Converts a master reconciliation message hash list into a string.
abstract  List<Pair<Integer,byte[]>> parseMRec(String message)
          Converts the raw contents of a master reconciliation message into a list of pairs; each pair contains an integer ID identifying a page, and the hash of that page.
abstract  List<Pair<Integer,SlaveRecResult>> parseSRec(String message)
          Converts the raw contents of a slave reconciliation message into a list of pairs; each pair contains an integer ID identifying a page, and a code indicating the result of the reconciliation.
abstract  String srecToString(List<Pair<Integer,SlaveRecResult>> lst)
          Converts a slave reconciliation message hash list into a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageParser

public MessageParser()
Method Detail

parseMRec

public abstract List<Pair<Integer,byte[]>> parseMRec(String message)
                                              throws MessageParseException
Converts the raw contents of a master reconciliation message into a list of pairs; each pair contains an integer ID identifying a page, and the hash of that page.

Parameters:
message - the raw message
Returns:
the message represented as a list of ID-hash pairs
Throws:
MessageParseException - if message cannot be parsed

parseSRec

public abstract List<Pair<Integer,SlaveRecResult>> parseSRec(String message)
                                                      throws MessageParseException
Converts the raw contents of a slave reconciliation message into a list of pairs; each pair contains an integer ID identifying a page, and a code indicating the result of the reconciliation.

Parameters:
message - the raw message
Returns:
the message represented as a list of ID-result code pairs
Throws:
MessageParseException - if message cannot be parsed

mrecToString

public abstract String mrecToString(List<Pair<Integer,byte[]>> lst)
Converts a master reconciliation message hash list into a string. Performs the opposite conversion as parseMRec; passing a list to this method, then parsing the returned string with parseMRec yields a list equivalent to the original.

Parameters:
lst - a list of ID-hash pairs
Returns:
a string representing the given list

srecToString

public abstract String srecToString(List<Pair<Integer,SlaveRecResult>> lst)
Converts a slave reconciliation message hash list into a string. Performs the opposite conversion as parseSRec; passing a list to this method, then parsing the returned string with parseSRec yields a list equivalent to the original.

Parameters:
lst - a list of ID-result code pairs
Returns:
a string representing the given list