| 
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.ObjectToken
public class Token
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;Readerr = newReader();Tokent; while (r.hasNext()) { t =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(List<Token> proc)
Construct a procedure.  | 
|
Token(String symbol)
Construct a symbol token  | 
|
| Method Summary | |
|---|---|
 boolean | 
equals(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.  | 
 List<Token> | 
getProcedure()
Fetch the list of tokens associated with a procedure token.  | 
 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.  | 
 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(String symbol)
symbol - the string representing the tokenpublic Token(List<Token> 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 String getSymbol()
public List<Token> getProcedure()
public boolean equals(Object other)
equals in class Objectother - another token
public String toString()
toString in class Object
  | 
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||