Public Member Functions | |
LogStringBuffer () | |
void | append (char ch, StringBuilder str) |
String | toString () |
void | dump () |
Private Member Functions | |
void | clear () |
char[] | doubleBuffer (char[] originalBuffer) |
boolean | compare (char[] src, int srcPos, char[]dest) |
boolean | compareFromLastChar (char src[], int lastCharPos, char[] dest) |
LogTypeHelper | lookForStartTag (char[] str, int pos) |
Private Attributes | |
char[] | buffer = new char[1024] |
int | bufferPos = 0 |
int | startTagPos |
char[][] | xmlOpeningTags |
final int | minStartXMLTagSize |
char[][] | xmlClosingTags |
char[] | cdataStart = (new String("<![CDATA[")).toCharArray() |
char[] | cdataEnd = (new String("]]>")).toCharArray() |
int | cdataStartPos |
int | cdataEndPos |
LogTypeHelper | startTag |
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.
|
The constructor
|
|
Append a char to the end of the buffer.
This method checks if the buffer contains the XML representing a log entry. The
Note: the content of the
|
|
Clear the buffer |
|
Compare the
The method checks if all the chars starting at
|
|
Compare the content of 2 array of chars starting from the position of the last char of the first array.
The method checks is
|
|
Doubles the array.
It creates a new array having the size double as the size of the passed array.
|
|
|
|
Look for an XML tag in the passed string, starting at the given position.
|
|
|
|
The array of chars where the chars read from the input file are written.
The size passed in the construct is doubled when the length is not enough by calling |
|
The position where a new char must be written in the array It represents also the length of the string in the buffer. |
|
The end of a CDATA section |
|
The position of the ending of the cdata section |
|
The starting of a CDATA section |
|
The position of the starting of the cdata section |
|
This property, initialized in the constructor, contains the size of the shortest start tag and is used to reduce the number of checks while looking for the starting tag |
|
The starting XML tag (it is |
|
The position of the starting XML tag The value of this property initially is -1 and is set to be equal to the position of the '<' char of the starting tag until a valid tag is found |
|
The closing XML tags of the log types for example </trace> and </info>
The first dimension is the position of the tag in the array of |
|
The XML tags of the log types (including the leading '<') for example <Trace and <Info
The first dimension is the position of the tag in the array of |