org.edg.data.reptor.analysis
Class LogScannerCachedImpl

java.lang.Object
  extended byorg.edg.data.reptor.analysis.LogScannerCachedImpl
All Implemented Interfaces:
LogScanner

public class LogScannerCachedImpl
extends java.lang.Object
implements LogScanner

LogScanner cached implmentation. This loads the entire logfile line-by-line into memory and then scans each line for matches from memoryu. Consequently, it is not suitable for large logfiles.

Version:
$Id: LogScannerCachedImpl.java,v 1.1 2003/10/15 14:35:25 jamesc Exp $
Author:
Gavin McCance

Constructor Summary
LogScannerCachedImpl(java.io.File logfile)
          Create a cached impl.
 
Method Summary
 LogEvent[] match(java.lang.String regex)
          Regular expression match on the logfile.
 LogEvent[] match(java.lang.String[] regexs, java.lang.String policy)
          Regular expression match on the logfile.
 LogEvent[] matchWithTimeLimit(java.lang.String regex, LogEvent event1, long timeLimit, java.lang.String timePolicy)
          Regular expression match as in match(java.lang.String) except that you can specify another event with a time limit.
 LogEvent[] refine(LogEvent[] events, java.lang.String regex)
          Used to refine a set of LogEvents with another regular expression.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LogScannerCachedImpl

public LogScannerCachedImpl(java.io.File logfile)
Create a cached impl. The constructor will read and parse the given logfile.

Parameters:
logfile - The logfile to parse.
Method Detail

matchWithTimeLimit

public LogEvent[] matchWithTimeLimit(java.lang.String regex,
                                     LogEvent event1,
                                     long timeLimit,
                                     java.lang.String timePolicy)
Regular expression match as in match(java.lang.String) except that you can specify another event with a time limit. Any matches must be found within the time limit of the supplied event, subject to the time policy, either "BEFORE", "AFTER", or "AROUND". "BEFORE" matches an event before the given event within the specified time limit. "AFTER" matches an event afterwards. "AROUND" matches an event either side.

Specified by:
matchWithTimeLimit in interface LogScanner
Parameters:
regex - The regular expression to match.
event1 - The event around which to look (in time).
timeLimit - The time limit for the match around event1 (in milliseconds).
timePolicy - either "BEFORE", "AFTER" or "AROUND".
Returns:
the log events within the time limit+

refine

public LogEvent[] refine(LogEvent[] events,
                         java.lang.String regex)
Used to refine a set of LogEvents with another regular expression. Every LogEvent is examined in turn; if its line matches the regular expression, it will be returned. Matching is done using the Java String.matches(java.lang.String) method.

Specified by:
refine in interface LogScanner
Parameters:
events - The array of LogEvent objects to match from.
regex - The regular expression to match.
Returns:
The refined array of LogEvent objects.

match

public LogEvent[] match(java.lang.String regex)
Regular expression match on the logfile. Every line is examined in turn. Each mathcing line is returned as a LogEvent. Matching is done using the java String.matches(java.lang.String) method.

Specified by:
match in interface LogScanner
Parameters:
regex - The regular expression to match.
Returns:
An array of the matched LogEvent objects.

match

public LogEvent[] match(java.lang.String[] regexs,
                        java.lang.String policy)
Regular expression match on the logfile. Every line is examined in turn. Each mathcing line is returned as a LogEvent. Matching is done using the java String.matches(java.lang.String) method.

Specified by:
match in interface LogScanner
Parameters:
regexs - An array of regular expression to match.
policy - The policy with which to match. "AND" means all the expressions must match, "OR" means any of them must match.
Returns:
An array of the matched LogEvent objects.