cern.colt.buffer
Class ObjectBuffer

java.lang.Object
  extended by cern.colt.PersistentObject
      extended by cern.colt.buffer.ObjectBuffer
All Implemented Interfaces:
ObjectBufferConsumer, java.io.Serializable, java.lang.Cloneable

public class ObjectBuffer
extends PersistentObject
implements ObjectBufferConsumer

Fixed sized (non resizable) streaming buffer connected to a target ObjectBufferConsumer to which data is automatically flushed upon buffer overflow.

Author:
wolfgang.hoschek@cern.ch
See Also:
Serialized Form

Field Summary
protected  int capacity
           
protected  java.lang.Object[] elements
           
protected  ObjectArrayList list
           
protected  int size
           
protected  ObjectBufferConsumer target
           
 
Fields inherited from class cern.colt.PersistentObject
serialVersionUID
 
Constructor Summary
ObjectBuffer(ObjectBufferConsumer target, int capacity)
          Constructs and returns a new buffer with the given target.
 
Method Summary
 void add(java.lang.Object element)
          Adds the specified element to the receiver.
 void addAllOf(ObjectArrayList list)
          Adds all elements of the specified list to the receiver.
 void clear()
          Sets the receiver's size to zero.
 void flush()
          Adds all internally buffered elements to the receiver's target, then resets the current buffer size to zero.
 
Methods inherited from class cern.colt.PersistentObject
clone
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

target

protected ObjectBufferConsumer target

elements

protected java.lang.Object[] elements

list

protected ObjectArrayList list

capacity

protected int capacity

size

protected int size
Constructor Detail

ObjectBuffer

public ObjectBuffer(ObjectBufferConsumer target,
                    int capacity)
Constructs and returns a new buffer with the given target.

Parameters:
target - the target to flush to.
capacity - the number of points the buffer shall be capable of holding before overflowing and flushing to the target.
Method Detail

add

public void add(java.lang.Object element)
Adds the specified element to the receiver.

Parameters:
element - the element to add.

addAllOf

public void addAllOf(ObjectArrayList list)
Adds all elements of the specified list to the receiver.

Specified by:
addAllOf in interface ObjectBufferConsumer
Parameters:
list - the list of which all elements shall be added.

clear

public void clear()
Sets the receiver's size to zero. In other words, forgets about any internally buffered elements.


flush

public void flush()
Adds all internally buffered elements to the receiver's target, then resets the current buffer size to zero.