public class Token extends Object
Token defines a set of constant properties that indicate basic token types. If you wish to define your own identifiers for tokens, you should start at Token.CUSTOM + 1.
Classifier| Modifier and Type | Field and Description |
|---|---|
static int |
CUSTOM
CUSTOM is simply an indicator of where you should start assigning identifiers
to your own custom tokens.
|
static int |
DQUOTE
DQUOTE indicates that the token is a double quote character.
|
static int |
EMPTY
EMPTY indicates an empty or unassigned token.
|
static int |
FLOAT
FLOAT indicates that the token is an floating point number i.e.
|
static int |
IGNORED
IGNORED indicates that the token should be ignored during parsing.
|
static int |
INTEGER
INTEGER indicates that the token is an integer.
|
static int |
QUOTEDTEXT
QUOTEDTEXT indicates that the token represents a chunk of text that was enclosed
in double quotes.
|
static int |
TEXT
TEXT indicates that the token is just a piece of text as opposed to a number.
|
| Constructor and Description |
|---|
Token(String v,
int t)
Creates a new token of the specified type.
|
Token(String v,
int t,
Object u)
Creates a new token of the specified type.
|
Token(Token t)
Creates a new token that's a copy of the supplied token.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getPos()
Sets the position.
|
int |
getType()
Returns the classified type of the token.
|
Object |
getUserData()
Returns the userdata associated with the token.
|
String |
getValue()
Returns the string value of the token.
|
boolean |
isKeyWord() |
void |
setPos(int p)
Sets the position.
|
void |
setUserData(Object o)
Sets the userdata.
|
String |
toString()
Formats the token as a String.
|
public static final int EMPTY
public static final int IGNORED
public static final int TEXT
public static final int QUOTEDTEXT
public static final int INTEGER
public static final int FLOAT
public static final int DQUOTE
public static final int CUSTOM
public Token(String v, int t)
v - The string value of the token.t - The type indicator.public Token(String v, int t, Object u)
v - The string value of the token.t - The type indicator.u - The user data.public Token(Token t)
t - The existing token.public String getValue()
public int getType()
public Object getUserData()
public void setPos(int p)
public int getPos()
public void setUserData(Object o)
public String toString()
public boolean isKeyWord()
Copyright © 2023. All rights reserved.