org.jwall.web.audit.io
Class AccessLogAuditReader

java.lang.Object
  extended by org.jwall.web.audit.io.AccessLogAuditReader
All Implemented Interfaces:
AuditEventReader

public class AccessLogAuditReader
extends java.lang.Object
implements AuditEventReader

This simple class creates small AuditEvent objects from a line of an web-server access log. The resulting events are not complete, i.e. they do not include the complete header.

Author:
Christian Bockermann <chris@jwall.org>

Constructor Summary
AccessLogAuditReader(java.io.File accessLogFile)
          This creates an instance of this class that reads from the given file accessLogFile.
 
Method Summary
 long bytesAvailable()
           
 long bytesRead()
           
 void close()
           
static AuditEvent createEvent(java.lang.String accessLine)
          This method create an audit-event from the given access-line.
 AuditEvent readNext()
          This method reads the next line from the underlying file and creates an AuditEvent-object from it.
static java.lang.String[] splitAccessLine(java.lang.String input)
          This method splits the given line into tokens.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AccessLogAuditReader

public AccessLogAuditReader(java.io.File accessLogFile)
                     throws java.io.IOException
This creates an instance of this class that reads from the given file accessLogFile.

Parameters:
accessLogFile - The file to read events from.
Throws:
java.io.IOException - In case a reader on this file cannot be created.
Method Detail

readNext

public AuditEvent readNext()
This method reads the next line from the underlying file and creates an AuditEvent-object from it.

Specified by:
readNext in interface AuditEventReader
Returns:
The next audit-event from or NULL if no event is available.
See Also:
AuditEventReader.readNext()

splitAccessLine

public static java.lang.String[] splitAccessLine(java.lang.String input)
This method splits the given line into tokens. In contrast to the java-native split, it preserves quoted strings.

Parameters:
input - The string to be split into parts.
Returns:
An array of strings that are parts of the original string.

createEvent

public static AuditEvent createEvent(java.lang.String accessLine)
                              throws java.lang.Exception
This method create an audit-event from the given access-line. The line is splitted into parts and an intermediate-data buffer is created, holding a pseudo http-header and simple audit-log sections.

Parameters:
accessLine - The line to create the event from.
Returns:
An audit-event instance.
Throws:
java.lang.Exception - In case anything goes wrong ;-)

close

public void close()
           throws java.io.IOException
Specified by:
close in interface AuditEventReader
Throws:
java.io.IOException

bytesRead

public long bytesRead()
Specified by:
bytesRead in interface AuditEventReader

bytesAvailable

public long bytesAvailable()
Specified by:
bytesAvailable in interface AuditEventReader