org.jwall.web.audit.io
Class AccessLogAuditReader

java.lang.Object
  extended by org.jwall.web.audit.io.AbstractAuditEventReader
      extended by org.jwall.web.audit.io.AccessLogAuditReader
All Implemented Interfaces:
Iterable<AuditEvent>, AuditEventReader

public class AccessLogAuditReader
extends AbstractAuditEventReader

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>

Field Summary
 
Fields inherited from class org.jwall.web.audit.io.AbstractAuditEventReader
DEFAULT_AUDIT_EVENT_FACTORY_CLASS
 
Constructor Summary
AccessLogAuditReader(File accessLogFile)
          This creates an instance of this class that reads from the given file accessLogFile.
AccessLogAuditReader(File accessLogFile, boolean tail)
          This creates an instance of this class that reads from the given file accessLogFile.
AccessLogAuditReader(InputStream in)
           
 
Method Summary
static AuditEvent createEvent(String accessLine)
          This method create an audit-event from the given access-line.
 Iterator<AuditEvent> iterator()
           
 AuditEvent readNext()
          This method reads the next line from the underlying file and creates an AuditEvent-object from it.
static String[] splitAccessLine(String input)
          This method splits the given line into tokens.
 
Methods inherited from class org.jwall.web.audit.io.AbstractAuditEventReader
atEOF, bytesAvailable, bytesRead, close, getDataRead, getFileSize, getSectionIndex, hasNext
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AccessLogAuditReader

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

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

AccessLogAuditReader

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

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

AccessLogAuditReader

public AccessLogAuditReader(InputStream in)
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
Specified by:
readNext in class AbstractAuditEventReader
Returns:
The next audit-event from or NULL if no event is available.
See Also:
AuditEventReader.readNext()

splitAccessLine

public static String[] splitAccessLine(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(String accessLine)
                              throws 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:
Exception - In case anything goes wrong ;-)

iterator

public Iterator<AuditEvent> iterator()


Copyright © 2012 jwall.org. All Rights Reserved.