public class TimestampedMessageParser extends Object
To use this class: Calling increment()
will tell the parser to read the next message from the
Reader. It will return true if there are more messages and false if not. Calling
getLastMessage()
and getLastTimestamp()
will return the last
message and timestamp, respectively, that were parsed when increment()
was called. Calling
processRemaining(java.io.Writer)
will write the remaining log messages to the given Writer.
Modifier and Type | Field and Description |
---|---|
int |
count |
protected BufferedReader |
reader |
Constructor and Description |
---|
TimestampedMessageParser(BufferedReader reader,
XLogFilter filter)
Creates a TimestampedMessageParser with the given BufferedReader and filter.
|
Modifier and Type | Method and Description |
---|---|
void |
closeReader()
Closes the Reader.
|
String |
getLastMessage()
Returns the message that was last parsed.
|
String |
getLastTimestamp()
Returns the timestamp from the last message that was parsed.
|
boolean |
increment()
Causes the next message and timestamp to be parsed from the BufferedReader.
|
protected String |
parseNextLine()
Reads the next line from the Reader and checks if it matches the filter.
|
void |
processRemaining(Writer writer)
Streams log messages to the passed in Writer, with default buffer len 4K
and zero bytes already written
|
void |
processRemaining(Writer writer,
int bufferLen)
Streams log messages to the passed in Writer, with zero bytes already
written
|
void |
processRemaining(Writer writer,
int bufferLen,
int bytesWritten)
Streams log messages to the passed in Writer.
|
protected BufferedReader reader
public int count
public TimestampedMessageParser(BufferedReader reader, XLogFilter filter)
reader
- The BufferedReader to get the log messages fromfilter
- The filterpublic boolean increment() throws IOException
IOException
- If there was a problem reading from the Readerpublic String getLastTimestamp()
public String getLastMessage()
public void closeReader() throws IOException
IOException
protected String parseNextLine() throws IOException
IOException
public void processRemaining(Writer writer, int bufferLen, int bytesWritten) throws IOException
writer
- bufferLen
- maximum len of log bufferbytesWritten
- num bytes already written to writerIOException
public void processRemaining(Writer writer, int bufferLen) throws IOException
writer
- bufferLen
- maximum len of log bufferIOException
public void processRemaining(Writer writer) throws IOException
writer
- IOException
Copyright © 2015 Apache Software Foundation. All Rights Reserved.