|
|||||||||
| Home >> All >> org >> pqt >> autorib >> [ tokenizer overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.pqt.autorib.tokenizer
Class Token

java.lang.Objectorg.pqt.autorib.tokenizer.Token
- All Implemented Interfaces:
- java.lang.Cloneable
- public class Token
- extends java.lang.Object
- implements java.lang.Cloneable
- extends java.lang.Object
this class is used to store, at the most basic level, items read from a RIB or instructions file. It can hold a request (a RIB request call word or an instruction word), a string, a floating point number, an array (a list of strings or floating point numbers stored separated by spaces and enclosed in square brackets), and opening and closing curly braces (used for instruction blocks). It is used by Tokenizer and its subclasses
- Version:
- $Header: /home/CVSRepository/autoribnew/org/pqt/autorib/tokenizer/Token.java,v 1.5 2003/12/02 17:10:52 remote Exp $
| Field Summary | |
static int |
ARRAY
Constant indicating an Array value, a single dimension array of either numbers or strings enclosed in [ ]. |
java.util.Vector |
arrayVal
if the data is an array it is stored in this vector, which is made up of Float or String objects |
static int |
CLOSEBRACE
Constant to indicate a } has been read |
static int |
column
the current column in the printing |
static int |
EOF
Constant to indicate an End of File has been read |
static int |
FLOAT
Constant to show this Token contains a Float value |
java.lang.Float |
floatVal
if the data is a float it will be here |
static int |
OPENBRACE
Constant used to indicate a { has been read |
static int |
REQUEST
Constant used to indicate that a RIB (or instructions file) request is held in this Token |
int |
requestID
if the data is a request this can contain an integer token for the request, one of those defined in RIBGlobals or InstrGlobals |
java.lang.String |
requestVal
if the data is a request then this will contain the request name |
static int |
STRING
Constant used to show this Token contains a string value |
java.lang.String |
stringVal
if the data is string this will contain it (minus the enclosing quotes) |
int |
tokenType
this is set to the integer constant for the type of data held, e.g REQUEST, or STRING |
| Constructor Summary | |
Token()
Default constuctor |
|
Token(float floatValue)
create a new float token |
|
Token(org.pqt.autorib.util.Point point)
create a new Token from a Point |
|
Token(java.lang.String stringValue)
create a new string valued token |
|
Token(java.util.Vector array)
create a new array valued token |
|
| Method Summary | |
java.lang.Object |
clone()
This method may be called to create a new copy of the Object. |
float[][] |
getAsArrayofFloatArrays(int dimension)
Convert this token into an array of (float) arrays |
java.lang.Float |
getAsFloat()
If the token is a single value float array e.g. |
float[] |
getAsFloatArray()
Convert an array token into an array of floats |
int[] |
getAsIntArray()
Convert an array token into an array of ints |
org.pqt.autorib.util.Point[] |
getAsPoints()
return an array of Point from this array token |
org.pqt.autorib.util.Point4D[] |
getAsPoints4D()
return an array of Point4D from this array token |
java.lang.String |
getAsString()
If this Token holds a single value string array e.g [ "hello" ], return it, else return null |
java.lang.String[] |
getAsStringArray()
Convert an array token into an array of Strings |
void |
write(java.io.Writer out)
Write this token to the output stream, with a trailing space. |
static void |
write(java.io.Writer out,
java.lang.String string)
Write a string to the output stream, with simple formatting to check lines within certain width |
static void |
writeln(java.io.Writer out)
Write out a newline to the given stream, keeping track of formatting |
static void |
writeln(java.io.Writer out,
java.lang.String string)
Write out a string with a newline at the end |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
column
public static int column
- the current column in the printing
REQUEST
public static final int REQUEST
- Constant used to indicate that a RIB (or instructions file)
request is held in this Token
- See Also:
- Constant Field Values
STRING
public static final int STRING
- Constant used to show this Token contains a string value
- See Also:
- Constant Field Values
FLOAT
public static final int FLOAT
- Constant to show this Token contains a Float value
- See Also:
- Constant Field Values
ARRAY
public static final int ARRAY
- Constant indicating an Array value, a single dimension
array of either numbers or strings enclosed in [ ]. Note
that in RIB quite often single value arguments are
enclosed in [] - these too are treated as arrays, at least
as far as token is concerned
- See Also:
- Constant Field Values
EOF
public static final int EOF
- Constant to indicate an End of File has been read
- See Also:
- Constant Field Values
OPENBRACE
public static final int OPENBRACE
- Constant used to indicate a { has been read
- See Also:
- Constant Field Values
CLOSEBRACE
public static final int CLOSEBRACE
- Constant to indicate a } has been read
- See Also:
- Constant Field Values
tokenType
public int tokenType
- this is set to the integer constant for the type of data held, e.g
REQUEST, or STRING
requestVal
public java.lang.String requestVal
- if the data is a request then this will contain the request name
requestID
public int requestID
- if the data is a request this can contain an integer token for the
request, one of those defined in RIBGlobals or InstrGlobals
stringVal
public java.lang.String stringVal
- if the data is string this will contain it (minus the enclosing quotes)
floatVal
public java.lang.Float floatVal
- if the data is a float it will be here
arrayVal
public java.util.Vector arrayVal
- if the data is an array it is stored in this vector, which is made up of
Float or String objects
| Constructor Detail |
Token
public Token()
- Default constuctor
Token
public Token(float floatValue)
- create a new float token
Token
public Token(java.lang.String stringValue)
- create a new string valued token
Token
public Token(java.util.Vector array)
- create a new array valued token
Token
public Token(org.pqt.autorib.util.Point point)
- create a new Token from a Point
| Method Detail |
write
public void write(java.io.Writer out) throws java.io.IOException
- Write this token to the output stream, with a trailing space.
clone
public java.lang.Object clone()
- Description copied from class:
java.lang.Object - This method may be called to create a new copy of the
Object. The typical behavior is as follows:
o == o.clone()is falseo.getClass() == o.clone().getClass()is trueo.equals(o)is true
However, these are not strict requirements, and may be violated if necessary. Of the three requirements, the last is the most commonly violated, particularly if the subclass does not override Object.equals(Object)>
Object.equals(Object)55 .If the Object you call clone() on does not implement java.lang.Cloneable (which is a placeholder interface), then a CloneNotSupportedException is thrown. Notice that Object does not implement Cloneable; this method exists as a convenience for subclasses that do.
Object's implementation of clone allocates space for the new Object using the correct class, without calling any constructors, and then fills in all of the new field values with the old field values. Thus, it is a shallow copy. However, subclasses are permitted to make a deep copy.
All array types implement Cloneable, and override this method as follows (it should never fail):
public Object clone() { try { super.clone(); } catch (CloneNotSupportedException e) { throw new InternalError(e.getMessage()); } }
getAsFloat
public java.lang.Float getAsFloat()
- If the token is a single value float array e.g. [ 4.5 ], or a float return this
value as a float, otherwise return null
getAsString
public java.lang.String getAsString()
- If this Token holds a single value string array
e.g [ "hello" ], return it, else return null
getAsPoints
public org.pqt.autorib.util.Point[] getAsPoints()
- return an array of Point from this array token
getAsPoints4D
public org.pqt.autorib.util.Point4D[] getAsPoints4D()
- return an array of Point4D from this array token
write
public static final void write(java.io.Writer out, java.lang.String string) throws java.io.IOException
- Write a string to the output stream, with
simple formatting to check lines within certain
width
writeln
public static final void writeln(java.io.Writer out) throws java.io.IOException
- Write out a newline to the given stream, keeping track
of formatting
writeln
public static final void writeln(java.io.Writer out, java.lang.String string) throws java.io.IOException
- Write out a string with a newline at the end
getAsFloatArray
public float[] getAsFloatArray()
- Convert an array token into an array of floats
getAsIntArray
public int[] getAsIntArray()
- Convert an array token into an array of ints
getAsStringArray
public java.lang.String[] getAsStringArray()
- Convert an array token into an array of Strings
getAsArrayofFloatArrays
public float[][] getAsArrayofFloatArrays(int dimension)
- Convert this token into an array of (float) arrays
|
|||||||||
| Home >> All >> org >> pqt >> autorib >> [ tokenizer overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
org.pqt.autorib.tokenizer.Token