org.metastatic.rsync
Class GeneratorStream

java.lang.Object
  |
  +--org.metastatic.rsync.GeneratorStream

public class GeneratorStream
extends Object


Field Summary
protected  byte[] buffer
          The intermediate byte buffer.
protected  Configuration config
          The configuration.
protected  long count
          The number of bytes summed thusfar.
protected  List listeners
          The list of GeneratorListeners.
protected  int ndx
          The current index in buffer.
 
Constructor Summary
GeneratorStream(Configuration config)
           
 
Method Summary
 void addListener(GeneratorListener listener)
          Add a GeneratorListener to the list of listeners.
 void doFinal()
          Finish generating checksums, flushing any buffered data and resetting this instance.
protected  ChecksumPair generateSum(byte[] buf, int off, int len)
          Generate a sum pair for a portion of a byte array.
 boolean removeListener(GeneratorListener listener)
          Remove a GeneratorListener from the list of listeners.
 void reset()
          Reset this generator, to be used for another data set.
 void update(byte b)
          Update this generator with a single byte.
 void update(byte[] buf)
          Update this generator with a byte array.
 void update(byte[] buf, int off, int len)
          Update this generator with a portion of a byte array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

config

protected final Configuration config
The configuration.


listeners

protected final List listeners
The list of GeneratorListeners.


buffer

protected final byte[] buffer
The intermediate byte buffer.


ndx

protected int ndx
The current index in buffer.


count

protected long count
The number of bytes summed thusfar.

Constructor Detail

GeneratorStream

public GeneratorStream(Configuration config)
Method Detail

addListener

public void addListener(GeneratorListener listener)
Add a GeneratorListener to the list of listeners.

Parameters:
listener - The listener to add.

removeListener

public boolean removeListener(GeneratorListener listener)
Remove a GeneratorListener from the list of listeners.

Parameters:
listener - The listener to add.
Returns:
True if a listener was really removed (i.e. that the listener was in the list to begin with).

reset

public void reset()
Reset this generator, to be used for another data set.


update

public void update(byte b)
            throws ListenerException
Update this generator with a single byte.

Parameters:
b - The next byte
ListenerException

update

public void update(byte[] buf,
                   int off,
                   int len)
            throws ListenerException
Update this generator with a portion of a byte array.

Parameters:
buf - The next bytes.
off - The offset to begin at.
len - The number of bytes to update.
ListenerException

update

public void update(byte[] buf)
            throws ListenerException
Update this generator with a byte array.

Parameters:
buf - The next bytes.
ListenerException

doFinal

public void doFinal()
             throws ListenerException
Finish generating checksums, flushing any buffered data and resetting this instance.

ListenerException

generateSum

protected ChecksumPair generateSum(byte[] buf,
                                   int off,
                                   int len)
Generate a sum pair for a portion of a byte array.

Parameters:
buf - The byte array to checksum.
off - Where in buf to start.
len - How many bytes to checksum.
Returns:
A ChecksumPair for this byte array.