com.inxar.syntacs.analyzer
Class StandardInput

java.lang.Object
  |
  +--com.inxar.syntacs.analyzer.StandardInput
All Implemented Interfaces:
Input

public class StandardInput
extends Object
implements Input

Concrete implementation of Input which wraps a java.io.Reader. This particular implementation slups the entire input into a char array at the upon initialization, so therefore it is fast, but it is a memory hog for large files.


Constructor Summary
StandardInput()
          Constructs a new StandardInput instance.
 
Method Summary
 int atch()
          "At char" (no argument): Returns the current absolute position of the input (the offset), as though an index into an array.
 void atch(int pos)
          "At char (with argument)": Sets the input position to the given argument.
 int atln()
          "At line": Returns the current line number.
 void bach(int length)
          "backup chars": Moves the input "back" the given number of characters.
 int broach()
          Returns the forthcoming char without advancing the buffer (like a `peek').
 void fetch(int offset, int length, char[] dst, int dstoff)
          "Fetch chars": Copies the region from offset with given length into the dst array provided starting at the given destination offset.
 int getch()
          "Get char": Gets the next char and advances the offset by one.
 void initch(Object src)
          Initialize the Input source to the given Object.
 void patch(int dstoff, char[] src, int srcoff, int len)
          "Patch": change the given region starting at the given offset.
 void reset()
           
 char retch(int offset)
          "Return char": get the the char at the given offset.
 char[] retch(int offset, int length)
          "Return chars": Gets the region from offset to length as a new character array.
 String stretch(int offset, int length)
          "Return chars as String": fetches the stretch of characters from offset to length as a new string.
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StandardInput

public StandardInput()
Constructs a new StandardInput instance.
Method Detail

initch

public void initch(Object src)
            throws IOException
Description copied from interface: Input
Initialize the Input source to the given Object.
Specified by:
initch in interface Input

reset

public void reset()

atch

public int atch()
Description copied from interface: Input
"At char" (no argument): Returns the current absolute position of the input (the offset), as though an index into an array.
Specified by:
atch in interface Input

atch

public void atch(int pos)
Description copied from interface: Input
"At char (with argument)": Sets the input position to the given argument.
Specified by:
atch in interface Input

atln

public int atln()
Description copied from interface: Input
"At line": Returns the current line number.
Specified by:
atln in interface Input

bach

public void bach(int length)
Description copied from interface: Input
"backup chars": Moves the input "back" the given number of characters. For example, if the state of the input over the sequence 'abc' is after position 2 (0,1,2; therefore directly after 'c'), ungetch(3) would move the input pointer back three characters and therefore to the beginning (just before 'a').
Specified by:
bach in interface Input

getch

public int getch()
          throws IOException,
                 EOFException
Description copied from interface: Input
"Get char": Gets the next char and advances the offset by one. If the end of input symbol has already been returned and getch() is called again, EOFException is thrown. Underlying IOExceptions that may occur are delegated to the caller.
Specified by:
getch in interface Input

broach

public int broach()
Description copied from interface: Input
Returns the forthcoming char without advancing the buffer (like a `peek'). If the end of the buffer has been reached, -1 is returned.
Specified by:
broach in interface Input

fetch

public void fetch(int offset,
                  int length,
                  char[] dst,
                  int dstoff)
Description copied from interface: Input
"Fetch chars": Copies the region from offset with given length into the dst array provided starting at the given destination offset.
Specified by:
fetch in interface Input
Following copied from interface: org.inxar.syntacs.analyzer.Input
Throws:
ArrayIndexOutOfBoundsException - if the region ifs not valid.

retch

public char[] retch(int offset,
                    int length)
Description copied from interface: Input
"Return chars": Gets the region from offset to length as a new character array. Retch stands for `return characters', but also invokes the vulgar sense of the word by `throwing up' new arrays.
Specified by:
retch in interface Input
Following copied from interface: org.inxar.syntacs.analyzer.Input
Throws:
ArrayIndexOutOfBoundsException - if the region ifs not valid.

retch

public char retch(int offset)
Description copied from interface: Input
"Return char": get the the char at the given offset.
Specified by:
retch in interface Input

stretch

public String stretch(int offset,
                      int length)
Description copied from interface: Input
"Return chars as String": fetches the stretch of characters from offset to length as a new string.
Specified by:
stretch in interface Input
Following copied from interface: org.inxar.syntacs.analyzer.Input
Throws:
ArrayIndexOutOfBoundsException - if the region ifs not valid.

toString

public String toString()
Overrides:
toString in class Object

patch

public void patch(int dstoff,
                  char[] src,
                  int srcoff,
                  int len)
Description copied from interface: Input
"Patch": change the given region starting at the given offset. This is used only in lexical error correction.
Specified by:
patch in interface Input