org.egothor.util
Class CyclicBuffer

java.lang.Object
  extended by org.egothor.util.CyclicBuffer

public final class CyclicBuffer
extends java.lang.Object

Author:
Leo Galambos

Constructor Summary
CyclicBuffer(int size)
          Creates a new instance of CyclicBuffer.
 
Method Summary
 int add(byte item)
          Adds a byte into the buffer.
 void clear()
          Resets this buffer.
 boolean compareWith(byte[] buffer)
          Compares the content of this buffer with another buffer that must be long enough.
 long getChecksum(java.util.zip.Checksum crc)
          Calculates the checksum of the stored data with a given algorithm.
 boolean isFull()
           
 void writeTo(DataOutput different)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CyclicBuffer

public CyclicBuffer(int size)
Creates a new instance of CyclicBuffer.

Method Detail

add

public int add(byte item)
Adds a byte into the buffer.

Returns:
value that was rewritten in this RR buffer on insertion, or -1 when the buffer was not fully filled yet

clear

public void clear()
Resets this buffer.


compareWith

public boolean compareWith(byte[] buffer)
Compares the content of this buffer with another buffer that must be long enough.


getChecksum

public long getChecksum(java.util.zip.Checksum crc)
Calculates the checksum of the stored data with a given algorithm. This method does not call the reset operation on the checksumer.


writeTo

public void writeTo(DataOutput different)
             throws java.io.IOException
Throws:
java.io.IOException

isFull

public boolean isFull()