Parsing Engine

danbikel.parser
Class SexpNumberedObjectReader

java.lang.Object
  extended by danbikel.parser.SexpNumberedObjectReader
All Implemented Interfaces:
ObjectReader

public class SexpNumberedObjectReader
extends Object
implements ObjectReader

Reads an underlying stream with a SexpTokenizer, converting S-expressions of the form (num processed obj), where obj is a Sexp and processed is a Symbol whose print-name is the output of String.valueOf(boolean), to NumberedObject objects.

See Also:
SexpNumberedObjectReaderFactory

Constructor Summary
SexpNumberedObjectReader(InputStream in)
          Constructs a new instance, reading numbered S-expressions from the specified input stream using the default character encoding.
SexpNumberedObjectReader(InputStream in, String encoding, int bufSize)
          Constructs a new numbered object reader from the specified filename, file encoding and buffer size, by building a SexpTokenizer from the specified arguments.
SexpNumberedObjectReader(String filename, String encoding, int bufSize)
          Constructs a new numbered object reader from the specified filename, file encoding and buffer size, by building a SexpTokenizer from the specified arguments.
 
Method Summary
 void close()
          Closes the underlying S-expression reader.
 Object readObject()
          Returns a NumberedObject instance constructed from the next numbered S-expression in the stream or file that this reader wraps.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SexpNumberedObjectReader

public SexpNumberedObjectReader(InputStream in)
Constructs a new instance, reading numbered S-expressions from the specified input stream using the default character encoding.

Parameters:
in - the input stream from which to read numbered S-expressions

SexpNumberedObjectReader

public SexpNumberedObjectReader(InputStream in,
                                String encoding,
                                int bufSize)
                         throws IOException
Constructs a new numbered object reader from the specified filename, file encoding and buffer size, by building a SexpTokenizer from the specified arguments.

Parameters:
in - the input stream from which to read numbered S-expressions
encoding - the character encoding to use when reading from the specified file
bufSize - the buffer size to use when reading from the specified file
Throws:
IOException
See Also:
SexpTokenizer.SexpTokenizer(InputStream,String,int)

SexpNumberedObjectReader

public SexpNumberedObjectReader(String filename,
                                String encoding,
                                int bufSize)
                         throws IOException
Constructs a new numbered object reader from the specified filename, file encoding and buffer size, by building a SexpTokenizer from the specified arguments.

Parameters:
filename - the filename from which to read numbered S-expressions
encoding - the character encoding to use when reading from the specified file
bufSize - the buffer size to use when reading from the specified file
Throws:
IOException
See Also:
SexpTokenizer.SexpTokenizer(String,String,int)
Method Detail

readObject

public Object readObject()
                  throws IOException
Returns a NumberedObject instance constructed from the next numbered S-expression in the stream or file that this reader wraps. A numbered S-expression is a list of the form (num processed obj), where obj is a Sexp and processed is a Symbol whose print-name is the output of String.valueOf(boolean), to NumberedObject objects.

Specified by:
readObject in interface ObjectReader
Returns:
a NumberedObject instance constructed from the next numbered S-expression in the stream or file that this reader wraps.
Throws:
IOException - if there is a problem reading from the underlying stream, or if the S-expression read is not in the proper format

close

public void close()
           throws IOException
Closes the underlying S-expression reader.

Specified by:
close in interface ObjectReader
Throws:
IOException - if there is a problem closing the underlying stream used by the underlying S-expression reader

Parsing Engine

Author: Dan Bikel.