| 
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectnet.logAnalyzer.handlers.AbstractLogHandler
This class defines a template for log file handlers. 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.
| Constructor Summary | |
AbstractLogHandler(FilesSetReader input,
                   java.lang.String pattern)
Constructs a log handler for the specified input files parsed with the specified converters.  | 
|
| 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()
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.  | 
 int | 
getConverterIndex(java.lang.String literal)
Returns the index of the converter identified by the specified literal.  | 
 LAConverter[] | 
getConverters()
Returns pattern converters.  | 
protected  long | 
getFileLength()
Returns the length of the parsed file.  | 
protected  long | 
getFilePointer()
Returns the current position in the parsed file.  | 
 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.  | 
protected  FilesSetReader | 
getReader()
Returns the current reader.  | 
abstract  int | 
getSize()
Returns the real number of messages in the log, not only in cache in case of a load on demand parsed log.  | 
protected  void | 
initParsing()
Makes the intialization before parsing.  | 
 boolean | 
isParsing()
Returns true if the handler is currently parsing the log.  | 
protected abstract  LAMessage | 
loadMessage(int index)
Loads the messageLabel at the specified index.  | 
 void | 
parse()
Parses the log content of the FilesSetReader returned by
 getReader().  | 
protected  LAMessage | 
parseMessage(java.lang.String message,
             LAConverter[] convertersToUse)
Parses a string messageLabel in a LAMessageusing
 LAConverter.parse(StringBuffer, LALogHandler)method. | 
protected  java.lang.String | 
readNextLine()
Reads a line form the input.  | 
protected  void | 
releaseParsing()
Makes the releases after parsing.  | 
 void | 
removeLogHandlerListener(LALogHandlerListener listener)
Removes a listener.  | 
 void | 
run()
Called by running the handler in a thread.  | 
protected abstract  void | 
saveMessage(LAMessage message,
            long pointer)
Saves the messageLabel after parsing.  | 
 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 class java.lang.Object | 
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Constructor Detail | 
public AbstractLogHandler(FilesSetReader input,
                          java.lang.String pattern)
                   throws java.io.FileNotFoundException,
                          NoConverterException
input - Log file(s) to parse.pattern - Pattern used to parse file.
NoConverterException - If no converter is specified.
java.io.FileNotFoundException - If file handled by input not found.| Method Detail | 
public final void setAnalyzers(LAAnalyzer[] newAnalyzers)
setAnalyzers in interface LALogHandlernewAnalyzers - Analyzers to add.public final LAAnalyzer[] getAnalyzers()
setAnalyzers(LAAnalyzer[]).
getAnalyzers in interface LALogHandlerpublic final LAConverter[] getConverters()
getConverters in interface LALogHandlerpublic final LAConverter getConverter(int index)
getConverter in interface LALogHandlerindex - Converter index.
public final LAConverter getConverter(java.lang.String literal)
                               throws UnknownOrLiteralConverterException
getConverter in interface LALogHandlerliteral - Converter literal.
UnknownOrLiteralConverterException - If the literal does not identify a non literal converter.getConverter(int), 
getConverterIndex(String)
public final int getConverterIndex(java.lang.String literal)
                            throws UnknownOrLiteralConverterException
getConverterIndex in interface LALogHandlerliteral - Converter literal.
UnknownOrLiteralConverterException - If the literal does not identify a non literal converter.getConverter(int)public final LAConverter getMessageConverter()
getMessageConverter in interface LALogHandlerparse(), 
LAMessage.extendsMessage(String)public final java.lang.Exception getLastException()
getLastException in interface LALogHandlerprotected final long getFileLength()
FilesSetReader.length()protected final long getFilePointer()
public final int getMaxRecords()
getMaxRecords in interface LALogHandlerpublic final void setMaxRecords(int maxRecords)
setMaxRecords in interface LALogHandlermaxRecords - Number of records.public final int getPercentDone()
getPercentDone in interface LALogHandlerpublic final LAMessage getMessage(int index)
getMessage in interface LALogHandlerindex - Physical index of the messageLabel in the log file.
public final LAMessage[] getMessages(int start,
                                     int end)
getMessage(int)to read messageLabel from the log file.
getMessages in interface LALogHandlerstart - start physicial index (included in the result).end - end physical index (included in the result).
protected final FilesSetReader getReader()
public abstract int getSize()
getSize in interface LALogHandlerpublic final boolean isParsing()
isParsing in interface LALogHandlerprotected abstract LAMessage loadMessage(int index)
index - Index of the messageLabel to load.
public final void parse()
                 throws ParsingException
FilesSetReader returned by
 getReader(). Calls, in order :
 initParsing()readNextLine()parseMessage(String, LAConverter[])saveMessage(LAMessage, long)LAAnalyzer.analyze(LAMessage, LALogHandler)on each
 LAAnalyzer;releaseParsing()
 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();
parse in interface LALogHandlerParsingException - If can't parse messageLabel.LALogHandler.parse()
protected final LAMessage parseMessage(java.lang.String message,
                                       LAConverter[] convertersToUse)
                                throws ParsingException
LAMessageusing
 LAConverter.parse(StringBuffer, LALogHandler)method.
message - Messate to parse.convertersToUse - Converters used to parse the messageLabel.
ParsingException - If can't parse messageLabel.
protected final java.lang.String readNextLine()
                                       throws java.io.IOException
LAConverter.parse(StringBuffer, LALogHandler)to read the messageLabel
 and the next lines. This is usefull when the messageLabel is written on more
 than one line (for example when the result of
 Throwable.printStackTrace()is added to the logged messageLabel}.
java.io.IOException - If an error occures.
protected abstract void saveMessage(LAMessage message,
                                    long pointer)
message - Parsed messageLabel.pointer - File pointer to the start of the messageLabel.
protected void initParsing()
                    throws java.io.IOException
LAAnalyzer.initAnalyze(LALogHandler) on each analyzer. If
 overwritten, you must call it with super.initParsing(). Calls
 fireStartParsing().
java.io.IOException - If an error occures.
protected void releaseParsing()
                       throws java.io.IOException
LAAnalyzer.releaseAnalyze(LALogHandler)on each analyzer.If
 overwritten, you must call it with super.releaseParsing().
 Calls fireEndParsing().
java.io.IOException - If an error occures.public final void run()
parse().Thread thread = new Thread(handler); thread.start();
run in interface java.lang.RunnableRunnable.run()public final void addLogHandlerListener(LALogHandlerListener listener)
addLogHandlerListener in interface LALogHandlerlistener - Lister to add.LALogHandler.addLogHandlerListener(LALogHandlerListener)public final void removeLogHandlerListener(LALogHandlerListener listener)
removeLogHandlerListener in interface LALogHandlerlistener - Lister to remove.LALogHandler.removeLogHandlerListener(LALogHandlerListener)public final void fireStartParsing()
fireStartParsing in interface LALogHandlerpublic final void fireStepParsing()
public final void fireEndParsing()
fireEndParsing in interface LALogHandler
  | 
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||