Package org.apache.log4j.helpers
Class CyclicBuffer
java.lang.Object
org.apache.log4j.helpers.CyclicBuffer
Holds
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
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCyclicBuffer
(int maxSize) Constructs a new instance of at mostmaxSize
events. -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(LoggingEvent event) Adds anevent
as the last event in the buffer.get()
Gets the oldest (first) element in the buffer.get
(int i) Gets the ith oldest event currently in the buffer.int
int
length()
Gets the number of elements in the buffer.void
resize
(int newSize) Resizes the cyclic buffer tonewSize
.
-
Field Details
-
ea
LoggingEvent[] ea -
first
int first -
last
int last -
numElems
int numElems -
maxSize
int maxSize
-
-
Constructor Details
-
CyclicBuffer
Constructs a new instance of at mostmaxSize
events. ThemaxSize
argument must a positive integer.- Parameters:
maxSize
- The maximum number of elements in the buffer.- Throws:
IllegalArgumentException
-
-
Method Details
-
add
Adds anevent
as the last event in the buffer. -
get
Gets the oldest (first) element in the buffer. The oldest element is removed from the buffer. -
get
Gets the ith oldest event currently in the buffer. If i is outside the range 0 to the number of elements currently in the buffer, thennull
is returned. -
getMaxSize
public int getMaxSize() -
length
public int length()Gets the number of elements in the buffer. This number is guaranteed to be in the range 0 tomaxSize
(inclusive). -
resize
public void resize(int newSize) Resizes the cyclic buffer tonewSize
.- Throws:
IllegalArgumentException
- ifnewSize
is negative.
-