bb.util.logging
Class FormatterFull.Parser

java.lang.Object
  extended by bb.util.logging.FormatterFull.Parser
All Implemented Interfaces:
Closeable
Enclosing class:
FormatterFull

public static class FormatterFull.Parser
extends Object
implements Closeable

Class which parses LogRecords from data generated by format. Instances are constructed with a Reader (e.g. a FileReader) to the data, and users may then call next to read off each LogRecord in sequence.

This class is not multithread safe.


Nested Class Summary
private static class FormatterFull.Parser.LogRecordData
           
 
Field Summary
private  FormatterFull.Parser.LogRecordData data
           
private  ParseReader in
           
private  StringBuilder sb
           
 
Constructor Summary
FormatterFull.Parser(Reader reader)
          Constructor.
 
Method Summary
 void close()
          Closes all resources used by this instance.
private  void confirmEntrySeparatorNext()
           
 LogRecord next()
          This method assumes that either an entrySeparator has previously been read from in, so that data for a LogRecord is next, or that end of stream has been encountered.
private  boolean parseLineSecond()
           
private  void parseLinesRemaining()
          As per the next contract, will lump any remaining info into data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

in

private final ParseReader in

sb

private final StringBuilder sb

data

private final FormatterFull.Parser.LogRecordData data
Constructor Detail

FormatterFull.Parser

public FormatterFull.Parser(Reader reader)
                     throws IllegalArgumentException,
                            IOException,
                            IllegalStateException
Constructor.

The final action is a call to confirmEntrySeparatorNext, which ensures that the user of this instance can immediately make a call to next.

Throws:
IllegalArgumentException - if reader == null
IOException - if any I/O problem occurs
IllegalStateException - if confirmEntrySeparatorNext finds a problem
Method Detail

confirmEntrySeparatorNext

private void confirmEntrySeparatorNext()
                                throws IOException,
                                       IllegalStateException
Throws:
IOException
IllegalStateException

next

public LogRecord next()
               throws ParseException
This method assumes that either an entrySeparator has previously been read from in, so that data for a LogRecord is next, or that end of stream has been encountered. If data is available on in, it parses that data, and returns a newly constructed LogRecord instance that records the information as faithfully as possible. Else it returns null.

The LogRecord must have been written in a format exactly equivalent to that produced by the format method.

The result returned by this method may not exactly equal the original LogRecord. In particular, it cannot undo localization and parameter substitution, nor does it attempt to parse any Throwable information. Instead, that information is simply added in its raw text form to the message field of the result.

Throws:
ParseException - if any problem in parsing is encountered

parseLineSecond

private boolean parseLineSecond()
                         throws IOException,
                                ParseException,
                                NumberFormatException,
                                IllegalArgumentException
Throws:
IOException
ParseException
NumberFormatException
IllegalArgumentException

parseLinesRemaining

private void parseLinesRemaining()
                          throws IOException
As per the next contract, will lump any remaining info into data.FormatterFull.Parser.LogRecordData.message.

Throws:
IOException

close

public void close()
Closes all resources used by this instance.

Specified by:
close in interface Closeable