com.jamonapi.utils
Class BufferList

java.lang.Object
  extended by com.jamonapi.utils.BufferList
All Implemented Interfaces:
DetailData

public class BufferList
extends java.lang.Object
implements DetailData

This object can contain a configurable number of items in a buffer. The items kept are rows in a 2 dim array and so the data can be viewed in a table. It is used in jamon to store recent exceptions, and sql queries from the various proxy classes. However it may be used elsewhere. It is thread safe. By default the buffer holds 50 elements, but this can be overridden in the constructor.

It uses a bufferHolder to determine whether a value should be added and another one removed when the buffer is full. For example the value could only be added if the new value is greater than the smallest member of the BufferList. Simply implement the BufferHolder interface to implement your desired rules.


Constructor Summary
BufferList(java.lang.String[] header)
          Constructor that takes the header of the structure of the rows that are stored.
BufferList(java.lang.String[] header, BufferHolder bufferHolder)
          Pass in the header and bufferHolder to be used
BufferList(java.lang.String[] header, int bufferSize)
          Use a FIFOBuffer and specify its header and size
BufferList(java.lang.String[] header, int bufferSize, BufferHolder bufferHolder)
          Specify the header, bufferSize and BufferHolder to be used in the BufferList
 
Method Summary
 void addRow(java.lang.Object obj)
           
 void addRow(java.lang.Object[] row)
          Add a row to be held in the buffer.
 BufferList copy()
           
 void disable()
          Disable monitoring
 void enable()
          Enable monitoring
 int getBufferSize()
          Get the number of Exceptions that can be stored in the buffer before the oldest entries must be removed.
 java.util.List getCollection()
          Return the underlying Collection that holds the BufferList
 java.lang.Object[][] getData()
          Deprecated. 
 DetailData getDetailData()
           
 java.lang.String[] getHeader()
          Get the header that can be used to display the buffer.
 int getRowCount()
          Return the rows in the BufferList
 boolean hasData()
          Return true if the bufferList has data
 boolean isEmpty()
          Return true if the bufferList is empty
 boolean isEnabled()
          Returns true if MonProxy is enabled.
 void reset()
          Reset BufferList.
 void resetBuffer()
          Remove all Exceptions from the buffer.
 void setBufferHolder(BufferHolder bufferHolder)
           
 void setBufferSize(int newBufferSize)
          Set the number of Exceptions that can be stored in the buffer before the oldest entries must be removed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BufferList

public BufferList(java.lang.String[] header)
Constructor that takes the header of the structure of the rows that are stored. For example header could be {"Time", "Exception info",}; Uses a FIFOBuffer.

Parameters:
header -

BufferList

public BufferList(java.lang.String[] header,
                  BufferHolder bufferHolder)
Pass in the header and bufferHolder to be used


BufferList

public BufferList(java.lang.String[] header,
                  int bufferSize)
Use a FIFOBuffer and specify its header and size


BufferList

public BufferList(java.lang.String[] header,
                  int bufferSize,
                  BufferHolder bufferHolder)
Specify the header, bufferSize and BufferHolder to be used in the BufferList

Method Detail

getBufferSize

public int getBufferSize()
Get the number of Exceptions that can be stored in the buffer before the oldest entries must be removed.


setBufferHolder

public void setBufferHolder(BufferHolder bufferHolder)

setBufferSize

public void setBufferSize(int newBufferSize)
Set the number of Exceptions that can be stored in the buffer before the oldest entries must be removed. A value of 0 will disable the collection of Exceptions in the buffer. Note if MonProxy is disabled exceptions will also not be put in the buffer.


resetBuffer

public void resetBuffer()
Remove all Exceptions from the buffer. Not sure why this was needed vs reset()


isEmpty

public boolean isEmpty()
Return true if the bufferList is empty


hasData

public boolean hasData()
Return true if the bufferList has data


getRowCount

public int getRowCount()
Return the rows in the BufferList


getCollection

public java.util.List getCollection()
Return the underlying Collection that holds the BufferList


isEnabled

public boolean isEnabled()
Returns true if MonProxy is enabled.


enable

public void enable()
Enable monitoring


disable

public void disable()
Disable monitoring


reset

public void reset()
Reset BufferList. It will empty the buffer and leave its size at the current value


getHeader

public java.lang.String[] getHeader()
Get the header that can be used to display the buffer. Use getDetailData() method instead.

Specified by:
getHeader in interface DetailData

getData

@Deprecated
public java.lang.Object[][] getData()
Deprecated. 

Get the buffer as an array, so it can be displayed. Use getDetailData() method instead.

Specified by:
getData in interface DetailData

getDetailData

public DetailData getDetailData()

addRow

public void addRow(java.lang.Object[] row)
Add a row to be held in the buffer. If the buffer is full the oldest one will be removed.


addRow

public void addRow(java.lang.Object obj)

copy

public BufferList copy()