sjm.parse.tokens
Class TokenString
java.lang.Object
|
+--sjm.parse.tokens.TokenString
- public class TokenString
- extends java.lang.Object
A TokenString is like a String, but it is a series of
Tokens rather than a series of chars. Once a TokenString is
created, it is "immutable", meaning it cannot change. This
lets you freely copy TokenStrings without worrying about
their state.
- Version:
- 1.0
- Author:
- Steven J. Metsker
Field Summary |
protected Token[] |
tokens
the tokens in this tokenString |
Constructor Summary |
TokenString(java.lang.String s)
Constructs a tokenString from the supplied string. |
TokenString(Token[] tokens)
Constructs a tokenString from the supplied tokens. |
TokenString(Tokenizer t)
Constructs a tokenString from the supplied reader and
tokenizer. |
Method Summary |
int |
length()
Returns the number of tokens in this tokenString. |
Token |
tokenAt(int i)
Returns the token at the specified index. |
java.lang.String |
toString()
Returns a string representation of this tokenString. |
Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
tokens
protected Token[] tokens
- the tokens in this tokenString
TokenString
public TokenString(Token[] tokens)
- Constructs a tokenString from the supplied tokens.
- Parameters:
tokens
- the tokens to use
TokenString
public TokenString(java.lang.String s)
- Constructs a tokenString from the supplied string.
- Parameters:
string
- the string to tokenize
TokenString
public TokenString(Tokenizer t)
- Constructs a tokenString from the supplied reader and
tokenizer.
- Parameters:
Tokenizer
- the tokenizer that will produces the
tokens
length
public int length()
- Returns the number of tokens in this tokenString.
- Returns:
- the number of tokens in this tokenString
tokenAt
public Token tokenAt(int i)
- Returns the token at the specified index.
- Parameters:
index
- the index of the desired token- Returns:
- token the token at the specified index
toString
public java.lang.String toString()
- Returns a string representation of this tokenString.
- Overrides:
toString
in class java.lang.Object
- Returns:
- a string representation of this tokenString