ioutil
Class LineScanner

java.lang.Object
  |
  +--ioutil.LineScanner

public class LineScanner
extends java.lang.Object

An object of class LineScanner scans text, breaking it up into tokens.


Field Summary
static int ECHO
           
static int NO_ECHO
           
 
Constructor Summary
LineScanner(java.lang.String str, int echoPol)
          new LineScanner(str, echoPol) returns a new LineScanner for scanning str.
LineScanner(java.lang.String str, int echoPol, int skip)
          new LineScanner(str, echoPol, skip) returns a new LineScanner for scanning str.
 
Method Summary
 void addError(java.lang.String msg)
          ls.addError(msg) adds msg to the error list for ls.
 void advance()
          ls.advance() advances the current position in ls.
 boolean atChar()
          ls.atChar() returns true if the token at the current position of ls is a character.
 boolean atEnd()
          ls.atEnd() returns true if the current position of ls is at the end of the line.
 boolean atFloat()
          ls.atFloat() returns true if the token at the current position of ls is a float.
 boolean atInt()
          ls.atInt() returns true if the token at the current position of ls is an int.
 boolean atString()
          ls.atString() returns true if the token at the current position of ls is a string.
 char currentChar()
          ls.currentChar() returns the string value of the current token of ls.
 float currentFloat()
          ls.currentFloat() returns the float value of the current token of ls.
 int currentInt()
          ls.currentInt() returns the int value of the current token of ls.
 java.lang.String currentString()
          ls.currentString() returns the string value of the current token of ls.
 int errorCount()
          ls.errorCount() returns the number of error messages in ls.
 int getEchoPolicy()
          ls.getEchoPolicy(echoPol) returns the echo policy of ls.
 java.lang.String getText()
          ls.getText(echoPol) returns the text of ls.
 void printAllErrors()
          ls.printAllErrors() prints all of the error messages in ls to System.out.
 void printFirstError()
          ls.printFirstError() prints the first error message in ls to System.out, if there is one.
 char readChar()
          ls.readChar() returns the character value of the current token of ls, then advances the current position.
 void readEnd()
          ls.readEnd() records an error message in ls if the current position of ls is not at the end of the line.
 float readFloat()
          ls.readFloat() returns the float value of the current token of ls, then advances the current position.
 int readInt()
          ls.readInt() returns the int value of the current token of ls, then advances the current position.
 java.lang.String readString()
          ls.readString() returns the string value of the current token of ls, then advances the current position.
 void removeLastError()
          ls.removeLastError() removes the last error message from ls.
 void setEchoPolicy(int echoPol)
          ls.setEchoPolicy(echoPol) changes the echo policy of ls to echoPol.
 void setText(java.lang.String str)
          ls.setText(str) resets ls in preparation for scanning str.
 void setText(java.lang.String str, int skip)
          ls.setText(str, skip) resets ls in preparation for scanning str.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_ECHO

public static final int NO_ECHO

ECHO

public static final int ECHO
Constructor Detail

LineScanner

public LineScanner(java.lang.String str,
                   int echoPol,
                   int skip)
new LineScanner(str, echoPol, skip) returns a new LineScanner for scanning str. The new LineScanner uses echoPol to determine echo policy for error messages. This parameter should have one of the values LineScanner.ECHO or LineScanner.NO_ECHO. The parameter skip specifies the number of characters to skip in str before scanning.

LineScanner

public LineScanner(java.lang.String str,
                   int echoPol)
new LineScanner(str, echoPol) returns a new LineScanner for scanning str. The new LineScanner uses echoPol to determine echo policy for error messages. This parameter should have one of the values LineScanner.ECHO or LineScanner.NO_ECHO.
Method Detail

setText

public void setText(java.lang.String str,
                    int skip)
ls.setText(str, skip) resets ls in preparation for scanning str. The echo policy of ls is not changed. The parameter skip specifies the number of characters to skip in str befor scanning.

setText

public void setText(java.lang.String str)
ls.setText(str) resets ls in preparation for scanning str. The echo policy of ls is not changed.

setEchoPolicy

public void setEchoPolicy(int echoPol)
ls.setEchoPolicy(echoPol) changes the echo policy of ls to echoPol. This parameter should have one of the values LineScanner.ECHO or LineScanner.NO_ECHO.

getText

public java.lang.String getText()
ls.getText(echoPol) returns the text of ls.

getEchoPolicy

public int getEchoPolicy()
ls.getEchoPolicy(echoPol) returns the echo policy of ls.

readString

public java.lang.String readString()
ls.readString() returns the string value of the current token of ls, then advances the current position. If an error occurs, a message is recorded in ls. Error messages: Unterminated quote. String expected.

readChar

public char readChar()
ls.readChar() returns the character value of the current token of ls, then advances the current position. If an error occurs, a message is recorded in ls. Error messages: Unterminated quote. Character expected.

readFloat

public float readFloat()
ls.readFloat() returns the float value of the current token of ls, then advances the current position. If an error occurs, a message is recorded in ls. Error messages: Real number expected.

readInt

public int readInt()
ls.readInt() returns the int value of the current token of ls, then advances the current position. If an error occurs, a message is recorded in ls. Error messages: Integer expected.

readEnd

public void readEnd()
ls.readEnd() records an error message in ls if the current position of ls is not at the end of the line. Error messages: No more arguments expected.

atString

public boolean atString()
ls.atString() returns true if the token at the current position of ls is a string.

atChar

public boolean atChar()
ls.atChar() returns true if the token at the current position of ls is a character.

atFloat

public boolean atFloat()
ls.atFloat() returns true if the token at the current position of ls is a float.

atInt

public boolean atInt()
ls.atInt() returns true if the token at the current position of ls is an int.

atEnd

public boolean atEnd()
ls.atEnd() returns true if the current position of ls is at the end of the line.

currentString

public java.lang.String currentString()
ls.currentString() returns the string value of the current token of ls. If an error occurs, a message is recorded in ls. Preconditions: ls.atString() is true.

currentChar

public char currentChar()
ls.currentChar() returns the string value of the current token of ls. If an error occurs, a message is recorded in ls. Preconditions: ls.atChar() is true.

currentFloat

public float currentFloat()
ls.currentFloat() returns the float value of the current token of ls. If an error occurs, a message is recorded in ls. Preconditions: ls.atFloat() is true.

currentInt

public int currentInt()
ls.currentInt() returns the int value of the current token of ls. If an error occurs, a message is recorded in ls. Preconditions: ls.atInt() is true.

advance

public void advance()
ls.advance() advances the current position in ls. Preconditions: ls.atEnd() is false.

errorCount

public int errorCount()
ls.errorCount() returns the number of error messages in ls.

addError

public void addError(java.lang.String msg)
ls.addError(msg) adds msg to the error list for ls. The position for this error is the current position of ls.

removeLastError

public void removeLastError()
ls.removeLastError() removes the last error message from ls. Preconditions: ls.errorCount() > 0.

printFirstError

public void printFirstError()
ls.printFirstError() prints the first error message in ls to System.out, if there is one.

printAllErrors

public void printAllErrors()
ls.printAllErrors() prints all of the error messages in ls to System.out.