org.metastatic.rsync
Class DeltaDecoder

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

public abstract class DeltaDecoder
extends Object

The superclass of all classes that decode delta objects from an external, binary format.

Subclasses MAY define themselves to be accessable through the #getInstance(java.lang.String,java.io.InputStream) method by providing a one-argument constructor that accepts an InputStream and defining the system property "jarsync.deltaDecoder.encoding-name".


Field Summary
protected  Configuration config
          The configuration.
protected  InputStream in
          The underlying input stream.
static String PROPERTY
           
 
Constructor Summary
DeltaDecoder(Configuration config, InputStream in)
           
 
Method Summary
static DeltaDecoder getInstance(String encoding, Configuration config, InputStream in)
          Returns a new instance of the specified decoder.
abstract  Delta read()
          Read (decode) a single delta from the input stream.
 int read(List deltas)
          Read (decode) a list of deltas from the input 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
See Also:
Constant Field Values

config

protected final Configuration config
The configuration.


in

protected final InputStream in
The underlying input stream.

Constructor Detail

DeltaDecoder

public DeltaDecoder(Configuration config,
                    InputStream in)
Method Detail

getInstance

public static final DeltaDecoder getInstance(String encoding,
                                             Configuration config,
                                             InputStream in)
Returns a new instance of the specified decoder.

Parameters:
encoding - The name of the decoder to get.
config - The configuration to use.
in - The source of binary data.
Returns:
The new decoder.
Throws:
NullPointerException - If any parameter is null.
IllegalArgumentException - If there is no appropriate decoder available.

read

public int read(List deltas)
         throws IOException
Read (decode) a list of deltas from the input stream.

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

read

public abstract Delta read()
                    throws IOException
Read (decode) a single delta from the input stream.

If this encoding provides an end-of-deltas marker, then this method is required to return null upon receiving this marker.

Returns:
The delta read, or null
Throws:
IOException - If an I/O error occurs.