Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

alma::acs::logging::engine::io::LogStringBuffer Class Reference

List of all members.

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

Detailed Description

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.

Author:
acaproni


Constructor & Destructor Documentation

alma::acs::logging::engine::io::LogStringBuffer::LogStringBuffer  )  [inline]
 

The constructor

Parameters:
size The size of the rotating buffer


Member Function Documentation

void alma::acs::logging::engine::io::LogStringBuffer::append char  ch,
StringBuilder  str
[inline]
 

Append a char to the end of the buffer.

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.

Parameters:
ch The char to append
str A string representing the new log; the content of this parameter is changed if and only if there is a log in the buffer

void alma::acs::logging::engine::io::LogStringBuffer::clear  )  [inline, private]
 

Clear the buffer

boolean alma::acs::logging::engine::io::LogStringBuffer::compare char[]  src,
int  srcPos,
char[]  dest
[inline, private]
 

Compare the src array starting at position srcPos with the dest array.

The method checks if all the chars starting at srcPos position of the first array are equal to the chars of the second array.
The comparison lasts for all the chars of the dest array i.e. this method compares the chars in src[newPos, newPos+dest.length] with those in dest[0,dest.length].

Parameters:
src The first array to compare
srcPos The position inside src to start the comparison at
dest The array to compare
Returns:
true If the chars of the src starting at srcPos are equal to the chars of dest.

boolean alma::acs::logging::engine::io::LogStringBuffer::compareFromLastChar char  src[],
int  lastCharPos,
char[]  dest
[inline, private]
 

Compare the content of 2 array of chars starting from the position of the last char of the first array.

The method checks is src and dest are equal. The check is done in reverse order, starting from the position of the last char of the first array, src.
The comparison lasts for all the chars of the dest array i.e. this method compares the chars in src[lastCharPos-dest.length,lastCharPos] with those in dest[0,dest.length].

Parameters:
src The first array to compare
lastCharPos The position of the last char of src to compare
dest The array to compare
Returns:
true If the chars of the src starting at lastCharPos-dest.length are equal to the chars of dest.

char [] alma::acs::logging::engine::io::LogStringBuffer::doubleBuffer char[]  originalBuffer  )  [inline, private]
 

Doubles the array.

It creates a new array having the size double as the size of the passed array.
The content of the first array is copied in the newly created one.

Parameters:
originalBuffer The buffer to copy in the new array of a double size

void alma::acs::logging::engine::io::LogStringBuffer::dump  )  [inline]
 

LogTypeHelper alma::acs::logging::engine::io::LogStringBuffer::lookForStartTag char[]  str,
int  pos
[inline, private]
 

Look for an XML tag in the passed string, starting at the given position.

Parameters:
str The string to check
pos The position in the str to look for the tag
Returns:
The LogTypehelper corresponding to the XML tag null if not XML tag is found at the given position

String alma::acs::logging::engine::io::LogStringBuffer::toString  )  [inline]
 

Returns:
a String representation of the buffer


Member Data Documentation

char [] alma::acs::logging::engine::io::LogStringBuffer::buffer = new char[1024] [private]
 

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 doubleBuffer().
While reading logs from a file, each log is temporarily written in this array do it begins with an XML opening tag and terminates with the closing tag. Any extra char read at the beginning of an opening tag is skipped.

int alma::acs::logging::engine::io::LogStringBuffer::bufferPos = 0 [private]
 

The position where a new char must be written in the array buffer.

It represents also the length of the string in the buffer.

char [] alma::acs::logging::engine::io::LogStringBuffer::cdataEnd = (new String("]]>")).toCharArray() [private]
 

The end of a CDATA section

int alma::acs::logging::engine::io::LogStringBuffer::cdataEndPos [private]
 

The position of the ending of the cdata section

char [] alma::acs::logging::engine::io::LogStringBuffer::cdataStart = (new String("<![CDATA[")).toCharArray() [private]
 

The starting of a CDATA section

int alma::acs::logging::engine::io::LogStringBuffer::cdataStartPos [private]
 

The position of the starting of the cdata section

final int alma::acs::logging::engine::io::LogStringBuffer::minStartXMLTagSize [private]
 

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

LogTypeHelper alma::acs::logging::engine::io::LogStringBuffer::startTag [private]
 

The starting XML tag (it is null when the start tag has not yet been found in the buffer

int alma::acs::logging::engine::io::LogStringBuffer::startTagPos [private]
 

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

char [][] alma::acs::logging::engine::io::LogStringBuffer::xmlClosingTags [private]
 

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 LogTypeHelper, the second dimension is the length of the tag

char [][] alma::acs::logging::engine::io::LogStringBuffer::xmlOpeningTags [private]
 

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 LogTypeHelper, the second dimension is the length of the tag


The documentation for this class was generated from the following file:
Generated on Thu Apr 30 02:53:50 2009 for ACS Java API by doxygen 1.3.8