public class LogStringBuffer
extends java.lang.Object
LogStringBuffer is a buffer of chars supporting the loading of logs
from a file.
The buffer contains the chars read from the file and passed through the append().
For each new chars, append() checks if a closing or an ending XML tag of a log is in the buffer.
When a whole XML representing a log is in the buffer, it is returned to the caller and the
buffer cleared to be ready to look for the next XML.
The size of the buffer is initially set to a default value and it is doubled whenever
the algorithm needs more room in the array of char.
This functionality was initially implemented encapsulating a StringBuilder property
but it was too slow compared to basic chars manipulation.
| Constructor and Description |
|---|
LogStringBuffer()
The constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
append(char ch,
java.lang.StringBuilder str)
Append a char to the end of the buffer.
|
void |
dump() |
java.lang.String |
toString() |
public LogStringBuffer()
size - The size of the rotating bufferpublic void append(char ch,
java.lang.StringBuilder str)
This method checks if the buffer contains the XML representing a log entry.
The str parameter is used to return the string with a log and
must be empty.
The method does not perform any check about the content of the passed
StringBuilder so it is the caller that must ensure the correctness.
Note: the content of the StringBuilder is changed only
and only if there is a whole log in the buffer.
ch - The char to appendstr - A string representing the new log;
the content of this parameter is changed if and only if there is
a log in the bufferpublic java.lang.String toString()
toString in class java.lang.Objectpublic void dump()