net.logAnalyzer.handlers
Interface LALogHandler

All Superinterfaces:
java.lang.Runnable
All Known Implementing Classes:
AbstractLogHandler, EmptyLogHandler, FilteredLogHandler

public interface LALogHandler
extends java.lang.Runnable

This interface defines the log file handlers methods. A log file handler is used to apply filters and analyzers on a log file. Filters dans analyzers can be added before and/or after log file parsing.

Version:
0.1
Author:
Karim REFEYTON

Method Summary
 void addLogHandlerListener(LALogHandlerListener listener)
          Adds a listener.
 void fireEndParsing()
          Fires an end parsing event.
 void fireStartParsing()
          Fires a start parsing event.
 LAAnalyzer[] getAnalyzers()
          Returns log analyzers added to the handler with setAnalyzers(LAAnalyzer[]).
 LAConverter getConverter(int index)
          Returns the converter at the specified index.
 LAConverter getConverter(java.lang.String literal)
          Returns the converter identified by the specified literal (for example, "%m" generally returns the messageLabel converter).
 int getConverterIndex(java.lang.String literal)
          Returns the index of the identified by the specified literal.
 LAConverter[] getConverters()
          Returns pattern converters.
 java.lang.Exception getLastException()
          Returns the last exception thrown by the parsing process.
 int getMaxRecords()
          Returns the number of records to parse; 0 for no limitation.
 LAMessage getMessage(int index)
          Returns the messageLabel at the specified position.
 LAConverter getMessageConverter()
          Returns the current messageLabel converter used to extend messageLabel text with unparsed lines.
 LAMessage[] getMessages(int start, int end)
          Returns the messages between specified positions.
 int getPercentDone()
          Returns the done percentage of the parsed file.
 int getSize()
          Returns the real number of messages in the log, not only in cache in case of a load on demand parsed log.
 boolean isParsing()
          Returns true if the handler is currently parsing the log.
 void parse()
          Parses the log content of the FilesSetReader.
 void removeLogHandlerListener(LALogHandlerListener listener)
          Removes a listener.
 void setAnalyzers(LAAnalyzer[] newAnalyzers)
          Adds new analyzers to the log handler.
 void setMaxRecords(int maxRecords)
          Number of records to parse; 0 for no limitation.
 
Methods inherited from interface java.lang.Runnable
run
 

Method Detail

getAnalyzers

public LAAnalyzer[] getAnalyzers()
Returns log analyzers added to the handler with setAnalyzers(LAAnalyzer[]).

Returns:
Log analyzers.

setAnalyzers

public void setAnalyzers(LAAnalyzer[] newAnalyzers)
Adds new analyzers to the log handler.

Parameters:
newAnalyzers - Analyzers to add.

getConverter

public LAConverter getConverter(int index)
Returns the converter at the specified index.

Parameters:
index - Converter index.
Returns:
Converter or null if unknown.

getConverter

public LAConverter getConverter(java.lang.String literal)
                         throws UnknownOrLiteralConverterException
Returns the converter identified by the specified literal (for example, "%m" generally returns the messageLabel converter).

Parameters:
literal - Converter literal as %m" or %"p" or "%H{CLIENTIP}".
Returns:
Converter or null if unknown.
Throws:
UnknownOrLiteralConverterException - If the literal does not identify a non literal column.

getConverters

public LAConverter[] getConverters()
Returns pattern converters.

Returns:
Pattern converters.

getConverterIndex

public int getConverterIndex(java.lang.String literal)
                      throws UnknownOrLiteralConverterException
Returns the index of the identified by the specified literal.

Parameters:
literal - Converter literal as %m" or %"p" or "%H{CLIENTIP}".
Returns:
Index of the converter.
Throws:
UnknownOrLiteralConverterException - If the literal does not identify a non literal column.

getLastException

public java.lang.Exception getLastException()
Returns the last exception thrown by the parsing process.

Returns:
Last exception or null parsing was succesfull.

getMaxRecords

public int getMaxRecords()
Returns the number of records to parse; 0 for no limitation.

Returns:
maxRecords Number of records.

setMaxRecords

public void setMaxRecords(int maxRecords)
Number of records to parse; 0 for no limitation.

Parameters:
maxRecords - Number of records.

getMessageConverter

public LAConverter getMessageConverter()
Returns the current messageLabel converter used to extend messageLabel text with unparsed lines.

Returns:
Message converter.
See Also:
LAMessage.extendsMessage(String)

getPercentDone

public int getPercentDone()
Returns the done percentage of the parsed file. If the handler is not parsing, returns 0.

Returns:
Done percentage.

getMessage

public LAMessage getMessage(int index)
Returns the messageLabel at the specified position.

Parameters:
index - Physical index of the messageLabel in the log file.
Returns:
Message.

getMessages

public LAMessage[] getMessages(int start,
                               int end)
Returns the messages between specified positions. Uses getMessage(int)to read messageLabel from the log file.

Parameters:
start - start physicial index (included in the result).
end - end physical index (included in the result).
Returns:
messages.

getSize

public int getSize()
Returns the real number of messages in the log, not only in cache in case of a load on demand parsed log.

Returns:
physical number of messages.

isParsing

public boolean isParsing()
Returns true if the handler is currently parsing the log.

Returns:
true if parsing; false otherwise.

addLogHandlerListener

public void addLogHandlerListener(LALogHandlerListener listener)
Adds a listener.

Parameters:
listener - Lister to add.

fireStartParsing

public void fireStartParsing()
Fires a start parsing event.


fireEndParsing

public void fireEndParsing()
Fires an end parsing event.


parse

public void parse()
           throws ParsingException
Parses the log content of the FilesSetReader. Calls, in order :

Because a LALogHandler is a Runnable, for a threaded parsing you must start it in a new Thread :

 handler.addLogHandlerListener(myLALogHandlerListener);
 Thread handlerThread = new Thread(handler);
 handlerThread.start();
 

Throws:
ParsingException - If can't parse messageLabel.
See Also:
AbstractLogHandler

removeLogHandlerListener

public void removeLogHandlerListener(LALogHandlerListener listener)
Removes a listener.

Parameters:
listener - Lister to remove.


Copyright © 2006 null. All Rights Reserved.