mmp.engine
Class Input

java.lang.Object
  extended by mmp.engine.Input

public class Input
extends java.lang.Object

Input is responsible for the management of the input sources of mmp.

During the processing of input, the input can be altered by the inclusion of files to be processed by the macro 'include' and by macro expansions which are inserted in front of the remaining input.

Input is organized as a stack of readers for input, the 'inputStack'.
Input furthermore has a queue of readers, called the 'wrapupQueue', for parts of the input that are postponed for processing at the end of input.

Author:
Burkhardt Renz

Constructor Summary
Input(java.io.Reader source)
          Constructor, that initializes the Input with a Reader source.
 
Method Summary
 void addWrapupSource(java.io.Reader source)
          Adds the reader 'source' to the wrapupQueue, to be processed at the end of input.
 boolean matches(java.lang.String string)
          The method checks whether the input matches string.
 int peekChar()
          Lookahead of one character in the Input.
 void pushInputSource(java.io.Reader source)
          Pushes the reader 'source' on the inputStack.
 int readChar()
          Reads a single character from Input.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Input

public Input(java.io.Reader source)
Constructor, that initializes the Input with a Reader source.

Parameters:
source - where to read input.
Method Detail

addWrapupSource

public final void addWrapupSource(java.io.Reader source)
Adds the reader 'source' to the wrapupQueue, to be processed at the end of input.

Parameters:
source - reader to be queued.
Modifies:
this

matches

public final boolean matches(java.lang.String string)
                      throws java.io.IOException
The method checks whether the input matches string.
If the input matches the string it is read from input.

Parameters:
string - to be compared with the input
Returns:
true iff the string matches the beginning of the input
Throws:
java.io.IOException - if io error
Pre:
string != null
Modifies:
this

peekChar

public final int peekChar()
                   throws java.io.IOException
Lookahead of one character in the Input.

Returns:
the char found (as an integer like Reader::read()),
-1 if the end of input is reached.
Throws:
java.io.IOException - if io error
Modifies:
this; more precise:
The character is pushed back to input, but in case the read pops a reader from input stack, the input is modified.
If the complete input is exhausted, i.e. the method returns -1, the -1 is not pushed back.

pushInputSource

public final void pushInputSource(java.io.Reader source)
Pushes the reader 'source' on the inputStack.

Parameters:
source - reader to be pushed on the inputStack.
Modifies:
this

readChar

public final int readChar()
                   throws java.io.IOException
Reads a single character from Input.

Returns:
the char found (as an integer like Reader::read()),
-1 if the end of input is reached.
Throws:
java.io.IOException - if io error
Modifies:
this