net.logAnalyzer.handlers
Class FilteredLogHandler

java.lang.Object
  extended bynet.logAnalyzer.handlers.FilteredLogHandler
All Implemented Interfaces:
LALogHandler, java.lang.Runnable

public class FilteredLogHandler
extends java.lang.Object
implements LALogHandler

This class implents a filtering log handler under another log handler. For example, the underlaying log handler can be a OnDemandLogHandlerparsing one or more log files, and the filtered log handler applies filters to accept or not each messageLabel of the underlaying log handler.

Version:
0.1
Author:
Karim REFEYTON

Constructor Summary
FilteredLogHandler(LALogHandler loghandler)
          Creates a log handler by filtering the specified log handler.
 
Method Summary
 void addLogHandlerListener(LALogHandlerListener listener)
          Adds a listener.
 void fireEndParsing()
          Fires an end parsing event.
 void fireStartParsing()
          Fires a start parsing event.
 void fireStepParsing()
          Fires a step parsing event.
 LAAnalyzer[] getAnalyzers()
          Delegated method.
 LAConverter getConverter(int index)
          Delegated method.
 LAConverter getConverter(java.lang.String literal)
          Delegated method.
 int getConverterIndex(java.lang.String literal)
          Delegated method.
 LAConverter[] getConverters()
          Delegated method.
 LAMessagesFilter getFilter()
          Returns the applied filter.
 java.lang.Exception getLastException()
          Delegated method.
 int getMaxRecords()
          Delegated method.
 LAMessage getMessage(int index)
          Returns the messageLabel at the specified position after filtering.
 LAConverter getMessageConverter()
          Returns the current messageLabel converter used to extend messageLabel text with unparsed lines.
 LAMessage[] getMessages(int start, int end)
          Returns the filtered messages between specified filtered positions.
 int getPercentDone()
          Delegated method.
 int getRealIndex(int filteredIndex)
          Returns the real index associated to the specified filtered index.
 int getSize()
          Delegated method.
 boolean isParsing()
          Delegated method.
 void parse()
          Parses the log content of the current LALogHandler.
 void removeLogHandlerListener(LALogHandlerListener listener)
          Removes a listener.
 void run()
          Delegated method.
 void setAnalyzers(LAAnalyzer[] newAnalyzers)
          NOP.
 void setFilter(LAMessagesFilter filter)
          Sets the filter used to accept or not the messages of the underlaying filter.
 void setMaxRecords(int maxRecords)
          Delegated method.
 void stopFiltering()
          Stop the filtering.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FilteredLogHandler

public FilteredLogHandler(LALogHandler loghandler)
Creates a log handler by filtering the specified log handler.

Parameters:
loghandler - Log handler to filter.
Method Detail

getFilter

public LAMessagesFilter getFilter()
Returns the applied filter.

Returns:
Applied filter.

setFilter

public void setFilter(LAMessagesFilter filter)
Sets the filter used to accept or not the messages of the underlaying filter.

Parameters:
filter - Filter to apply.

getRealIndex

public int getRealIndex(int filteredIndex)
Returns the real index associated to the specified filtered index. No change if no filter apply.

Parameters:
filteredIndex - Filterer index.
Returns:
Real index of the messageLabel in the real log handler.

getAnalyzers

public LAAnalyzer[] getAnalyzers()
Delegated method.

Specified by:
getAnalyzers in interface LALogHandler
Returns:
Log analyzers.
See Also:
LALogHandler.getAnalyzers()

getConverter

public LAConverter getConverter(int index)
Delegated method.

Specified by:
getConverter in interface LALogHandler
Parameters:
index - Converter index.
Returns:
Converter or null if unknown.
See Also:
LALogHandler.getConverter(int)

getConverter

public LAConverter getConverter(java.lang.String literal)
                         throws UnknownOrLiteralConverterException
Delegated method.

Specified by:
getConverter in interface LALogHandler
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.
See Also:
LALogHandler.getConverter(java.lang.String)

getConverterIndex

public int getConverterIndex(java.lang.String literal)
                      throws UnknownOrLiteralConverterException
Delegated method.

Specified by:
getConverterIndex in interface LALogHandler
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.
See Also:
LALogHandler.getConverterIndex(java.lang.String)

getConverters

public LAConverter[] getConverters()
Delegated method.

Specified by:
getConverters in interface LALogHandler
Returns:
Pattern converters.
See Also:
LALogHandler.getConverters()

getLastException

public java.lang.Exception getLastException()
Delegated method.

Specified by:
getLastException in interface LALogHandler
Returns:
Last exception or null parsing was succesfull.
See Also:
LALogHandler.getLastException()

getMaxRecords

public int getMaxRecords()
Delegated method.

Specified by:
getMaxRecords in interface LALogHandler
Returns:
maxRecords Number of records.
See Also:
LALogHandler.getMaxRecords()

getMessageConverter

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

Specified by:
getMessageConverter in interface LALogHandler
Returns:
Message converter.
See Also:
parse(), LAMessage.extendsMessage(String)

getMessage

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

Specified by:
getMessage in interface LALogHandler
Parameters:
index - Physical index of the messageLabel in the log file.
Returns:
Message.

getMessages

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

Specified by:
getMessages in interface LALogHandler
Parameters:
start - start filtered index (included in the result).
end - end filtered index (included in the result).
Returns:
messages.
See Also:
LALogHandler.getMessages(int, int)

getPercentDone

public int getPercentDone()
Delegated method.

Specified by:
getPercentDone in interface LALogHandler
Returns:
Done percentage.
See Also:
LALogHandler.getPercentDone()

getSize

public int getSize()
Delegated method.

Specified by:
getSize in interface LALogHandler
Returns:
physical number of messages.
See Also:
LALogHandler.getSize()

isParsing

public boolean isParsing()
Delegated method.

Specified by:
isParsing in interface LALogHandler
Returns:
true if parsing; false otherwise.
See Also:
LALogHandler.isParsing()

setAnalyzers

public void setAnalyzers(LAAnalyzer[] newAnalyzers)
NOP.

Specified by:
setAnalyzers in interface LALogHandler
Parameters:
newAnalyzers - Analyzers to add.
See Also:
LALogHandler.setAnalyzers(net.logAnalyzer.analysis.LAAnalyzer[])

setMaxRecords

public void setMaxRecords(int maxRecords)
Delegated method.

Specified by:
setMaxRecords in interface LALogHandler
Parameters:
maxRecords - Number of records.
See Also:
LALogHandler.setMaxRecords(int)

parse

public void parse()
           throws ParsingException
Parses the log content of the current LALogHandler. 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();
 

Specified by:
parse in interface LALogHandler
Throws:
ParsingException - If can't parse messageLabel.
See Also:
AbstractLogHandler

run

public void run()
Delegated method.

Specified by:
run in interface java.lang.Runnable
See Also:
Runnable.run()

stopFiltering

public void stopFiltering()
Stop the filtering. A LALogHandlerListener.endParsing(LALogHandler) is received by all LALogHandlerListener.


addLogHandlerListener

public void addLogHandlerListener(LALogHandlerListener listener)
Adds a listener.

Specified by:
addLogHandlerListener in interface LALogHandler
Parameters:
listener - Lister to add.
See Also:
LALogHandler.addLogHandlerListener(LALogHandlerListener)

removeLogHandlerListener

public void removeLogHandlerListener(LALogHandlerListener listener)
Removes a listener.

Specified by:
removeLogHandlerListener in interface LALogHandler
Parameters:
listener - Lister to remove.
See Also:
LALogHandler.removeLogHandlerListener(LALogHandlerListener)

fireStartParsing

public void fireStartParsing()
Fires a start parsing event.

Specified by:
fireStartParsing in interface LALogHandler

fireStepParsing

public void fireStepParsing()
Fires a step parsing event.


fireEndParsing

public void fireEndParsing()
Fires an end parsing event.

Specified by:
fireEndParsing in interface LALogHandler


Copyright © 2006 null. All Rights Reserved.