public class TimestampedMessageParser extends java.lang.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 java.io.BufferedReader |
reader |
| Constructor and Description |
|---|
TimestampedMessageParser(java.io.BufferedReader reader,
XLogFilter filter)
Creates a TimestampedMessageParser with the given BufferedReader and filter.
|
| Modifier and Type | Method and Description |
|---|---|
void |
closeReader()
Closes the Reader.
|
java.lang.String |
getLastMessage()
Returns the message that was last parsed.
|
java.lang.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 LogLine |
parseNextLogLine()
Reads the next line from the Reader and checks if it matches the filter.
|
void |
processRemaining(java.io.Writer writer)
Streams log messages to the passed in Writer, with default buffer len 4K
and zero bytes already written
|
void |
processRemaining(java.io.Writer writer,
int bufferLen)
Streams log messages to the passed in Writer, with zero bytes already
written
|
void |
processRemaining(java.io.Writer writer,
int bufferLen,
int bytesWritten)
Streams log messages to the passed in Writer.
|
protected java.util.ArrayList<java.lang.String> |
splitLogMessage(java.lang.String line)
Splits the log message into parts
|
public TimestampedMessageParser(java.io.BufferedReader reader, XLogFilter filter)
reader - The BufferedReader to get the log messages fromfilter - The filterpublic boolean increment() throws java.io.IOException
java.io.IOException - If there was a problem reading from the Readerpublic java.lang.String getLastTimestamp()
public java.lang.String getLastMessage()
public void closeReader() throws java.io.IOException
java.io.IOExceptionprotected LogLine parseNextLogLine() throws java.io.IOException
java.io.IOExceptionpublic void processRemaining(java.io.Writer writer, int bufferLen, int bytesWritten) throws java.io.IOException
writer - bufferLen - maximum len of log bufferbytesWritten - num bytes already written to writerjava.io.IOExceptionpublic void processRemaining(java.io.Writer writer, int bufferLen) throws java.io.IOException
writer - bufferLen - maximum len of log bufferjava.io.IOExceptionpublic void processRemaining(java.io.Writer writer) throws java.io.IOException
writer - java.io.IOExceptionprotected java.util.ArrayList<java.lang.String> splitLogMessage(java.lang.String line)
line - Copyright © 2019 Apache Software Foundation. All Rights Reserved.