org.openmdx.kernel.log.impl
Class LogFileParser

java.lang.Object
  extended by org.openmdx.kernel.log.impl.LogFileParser
All Implemented Interfaces:
LogEntityReader

public class LogFileParser
extends Object
implements LogEntityReader

This class parses log files into LogEvents


Constructor Summary
LogFileParser(File aFile)
          Create a new LogFileParser.
 
Method Summary
 int readBinary(long startPos, byte[] buffer)
          Reads from a start position a given number of bytes from the log file.
 long readLogEvents(long startPos, int maxEvents, long maxProcessingTime, LogEventFilter filter, ArrayList events)
          Parses the log entity for log events.
 long readLogEvents(long startPos, int maxEvents, long maxProcessingTime, LogEventFilter filter, ObjectOutputStream target)
           
 long size()
          Returns the size of the log entity in bytes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LogFileParser

public LogFileParser(File aFile)
Create a new LogFileParser.

Method Detail

size

public long size()
          throws IOException
Returns the size of the log entity in bytes

Specified by:
size in interface LogEntityReader
Returns:
The log entity size
Throws:
IOException - Thrown if file does not exist or cannot be read
UnsupportedOperationException - if the entity size is not supported on the currently used log entity

readLogEvents

public long readLogEvents(long startPos,
                          int maxEvents,
                          long maxProcessingTime,
                          LogEventFilter filter,
                          ArrayList events)
                   throws IOException
Description copied from interface: LogEntityReader
Parses the log entity for log events. Returns at most events log events. If the start position is >0 the parser seeks to next starting log event.

If the file position is a positive number the reading starts from the given file position. If the given file position is a negative number it is used as offset from the end of the file.

Be prepared that the requested number of events can be limited.

The parser returns if either the end of the file is reached, the max number of events is parsed or the max processing time is exceeded.

Specified by:
readLogEvents in interface LogEntityReader
Parameters:
startPos - The start position where the parsing starts
maxEvents - The max number of events to be processed
maxProcessingTime - The max processing time in milliseconds. A value of 0 means no time limit.
filter - A log event filter
events - The event list to be filled with the parsed
Returns:
The file position after reading all the events
Throws:
IOException - Thrown if file does not exist or cannot be read

readLogEvents

public long readLogEvents(long startPos,
                          int maxEvents,
                          long maxProcessingTime,
                          LogEventFilter filter,
                          ObjectOutputStream target)
                   throws IOException
Specified by:
readLogEvents in interface LogEntityReader
Throws:
IOException

readBinary

public int readBinary(long startPos,
                      byte[] buffer)
               throws IOException
Reads from a start position a given number of bytes from the log file.

Specified by:
readBinary in interface LogEntityReader
Parameters:
startPos - The start position where the parsing starts
buffer - The allocated buffer to receive the file data
Returns:
The number of bytes read. 0 indicates EOF
Throws:
IOException - Thrown if file does not exist or cannot be read


This software is published under the BSD license. Copyright © 2003-2007, OMEX AG, Switzerland, All rights reserved. Use is subject to license terms.