com.jamonapi.utils
Class FIFOBufferHolder

java.lang.Object
  extended by com.jamonapi.utils.FIFOBufferHolder
All Implemented Interfaces:
BufferHolder

public class FIFOBufferHolder
extends java.lang.Object
implements BufferHolder

First-in, first-out buffer. When the BufferList is filled the first element is removed to make room for the newest value, then the second oldest etc. Used in BufferList and subsequently JAMonBufferListeners.

Author:
steve souza

Constructor Summary
FIFOBufferHolder()
           
 
Method Summary
 void add(java.lang.Object replaceWithObj)
          Add the passed object to the array if BufferList is not full or shouldReplaceWith returns true
 BufferHolder copy()
          return a usable copy of the BufferHolder
 java.util.List getCollection()
          Get the underlying collection
 java.util.List getOrderedCollection()
          Get the Collection in sorted order
 void remove(java.lang.Object replaceWithObj)
          Remove the smallest element from the BufferList if the buffer is full and shouldReplaceWith(...) returns true.
 void setCollection(java.util.List list)
           
 boolean shouldReplaceWith(java.lang.Object replaceWithObj)
          Returns true if this object is greater than the smallest value in the buffer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FIFOBufferHolder

public FIFOBufferHolder()
Method Detail

add

public void add(java.lang.Object replaceWithObj)
Description copied from interface: BufferHolder
Add the passed object to the array if BufferList is not full or shouldReplaceWith returns true

Specified by:
add in interface BufferHolder

remove

public void remove(java.lang.Object replaceWithObj)
Description copied from interface: BufferHolder
Remove the smallest element from the BufferList if the buffer is full and shouldReplaceWith(...) returns true.

Specified by:
remove in interface BufferHolder

shouldReplaceWith

public boolean shouldReplaceWith(java.lang.Object replaceWithObj)
Description copied from interface: BufferHolder
Returns true if this object is greater than the smallest value in the buffer

Specified by:
shouldReplaceWith in interface BufferHolder

getCollection

public java.util.List getCollection()
Description copied from interface: BufferHolder
Get the underlying collection

Specified by:
getCollection in interface BufferHolder

getOrderedCollection

public java.util.List getOrderedCollection()
Description copied from interface: BufferHolder
Get the Collection in sorted order

Specified by:
getOrderedCollection in interface BufferHolder

setCollection

public void setCollection(java.util.List list)
Specified by:
setCollection in interface BufferHolder

copy

public BufferHolder copy()
Description copied from interface: BufferHolder
return a usable copy of the BufferHolder

Specified by:
copy in interface BufferHolder