Package net.sf.eBus.text
Class Token
- java.lang.Object
-
- net.sf.eBus.text.Token
-
public final class Token extends Object
Contains the token's type, corresponding Java object, raw text and the input line number where the token was found. This class is immutable.- Author:
- Charles Rapp
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)Returnstrueifois a non-nullTokeninstance of the same type and raw token text;falseotherwise.inthashCode()Returns the token hashcode based on the raw token string.booleanisValue(Object value)Returnstrueifvalueequals the token value andfalseotherwise.intlineNumber()Returns the input line number where the token was found.Stringtoken()Returns the raw token string.StringtoString()Returns this token's textual representation.inttype()Returns the token type.Objectvalue()Returns the token value.
-
-
-
Constructor Detail
-
Token
public Token(int type, Object value, String token, int line)Creates a token with the given attributes.- Parameters:
type- The token type. SeeTokenLexerfor the token type list.value- The token value created from raw token string.token- The raw token string.line- The input line where the token was found.
-
-
Method Detail
-
type
public int type()
Returns the token type.- Returns:
- the token type.
-
value
public Object value()
Returns the token value.- Returns:
- the token value.
-
token
public String token()
Returns the raw token string.- Returns:
- the raw token string.
-
lineNumber
public int lineNumber()
Returns the input line number where the token was found.- Returns:
- the input line number where the token was found.
-
isValue
public boolean isValue(Object value)
Returnstrueifvalueequals the token value andfalseotherwise.- Parameters:
value- Test equality between this object and the token value.- Returns:
trueifvalueequals the token value andfalseotherwise.
-
equals
public boolean equals(Object o)
Returnstrueifois a non-nullTokeninstance of the same type and raw token text;falseotherwise.
-
hashCode
public int hashCode()
Returns the token hashcode based on the raw token string.
-
-