org.jwall.web.audit.io
Class ModSecurity2AuditReader

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

public class ModSecurity2AuditReader
extends java.lang.Object
implements AuditEventReader

This class implements a parser for audit-logfile for the modsecurity2. It also implements the AuditEventSource interface.

Author:
Christian Bockermann <chris@jwall.org>

Field Summary
static boolean DEBUG
           
 
Constructor Summary
ModSecurity2AuditReader(java.io.File file)
           
ModSecurity2AuditReader(java.io.File file, boolean tail)
          This constructor creates a ModSecurity2-AuditReader with a file as source.
ModSecurity2AuditReader(java.io.InputStream in, boolean tail)
          This constructor creates an audit-event-Reader that reads from the given inputstream.
 
Method Summary
 long bytesAvailable()
           
 long bytesRead()
           
 void close()
           
 double getDataRead()
          Returns the number of bytes that have been read.
 double getFileSize()
          Returns the number of bytes that are available in the file.
static int getSectionIndex(java.lang.String line)
           
 boolean hasNext()
           
 AuditEvent readNext()
          This method tries to read the next event that is available.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

public static final boolean DEBUG
Constructor Detail

ModSecurity2AuditReader

public ModSecurity2AuditReader(java.io.InputStream in,
                               boolean tail)
                        throws java.io.IOException,
                               java.lang.Exception
This constructor creates an audit-event-Reader that reads from the given inputstream.

Parameters:
in -
Throws:
java.io.IOException
java.lang.Exception

ModSecurity2AuditReader

public ModSecurity2AuditReader(java.io.File file,
                               boolean tail)
                        throws java.io.IOException,
                               java.lang.Exception
This constructor creates a ModSecurity2-AuditReader with a file as source.

Parameters:
file - The file to read from.
tail - Skip the whole file at first and read only events that are subsequently appended.
Throws:
java.io.IOException
java.lang.Exception

ModSecurity2AuditReader

public ModSecurity2AuditReader(java.io.File file)
                        throws java.io.IOException,
                               java.lang.Exception
Throws:
java.io.IOException
java.lang.Exception
Method Detail

getFileSize

public double getFileSize()
Returns the number of bytes that are available in the file. This method returns -1.0 if the reader is reading from a stream.

Returns:
The size of the file from which this reader reads.

getDataRead

public double getDataRead()
Returns the number of bytes that have been read. This can be used to display the progress of the reader-process.

Returns:
Number of bytes that have been read.

readNext

public AuditEvent readNext()
                    throws java.io.IOException,
                           ParseException
Description copied from interface: AuditEventReader
This method tries to read the next event that is available.

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

getSectionIndex

public static int getSectionIndex(java.lang.String line)

hasNext

public boolean hasNext()

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