org.metastatic.rsync
Class ChecksumEncoder

java.lang.Object
  |
  +--org.metastatic.rsync.ChecksumEncoder
Direct Known Subclasses:
ChecksumEncoder

public abstract class ChecksumEncoder
extends Object

The base class of objects that encode (externalize) checksum pairs to byte streams.


Field Summary
protected  Configuration config
          The configuration object.
protected  OutputStream out
          The output stream being written to.
static String PROPERTY
          Property prefix for checksum encoders.
 
Constructor Summary
ChecksumEncoder(Configuration config, OutputStream out)
           
 
Method Summary
abstract  void doFinal()
          Finishes encoding by emitting any end-of-checksums markers.
static ChecksumEncoder getInstance(String encoding, Configuration config, OutputStream out)
          Gets an instance of a checksum encoder for the specified encoding.
abstract  boolean requiresOrder()
          This method returns true if the checksums must be presented in order of ascending offset.
abstract  void write(ChecksumPair pair)
          Encodes a checksum pair to the output stream.
 void write(List sums)
          Encodes a list of checksums to the output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY

public static final String PROPERTY
Property prefix for checksum encoders.

See Also:
Constant Field Values

config

protected Configuration config
The configuration object.


out

protected OutputStream out
The output stream being written to.

Constructor Detail

ChecksumEncoder

public ChecksumEncoder(Configuration config,
                       OutputStream out)
Method Detail

getInstance

public static ChecksumEncoder getInstance(String encoding,
                                          Configuration config,
                                          OutputStream out)
Gets an instance of a checksum encoder for the specified encoding.

Parameters:
encoding - The encoding name.
config - The configuration object.
out - The output stream.
Throws:
NullPointerException - If any parameter is null.
IllegalArgumentException - If the specified encoding cannot be found, or if any of the arguments are inappropriate.

write

public void write(List sums)
           throws IOException
Encodes a list of checksums to the output stream.

Parameters:
sums - The sums to write.
Throws:
IOException - If an I/O error occurs.
NullPointerException - If any element of the list is null.
IllegalArgumentException - If any element of the list is not a ChecksumPair.

write

public abstract void write(ChecksumPair pair)
                    throws IOException
Encodes a checksum pair to the output stream.

Parameters:
pair - The pair to write.
Throws:
IOException - If an I/O error occurs.

doFinal

public abstract void doFinal()
                      throws IOException
Finishes encoding by emitting any end-of-checksums markers.

Throws:
IOException - If an I/O error occurs.

requiresOrder

public abstract boolean requiresOrder()
This method returns true if the checksums must be presented in order of ascending offset.

Returns:
true if this encoder requires order.