public class CyclicBuffer extends Object
LoggingEvents
for immediate or differed display.
This buffer gives read access to any element in the buffer not just the first or last element.
Constructor and Description |
---|
CyclicBuffer(int maxSize)
Constructs a new instance of at most
maxSize events. |
Modifier and Type | Method and Description |
---|---|
void |
add(LoggingEvent event)
Adds an
event as the last event in the buffer. |
LoggingEvent |
get()
Gets the oldest (first) element in the buffer.
|
LoggingEvent |
get(int i)
Gets the ith oldest event currently in the buffer.
|
int |
getMaxSize() |
int |
length()
Gets the number of elements in the buffer.
|
void |
resize(int newSize)
Resizes the cyclic buffer to
newSize . |
public CyclicBuffer(int maxSize) throws IllegalArgumentException
maxSize
events.
The maxSize
argument must a positive integer.maxSize
- The maximum number of elements in the buffer.IllegalArgumentException
public void add(LoggingEvent event)
event
as the last event in the buffer.public LoggingEvent get()
public LoggingEvent get(int i)
null
is returned.public int getMaxSize()
public int length()
maxSize
(inclusive).public void resize(int newSize)
newSize
.IllegalArgumentException
- if newSize
is negative.Copyright © 1999-2023 The Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.