org.jwall.web.audit.io
Class AbstractAuditEventReader

java.lang.Object
  extended by org.jwall.web.audit.io.AbstractAuditEventReader
All Implemented Interfaces:
Iterable<AuditEvent>, AuditEventReader
Direct Known Subclasses:
AccessLogAuditReader, ConcurrentAuditReader, ModSecurity2AuditReader, ModSecurity2AuditStream, ModSecurity2AuditStream, ModSecurityAuditReader, SyslogAuditEventStream

public abstract class AbstractAuditEventReader
extends Object
implements AuditEventReader

This abstract class implements the basic methods of an AuditEventReader. Implementations of the AuditEventReader interface may inherit this class to ease implementation. The only method that needs to be implemented is the readNext() method, which parses an audit event object from the underlying file/stream.

Author:
Christian Bockermann <chris@jwall.org>

Field Summary
static String DEFAULT_AUDIT_EVENT_FACTORY_CLASS
           
 
Constructor Summary
AbstractAuditEventReader(InputStream in)
          This constructor creates a new AbstractAuditEventReader by initializing the basic reader instance to read from the given stream.
AbstractAuditEventReader(Reader in)
          This constructor creates a new AbstractAuditEventReader by initializing the basic reader instance to read from the given stream.
 
Method Summary
 boolean atEOF()
           
 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(String line)
          This method returns the index of the section, that the given line maps to.
 boolean hasNext()
          Deprecated.  
abstract  AuditEvent readNext()
          This method tries to read the next event that is available.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.lang.Iterable
iterator
 

Field Detail

DEFAULT_AUDIT_EVENT_FACTORY_CLASS

public static final String DEFAULT_AUDIT_EVENT_FACTORY_CLASS
Constructor Detail

AbstractAuditEventReader

public AbstractAuditEventReader(InputStream in)
This constructor creates a new AbstractAuditEventReader by initializing the basic reader instance to read from the given stream.


AbstractAuditEventReader

public AbstractAuditEventReader(Reader in)
This constructor creates a new AbstractAuditEventReader by initializing the basic reader instance to read from the given stream.

Method Detail

getSectionIndex

public static int getSectionIndex(String line)
This method returns the index of the section, that the given line maps to.

Parameters:
line - A section boundary line.
Returns:
The index of the section, to which this line belongs.

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 abstract AuditEvent readNext()
                             throws 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:
IOException
ParseException
See Also:
AuditEventReader.readNext()

hasNext

public boolean hasNext()
Deprecated. 

Returns:
true, if there is another event pending.

close

public void close()
           throws IOException
Specified by:
close in interface AuditEventReader
Throws:
IOException
See Also:
AuditEventReader.close()

bytesRead

public long bytesRead()
Specified by:
bytesRead in interface AuditEventReader
See Also:
AuditEventReader.bytesRead()

bytesAvailable

public long bytesAvailable()
Specified by:
bytesAvailable in interface AuditEventReader
See Also:
AuditEventReader.bytesAvailable()

atEOF

public boolean atEOF()
Specified by:
atEOF in interface AuditEventReader


Copyright © 2012 jwall.org. All Rights Reserved.