org.sc3d.apt.sss.v3
Class Token

java.lang.Object
  extended by org.sc3d.apt.sss.v3.Token
Direct Known Subclasses:
Bracket, SSSChar, SSSNumber, SSSString

public class Token
extends java.lang.Object

Represents a part of a Sentence that has some sort of syntactic significance. For example, Tokens are used to represent keywords, comments and numbers. Every Token has a 'type' field whose value indicates what kind of Token it is.


Field Summary
 int length
          The length of this Token in characters.
 Sentence sentence
          The Sentence of which this Token is part.
 int start
          The index into 'sentence' of the character at which this Token starts.
 int type
          The type of this Token (one of the 'TYPE_XXX' values).
static int TYPE_BRACE
          The value of the 'type' field for a Token that represents a string of Tokens inside braces (curly brackets).
static int TYPE_CHAR
          The value of the 'type' field for a Token that represents an SSS literal character.
static int TYPE_COMMENT
          The value of the 'type' field for a Token that represents an SSS comment.
static int TYPE_CONSTANT
          The value of the 'type' field for a Token that represents an SSS constant.
static int TYPE_IDENTIFIER
          The value of the 'type' field for a Token that represents an SSS identifier.
static int TYPE_NUMBER
          The value of the 'type' field for a Token that represents an SSS literal number.
static int TYPE_ROUND
          The value of the 'type' field for a Token that represents a string of Tokens inside round brackets.
static int TYPE_SQUARE
          The value of the 'type' field for a Token that represents a string of Tokens inside square brackets.
static int TYPE_STRING
          The value of the 'type' field for a Token that represents an SSS literal string.
static int TYPE_WORD
          The value of the 'type' field for a Token that represents an SSS keyword, separator character, or punctuation string.
 
Constructor Summary
Token(int type, Sentence sentence, int start, int length)
          Constructs a Token.
 
Method Summary
 void addError(java.lang.String message)
          Attaches an error message to this Token.
 boolean equals(java.lang.Object that)
          Returns 'true' only if 'that' is a non-null Token whose 'toString()' method returns a String equal to 'this.toString()'.
 int hashCode()
          Returns 'this.toString().hashCode()'.
 java.lang.String toString()
          Returns the characters that make up this Token.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

type

public final int type
The type of this Token (one of the 'TYPE_XXX' values).


sentence

public final Sentence sentence
The Sentence of which this Token is part.


start

public final int start
The index into 'sentence' of the character at which this Token starts.


length

public final int length
The length of this Token in characters.


TYPE_COMMENT

public static final int TYPE_COMMENT
The value of the 'type' field for a Token that represents an SSS comment.

See Also:
Constant Field Values

TYPE_WORD

public static final int TYPE_WORD
The value of the 'type' field for a Token that represents an SSS keyword, separator character, or punctuation string.

See Also:
Constant Field Values

TYPE_CONSTANT

public static final int TYPE_CONSTANT
The value of the 'type' field for a Token that represents an SSS constant.

See Also:
Constant Field Values

TYPE_IDENTIFIER

public static final int TYPE_IDENTIFIER
The value of the 'type' field for a Token that represents an SSS identifier.

See Also:
Constant Field Values

TYPE_STRING

public static final int TYPE_STRING
The value of the 'type' field for a Token that represents an SSS literal string.

See Also:
Constant Field Values

TYPE_NUMBER

public static final int TYPE_NUMBER
The value of the 'type' field for a Token that represents an SSS literal number.

See Also:
Constant Field Values

TYPE_CHAR

public static final int TYPE_CHAR
The value of the 'type' field for a Token that represents an SSS literal character.

See Also:
Constant Field Values

TYPE_ROUND

public static final int TYPE_ROUND
The value of the 'type' field for a Token that represents a string of Tokens inside round brackets.

See Also:
Constant Field Values

TYPE_SQUARE

public static final int TYPE_SQUARE
The value of the 'type' field for a Token that represents a string of Tokens inside square brackets.

See Also:
Constant Field Values

TYPE_BRACE

public static final int TYPE_BRACE
The value of the 'type' field for a Token that represents a string of Tokens inside braces (curly brackets).

See Also:
Constant Field Values
Constructor Detail

Token

public Token(int type,
             Sentence sentence,
             int start,
             int length)
Constructs a Token.

Parameters:
type - one of the 'TYPE_XXX' values, indicating what kind of Token this is.
Method Detail

addError

public void addError(java.lang.String message)
Attaches an error message to this Token. This method calls 'sentence.addError()'.


toString

public final java.lang.String toString()
Returns the characters that make up this Token.

Overrides:
toString in class java.lang.Object

hashCode

public int hashCode()
Returns 'this.toString().hashCode()'.

Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object that)
Returns 'true' only if 'that' is a non-null Token whose 'toString()' method returns a String equal to 'this.toString()'.

Overrides:
equals in class java.lang.Object