librarian
Class LeaTranslator

java.lang.Object
  |
  +--librarian.LeaTranslator

public class LeaTranslator
extends java.lang.Object


Field Summary
 java.lang.Object currentFind
           
 int currentLineType
          The type of the last line can be found here
 moves.EuMove currentMove
          The last successfully read move can be found here
static int EMPTY
          A constant indicating that an empty line has been read
static int EOF
          A constant indicating that the end of the file has been reached
static int MOVE
          A constant indicating that a move has been successfully read
static int REMARK
           
 
Constructor Summary
LeaTranslator(java.util.Hashtable keywords, int numberOfBeacons)
          Readies the translator for use by reading the keywords from a file found at a URL supplied as a string.
 
Method Summary
 int nextItem()
          Reads the next token, establishes and returns its type and wraps it into an object which is stored at @see currentFind. the type is also stored at @see currentType for internal use
 int nextLine()
          Reads the next line and tries to convert it to a @see EuMove.
 void setStream(java.io.Reader inputs)
          Initialization for reading a LEA program from a given stream of characters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

currentFind

public java.lang.Object currentFind

currentMove

public moves.EuMove currentMove
The last successfully read move can be found here


currentLineType

public int currentLineType
The type of the last line can be found here


EMPTY

public static final int EMPTY
A constant indicating that an empty line has been read

See Also:
Constant Field Values

MOVE

public static final int MOVE
A constant indicating that a move has been successfully read

See Also:
Constant Field Values

EOF

public static final int EOF
A constant indicating that the end of the file has been reached

See Also:
Constant Field Values

REMARK

public static final int REMARK
See Also:
Constant Field Values
Constructor Detail

LeaTranslator

public LeaTranslator(java.util.Hashtable keywords,
                     int numberOfBeacons)
Readies the translator for use by reading the keywords from a file found at a URL supplied as a string. The file is expected to contain one keyword per line, starting with the beacons and ending with the LEA commands. the two are separated by a line containing the word 'END_BEACON'

Method Detail

setStream

public void setStream(java.io.Reader inputs)
Initialization for reading a LEA program from a given stream of characters

Parameters:
inputs - the character stream

nextItem

public int nextItem()
             throws InternalException,
                    DesignException,
                    java.io.IOException
Reads the next token, establishes and returns its type and wraps it into an object which is stored at @see currentFind. the type is also stored at @see currentType for internal use

Returns:
one of @see OBJECT, @see COMMAND, @see BEACON, @see ARGUMENT ,@see EOL
Throws:
LibrarianException, - DesignException
InternalException
DesignException
java.io.IOException

nextLine

public int nextLine()
             throws DesignException,
                    InternalException,
                    java.io.IOException
Reads the next line and tries to convert it to a @see EuMove. Throws @DesignException if not successful, unless the line contains only whitespace and comment. In this case, null is returned.

Returns:
one of @see EMPTY, @see MOVE, @see EOF
Throws:
LibrarianException, - DesignException, InternalException
DesignException
InternalException
java.io.IOException