TPTP 4.4.0 Monitoring Tools Project
Public API Specification

org.eclipse.hyades.logging.adapter.util
Class BufferedPeriodicReader

java.lang.Object
  extended byorg.eclipse.hyades.logging.adapter.util.BufferedPeriodicReader
Direct Known Subclasses:
BufferedSinglePassReader

public class BufferedPeriodicReader
extends java.lang.Object

BufferedPeriodicReader reads a file line by line. It holds a pointer offset to the last read byte in order to resume when the file is appended or updated.


Field Summary
protected  int bytesRead
           
protected  boolean flushingMode
           
protected  int lastOffset
           
protected  byte[] logBuffer
           
protected  int logBufferInitialSize
          Initial size of buffer to read data from log file into.
 
Constructor Summary
BufferedPeriodicReader(java.lang.String newFilename)
          Create a BufferedPeriodicReader for the specified file.
BufferedPeriodicReader(java.lang.String newFilename, java.lang.String converter)
          Create a BufferedPeriodicReader for the specified file and using the specified converter command.
BufferedPeriodicReader(java.lang.String newFilename, java.lang.String[] convArray)
          Create a BufferedPeriodicReader for the specified file and using the specified converter command stored as an array of tokens.
BufferedPeriodicReader(java.lang.String newFilename, java.lang.String converter, java.lang.String shell)
          Create a BufferedPeriodicReader for the specified file and using the specified converter command and shell to run the converter command in.
 
Method Summary
 void close()
          Close the file.
protected  java.lang.String getCharset()
           
 int getConfidenceBufferSize()
          Get the confidence buffer size.
protected  java.lang.String getConverter()
           
 java.lang.String[] getConverterArray()
          Get the converter command array.
 int getFileFooterSize()
          Get the file footer size.
protected  java.lang.String getFilename()
           
 long getFilePointer()
          Get the offset within the file where the next read will be done.
protected  long getLastSize()
           
 long getSize()
          Returns the size of the file being read
 boolean isFlushingMode()
           
 boolean isMultiFile()
          Returns whether a multi-file log is being read.
 void prepare()
          Prepare the file for reading.
 java.lang.String readLine()
          Read a line of the file and return it.
protected  void runConverter()
           
 void setCharset(java.lang.String cs)
          Set the character set of file to read.
 void setConfidenceBufferSize(int confidenceBufferSize)
          Set the confidence buffer size.
 void setConverter(java.lang.String converter)
          Set the converter command string.
 void setConverter(java.lang.String[] converterArray)
          Set the converter command array.
 void setFileFooterSize(int fileFooterSize)
          Set the file footer size.
 void setFilename(java.lang.String filename)
          Set the name of the file to read.
 void setFlushingMode(boolean flushingMode)
           
protected  void setLastSize(long lastSize)
           
 void setMultiFile(boolean multiFile)
          Set the multi-file indicator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logBufferInitialSize

protected int logBufferInitialSize
Initial size of buffer to read data from log file into. This value may need to be adjusted to improve performance.


bytesRead

protected int bytesRead

logBuffer

protected byte[] logBuffer

lastOffset

protected int lastOffset

flushingMode

protected boolean flushingMode
Constructor Detail

BufferedPeriodicReader

public BufferedPeriodicReader(java.lang.String newFilename)
Create a BufferedPeriodicReader for the specified file.

Parameters:
newFilename - - name of the file to read.

BufferedPeriodicReader

public BufferedPeriodicReader(java.lang.String newFilename,
                              java.lang.String converter)
Create a BufferedPeriodicReader for the specified file and using the specified converter command.

Parameters:
newFilename - - name of the file to read.
converter - - command to do any required conversion on the file before reading it.

BufferedPeriodicReader

public BufferedPeriodicReader(java.lang.String newFilename,
                              java.lang.String converter,
                              java.lang.String shell)
Create a BufferedPeriodicReader for the specified file and using the specified converter command and shell to run the converter command in.

Parameters:
newFilename - - name of the file to read.
converter - - command to do any required conversion on the file before reading it.
shell - - shell to run the converter command in.

BufferedPeriodicReader

public BufferedPeriodicReader(java.lang.String newFilename,
                              java.lang.String[] convArray)
Create a BufferedPeriodicReader for the specified file and using the specified converter command stored as an array of tokens.

Parameters:
newFilename - - name of the file to read.
convArray - - command stored as an array to do any required conversion on the file before reading it.
Method Detail

setCharset

public void setCharset(java.lang.String cs)
Set the character set of file to read. The character set is used to ready bytes from the file.

Parameters:
cs - - character set of the file

runConverter

protected void runConverter()
                     throws java.lang.Exception
Throws:
java.lang.Exception

prepare

public void prepare()
             throws java.lang.Exception
Prepare the file for reading. This includes running any converter command and finding the place in the file to start reading from.

Throws:
java.lang.Exception

close

public void close()
Close the file.


readLine

public java.lang.String readLine()
                          throws java.io.IOException
Read a line of the file and return it. If the end of file is reached, then save the last n bytes of the file when n is the confidence buffer size. The confidence buffer is used the next time the file is prepared to determine if the file has been changed or appended.

Returns:
the line read from the file.
Throws:
java.io.IOException

getFilePointer

public long getFilePointer()
Get the offset within the file where the next read will be done.

Returns:
Returns the offset within the file where we are currently reading.

getConfidenceBufferSize

public int getConfidenceBufferSize()
Get the confidence buffer size. The confidence buffer is used when the file is prepared to determine if the file has been changed or appended.

Returns:
the confidence buffer size.

setConfidenceBufferSize

public void setConfidenceBufferSize(int confidenceBufferSize)
Set the confidence buffer size. The confidence buffer is used when the file is prepared to determine if the file has been changed or appended.

Parameters:
confidenceBufferSize - - the confidence buffer size to set.

getFileFooterSize

public int getFileFooterSize()
Get the file footer size. The file footer is the last part of the file that contains mostly static data and does not need to be included when parsing. Note, not all files have footers. The footer needs to be accounted for when determinig if the file has been appended.

Returns:
the file footer size.

setFileFooterSize

public void setFileFooterSize(int fileFooterSize)
Set the file footer size. The file footer is the last part of the file that contains mostly static data and does not need to be included when parsing. Note, not all files have footers. The footer needs to be accounted for when determinig if the file has been appended.

Parameters:
fileFooterSize - The fileFooterSize to set.

isMultiFile

public boolean isMultiFile()
Returns whether a multi-file log is being read.

Returns:
true if a multi-file log is being read, false otherwise.

setMultiFile

public void setMultiFile(boolean multiFile)
Set the multi-file indicator

Parameters:
multiFile - - boolean value indicating whether the log is mult-file.

getConverterArray

public java.lang.String[] getConverterArray()
Get the converter command array. The command can be stored as an array of tokens.

Returns:
the converter command array.

setConverter

public void setConverter(java.lang.String[] converterArray)
Set the converter command array. The command can be stored either as an array of tokens or a string. This method stores it as an array.

Parameters:
converterArray - - the converter command array to set.

setFilename

public void setFilename(java.lang.String filename)
Set the name of the file to read.

Parameters:
filename - - the name of the file to read.

setConverter

public void setConverter(java.lang.String converter)
Set the converter command string. The command can be stored either as an array of tokens or a string. This method stores it as a string.

Parameters:
converter - The converter to set.

getSize

public long getSize()
Returns the size of the file being read

Returns:
the size of the file the last time it was read.

getConverter

protected java.lang.String getConverter()

getFilename

protected java.lang.String getFilename()

getLastSize

protected long getLastSize()

setLastSize

protected void setLastSize(long lastSize)

getCharset

protected java.lang.String getCharset()

isFlushingMode

public boolean isFlushingMode()

setFlushingMode

public void setFlushingMode(boolean flushingMode)

TPTP 4.4.0 Monitoring Tools Project
Public API Specification