Hilbert II - JAVA-Packages - Principia Mathematica II

com.meyling.principia.io
Class TextInput

java.lang.Object
  extended bycom.meyling.principia.io.TextInput

public class TextInput
extends Object

This class provides convenient methods for parsing input. TODO offer input stream constructor

Version:
$Revision: 1.9 $
Author:
Michael Meyling

Constructor Summary
TextInput(StringBuffer source, String address, String localAddress)
          Constructor using StringBuffer source.
TextInput(String source, String address, String localAddress)
          Constructor using String source.
 
Method Summary
 String getAddress()
          Get address (or something to identify it) of input source.
 char getChar()
          Reads a single character and does not change the reading position.
 char getChar(int i)
          Reads a single character and does not change the reading position.
 int getColumn()
          Returns the current column number.
 String getLine()
          Returns the current line.
 String getLocalAddress()
          Get local address (or something to identify it) of input source.
 int getMaximumPosition()
          Returns the highest position number possible.
 int getPosition()
          Returns the current position.
 int getRow()
          Returns the current line number.
 boolean isEmpty()
          Is there no data left for reading?
 char readChar()
          Reads a single character and increments the reading position by one.
 int readCounter()
          Reads the next positive integer made completly out of digits, leading whitespace is skipped.
 String readLatexEnvironment()
          Reads the next latex string containing Changes reading position.
 String readLatexWord()
          Reads the next word string containing Changes reading position.
 String readLetterDigitString()
          Reads the next string containing only letters or digits, leading whitespace is skipped.
 String readQuoted()
          Reads the next quoted string, leading whitespace is skipped.
 void setPosition(int position)
          Sets the current position (and indirectly the line number).
 String showLinePosition()
          Show reading position.
 void skipWhiteSpace()
          Skips white space, beginning from reading position.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextInput

public TextInput(StringBuffer source,
                 String address,
                 String localAddress)
Constructor using StringBuffer source.

Parameters:
source - data source
address - for identifing source
localAddress - source address
Throws:
IllegalArgumentException - if argument was an nullpointer

TextInput

public TextInput(String source,
                 String address,
                 String localAddress)
Constructor using String source.

Parameters:
source - data source
address - for identifing source
localAddress - source address
Throws:
IllegalArgumentException - if argument was an nullpointer
Method Detail

readChar

public final char readChar()
Reads a single character and increments the reading position by one.

Returns:
character read, if there are no more chars Character.MAX_VALUE is returned

getChar

public final char getChar()
Reads a single character and does not change the reading position.

Returns:
character read, if there are no more chars Character.MAX_VALUE is returned

getChar

public final char getChar(int i)
Reads a single character and does not change the reading position.

Parameters:
i - offset from current reading position.
Returns:
character read, if there are no more chars Character.MAX_VALUE is returned

skipWhiteSpace

public final void skipWhiteSpace()
Skips white space, beginning from reading position. Changes reading position to next non white space character.


isEmpty

public final boolean isEmpty()
Is there no data left for reading?

Returns:
is all data read?

readLetterDigitString

public final String readLetterDigitString()
Reads the next string containing only letters or digits, leading whitespace is skipped. Changes reading position.

Returns:
read string
Throws:
IllegalArgumentException - if no such characters could be found

readLatexEnvironment

public final String readLatexEnvironment()
Reads the next latex string containing Changes reading position.

Returns:
read string

readLatexWord

public final String readLatexWord()
Reads the next word string containing Changes reading position.

Returns:
read string

readCounter

public final int readCounter()
Reads the next positive integer made completly out of digits, leading whitespace is skipped. Changes reading position.

Returns:
read integer
Throws:
IllegalArgumentException - if no digits where found or the number was to big for an int

readQuoted

public final String readQuoted()
                        throws IllegalArgumentException
Reads the next quoted string, leading whitespace is skipped. A correctly quoted string could be created by adding a leading and a trailing quote character and doubling each other quote character. The resulting string is dequoted. Changes reading position.

Returns:
deqoted read string
Throws:
IllegalArgumentException - if no correctly quoted string was found

getRow

public final int getRow()
Returns the current line number.

Returns:
current line number (starting with line 1)

getColumn

public final int getColumn()
Returns the current column number.

Returns:
current column number (starting with line 1)

getLine

public final String getLine()
Returns the current line.

Returns:
current line

getPosition

public final int getPosition()
Returns the current position.

Returns:
current position

getMaximumPosition

public final int getMaximumPosition()
Returns the highest position number possible. This is equal to the length of the source.

Returns:
maximum position

setPosition

public final void setPosition(int position)
Sets the current position (and indirectly the line number).

Parameters:
position - set current position

getAddress

public final String getAddress()
Get address (or something to identify it) of input source.

Returns:
address of input source

getLocalAddress

public final String getLocalAddress()
Get local address (or something to identify it) of input source.

Returns:
local address of input source

showLinePosition

public final String showLinePosition()
Show reading position.

Returns:
current line with mark at current reading position

Hilbert II - JAVA-Packages - Principia Mathematica II

©left GNU General Public Licence
All Rights Reserved.