|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectToken
A class that implements Tokens that might be read from a stream of postscript commands. There are, basically, four types of tokens:
To read in the tokens of a postscript file, without interpretation, we might do the following:
public static voidmain(String[] args)
{ int i=0;Reader
r = newReader()
;Token
t; while (r.hasNext()
) { t = (Token)r.next()
; if (t.isSymbol()
&& // only if symbol: t.getSymbol
().equals("quit")
) break; // process token System.out.println(i+": "+t); i++; } }
Field Summary | |
static int |
BooleanKind
Token is a boolean. |
static int |
NumberKind
Token is a number. |
static int |
ProcedureKind
Token is a procedure. |
static int |
SymbolKind
Token is a symbol. |
Constructor Summary | |
Token(boolean bool)
Construct a boolean token |
|
Token(double value)
Construct a numeric token. |
|
Token(structure.List proc)
Construct a procedure. |
|
Token(java.lang.String symbol)
Construct a symbol token |
Method Summary | |
boolean |
equals(java.lang.Object other)
Returns true if this token has the same value as the other. |
boolean |
getBoolean()
Fetch boolean value of token, provided it's a boolean. |
double |
getNumber()
Fetch numeric value of token, provided it's a number. |
structure.List |
getProcedure()
Fetch the list of tokens associated with a procedure token. |
java.lang.String |
getSymbol()
Fetch string value of token, provided it's a symbol. |
boolean |
isBoolean()
Returns true if and only if this token is a boolean. |
boolean |
isNumber()
Returns true if and only if this token is a number. |
boolean |
isProcedure()
Returns true if and only if this token is a procedure. |
boolean |
isSymbol()
Returns true if and only if this token is a symbol. |
int |
kind()
Return the kind of token. |
java.lang.String |
toString()
Generates string representation of a token. |
Methods inherited from class java.lang.Object |
getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int NumberKind
public static final int BooleanKind
public static final int SymbolKind
public static final int ProcedureKind
Constructor Detail |
public Token(double value)
value
- the numeric value of the tokenpublic Token(boolean bool)
bool
- the boolean value of the tokenpublic Token(java.lang.String symbol)
symbol
- the string representing the tokenpublic Token(structure.List proc)
proc
- the list of tokens that make up the procedure.Method Detail |
public int kind()
public boolean isNumber()
public boolean isBoolean()
public boolean isSymbol()
public boolean isProcedure()
public double getNumber()
public boolean getBoolean()
public java.lang.String getSymbol()
public structure.List getProcedure()
public boolean equals(java.lang.Object other)
other
- another token
public java.lang.String toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |