Class Reader

java.lang.Object
  extended by structure5.AbstractIterator<Token>
      extended by Reader
All Implemented Interfaces:
Iterable<Token>, Enumeration<Token>, Iterator<Token>

public class Reader
extends AbstractIterator<Token>

A simple input stream that parses postscript files and generates a stream of Tokens. By default, the stream is constructed from a structure.ReadStream, but the Reader may also be constructed to read from a List. This allows the recursive implementation of procedures.


Constructor Summary
Reader()
          Constructs a Reader that reads from the default input stream.
Reader(List<Token> l)
          Constructs a Reader that reads tokens from a List.
Reader(Token t)
          Constructs a Reader that reads from a single Token.
 
Method Summary
 Token get()
          Not yet implemented.
 boolean hasNext()
          Check for more tokens on input stream.
static void main(String[] args)
          A sample method that reads tokens from a Reader and prints their value to the console.
 Token next()
          If hasNext() returns the next token from the input stream.
 void reset()
          If this is a list, resets the reader back to the beginning.
 
Methods inherited from class structure5.AbstractIterator
hasMoreElements, iterator, nextElement, remove, value
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Reader

public Reader()
Constructs a Reader that reads from the default input stream.


Reader

public Reader(List<Token> l)
Constructs a Reader that reads tokens from a List.

Parameters:
l - a List containing the tokens to be read.

Reader

public Reader(Token t)
Constructs a Reader that reads from a single Token. If the token is a procedure, the tokens are read from the associated list, otherwise a trivial stream is constructed that contains the single token.

Parameters:
t - the source of the token stream
Method Detail

hasNext

public boolean hasNext()
Check for more tokens on input stream.

Specified by:
hasNext in interface Iterator<Token>
Specified by:
hasNext in class AbstractIterator<Token>
Returns:
true iff there are more unprocessed tokens on stream.

get

public Token get()
Not yet implemented.

Specified by:
get in class AbstractIterator<Token>

reset

public void reset()
If this is a list, resets the reader back to the beginning. Tokens will be re-read.

Specified by:
reset in class AbstractIterator<Token>

next

public Token next()
If hasNext() returns the next token from the input stream.

Specified by:
next in interface Iterator<Token>
Specified by:
next in class AbstractIterator<Token>
Returns:
the next token read from the stream.

main

public static void main(String[] args)
A sample method that reads tokens from a Reader and prints their value to the console.