Send bugs or comments to Bernd Kühl (bernd@informatik.uni-osnabrueck.de)

lolo
Class Input

java.lang.Object
  |
  +--lolo.Input

public class Input
extends java.lang.Object

A Scanner gets the characters from an Input instance.

Author:
Bernd Kühl (bernd@informatik.uni-osnabrueck.de)
See Also:
Scanner, Scanner.scan(lolo.Input)

Field Summary
protected  char[] buffer
          The characters are buffered in this buffer.
protected  int filled
          buffer[filled] is the last character in the buffer.
protected  int mark
          if mark is greater then 0, then all characters from buffer[mark] up to buffer[next-1] are not discarded.
protected  int next
          buffer[next] is the next character.
protected  java.io.Reader reader
          The character source.
protected  int startOfSymbol
          Marks the position of the first character of a symbol.
 
Constructor Summary
Input(java.io.Reader reader, int bufferSize)
          Creates an instance.
 
Method Summary
static void main(java.lang.String[] args)
          A simple test for the Input class.
 void mark()
          Marks the position of the next character.
 int next()
          Returns the character read, as an integer in the range 0 to 65535 (0x00-0xffff), or -1 if the end of the stream has been reached
 void pushBackToMarked()
          Resets next to the marked position.
protected  void setStartSymbol()
          Marks buffer[next] as the first character of a new symbol and the mark flag is turned off.
 java.lang.String toString()
          returns "Input["+reader+"]".
 void unmark()
          Unmarks the buffer.
protected  void unsetSymbol()
          Unmarks which characters belong to a symbol.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

reader

protected final java.io.Reader reader
The character source.

buffer

protected char[] buffer
The characters are buffered in this buffer.

next

protected int next
buffer[next] is the next character.

startOfSymbol

protected int startOfSymbol
Marks the position of the first character of a symbol.

mark

protected int mark
if mark is greater then 0, then all characters from buffer[mark] up to buffer[next-1] are not discarded.

filled

protected int filled
buffer[filled] is the last character in the buffer.
Constructor Detail

Input

public Input(java.io.Reader reader,
             int bufferSize)
Creates an instance.
Parameters:
reader - the character source.
bufferSize - sets the initial buffer size.
Method Detail

setStartSymbol

protected void setStartSymbol()
Marks buffer[next] as the first character of a new symbol and the mark flag is turned off. All symbols characters will not be discarded.
See Also:
mark, unsetSymbol()

unsetSymbol

protected void unsetSymbol()
Unmarks which characters belong to a symbol. The characters can be discarde from the buffer.

next

public int next()
         throws java.io.IOException
Returns the character read, as an integer in the range 0 to 65535 (0x00-0xffff), or -1 if the end of the stream has been reached
Returns:
The character read, as an integer in the range 0 to 65535 (0x00-0xffff), or -1 if the end of the stream has been reached

mark

public void mark()
Marks the position of the next character.

unmark

public void unmark()
Unmarks the buffer.

pushBackToMarked

public void pushBackToMarked()
Resets next to the marked position.

toString

public java.lang.String toString()
returns "Input["+reader+"]".
Overrides:
toString in class java.lang.Object
Returns:
"Input["+reader+"]".

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
A simple test for the Input class.

Send bugs or comments to Bernd Kühl (bernd@informatik.uni-osnabrueck.de)