org.log4j.helpers
Class CyclicBuffer
java.lang.Object
|
+--org.log4j.helpers.CyclicBuffer
- public class CyclicBuffer
- extends Object
CyclicBuffer is used by other appenders to hold LoggingEvents
for immediate or differed display.
This buffer gives read access to any element in the buffer not
just the first or last element.
- Since:
- 0.9.0
- Author:
- Ceki Gülcü
Constructor Summary |
CyclicBuffer(int maxSize)
Instantiate a new CyclicBuffer of at most maxSize events. |
Method Summary |
void |
add(LoggingEvent event)
Add an event as the last event in the buffer. |
LoggingEvent |
get(int i)
Get the ith oldest event currently in the buffer. |
int |
getMaxSize()
|
int |
length()
Get the number of elements in the buffer. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CyclicBuffer
public CyclicBuffer(int maxSize)
throws IllegalArgumentException
- Instantiate a new CyclicBuffer of at most
maxSize
events.
The maxSize
argument must a positive integer.
- Parameters:
maxSize
- The maximum number of elements in the buffer.
add
public void add(LoggingEvent event)
- Add an
event
as the last event in the buffer.
get
public LoggingEvent get(int i)
- Get the ith oldest event currently in the buffer. If
i is outside the range 0 to the number of elements
currently in the buffer, then
null
is returned.
getMaxSize
public int getMaxSize()
length
public int length()
- Get the number of elements in the buffer. This number is
guaranteed to be in the range 0 to
maxSize
(inclusive).
Please notify me about new log4j releases.