edu.ntnu.item.jt.system
Class LogFilter

java.lang.Object
  extended by edu.ntnu.item.jt.system.LogFilter

public class LogFilter
extends Object

A representation of the output format of a given antivirus engine. Keeps record of ways to interpret, analyze and filter an AVE's scan output.

Author:
Jøran Vagnby Lillesand
See Also:
Scanner

Constructor Summary
LogFilter()
          Constructor for a log filter that returns every line of the log file.
LogFilter(String resultIdentifier)
          Constructor for a log filter that looks for a certain identifier string in each line and returns every line containing it.
LogFilter(String resultIdentifier, String resultPrefix, String resultSuffix)
          Constructor for a log filter that looks for a certain identifier string in each line and extract the information between a given prefix and suffix in that string.
 
Method Summary
 ArrayList<String> filter(File log)
          Reads a log file and extracts parts of it based on the prefixes and suffixes associated with this instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LogFilter

public LogFilter(String resultIdentifier,
                 String resultPrefix,
                 String resultSuffix)
Constructor for a log filter that looks for a certain identifier string in each line and extract the information between a given prefix and suffix in that string.

Parameters:
resultIdentifier - string that identifies a line containing a match.
resultPrefix - unique string (for the line containing the match) identifying the beginning of the result (i.e. the actual match). If the parameter is null, it will be assumed the result is at the beginning of the line.
resultSuffix - unique string (for the line containing the match) identifying the end of the result (i.e. the actual match). If the parameter is null, it will be assumed the result is at the end of the line.

LogFilter

public LogFilter(String resultIdentifier)
Constructor for a log filter that looks for a certain identifier string in each line and returns every line containing it.

Parameters:
resultIdentifier - string that identifies a line containing a match.

LogFilter

public LogFilter()
Constructor for a log filter that returns every line of the log file.

Method Detail

filter

public ArrayList<String> filter(File log)
                         throws NoMatchFoundException,
                                FileNotFoundException,
                                IOException
Reads a log file and extracts parts of it based on the prefixes and suffixes associated with this instance. If no prefix and suffix is defined, every line containing the resultIdentifier set in the constructor is returned. Uses simple String matching to identify the scan result in the log file. Supports multiple matches per log.

Parameters:
log - the log file to be filtered.
Returns:
a generic representation of the scan result.
Throws:
NoMatchFoundException - no match was found during the scan, i.e. the scanned file was reported clean.
FileNotFoundException - the input file to be parsed could not be found.
IOException - an IO exception occured while reading the file before any result was found (if the exception is thrown after a result is found, it is ignored).