public class Keyword
extends java.lang.Object
KeywordDictionary
. This class provides sufficient data about
the keyword to implement reserved/unreserved keywords and matching on a
set of valid keyword abbreviations.
The interface is designed to provide data access and the class does not implement any real function other than the storage and retrieval of the associated data members.
Modifier and Type | Field and Description |
---|---|
private java.lang.Object |
extra
Arbitrary user-specified data to be associated with this keyword.
|
private java.lang.String |
fullText
Full, literal text form of the keyword.
|
private int |
minChars
Minimum number of characters needed to match the keyword.
|
private boolean |
reserved
The keyword is a reserved keyword in the source language.
|
private int |
tokenType
The integer token type associated with this keyword in the Parser
and Lexer.
|
Constructor and Description |
---|
Keyword(java.lang.String text,
int min,
int type,
boolean reserved)
Constructs a keyword with the minimum number of valid fields.
|
Keyword(java.lang.String text,
int min,
int type,
boolean reserved,
java.lang.Object extra)
Constructs a keyword with all possible fields.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
getExtra()
Returns the user-defined object associated with this keyword.
|
java.lang.String |
getFullText()
Returns the full text of the keyword.
|
int |
getMinChars()
Returns the minimum number of characters used in abbreviations.
|
int |
getTokenType()
Returns the token type associated with this keyword by the Lexer and
Parser.
|
boolean |
isReserved()
Returns the reserved keyword status of this keyword.
|
void |
setExtra(java.lang.Object extra)
Sets the user-defined object associated with this keyword.
|
void |
setFullText(java.lang.String text)
Sets the full text of the keyword.
|
void |
setMinChars(int min)
Sets the minimum number of characters used in abbreviations.
|
void |
setReserved(boolean reserved)
Sets the reserved keyword status of this keyword.
|
void |
setTokenType(int type)
Sets the token type associated with this keyword by the Lexer and
Parser.
|
java.lang.String |
toString()
Converts a
Keyword object into a String
representation. |
private java.lang.String fullText
private int minChars
private int tokenType
private boolean reserved
private java.lang.Object extra
public Keyword(java.lang.String text, int min, int type, boolean reserved)
text
- Full text form of the keyword.min
- Minimum number of leftmost characters which will still match
the full text. Set to 0 to disable abbreviation support.type
- Constant representing the Lexer or Parser token type
associated with this keyword.reserved
- If true, this keyword is a reserved keyword and may not be
used in user-defined symbols. If false, this is an
unreserved keyword.public Keyword(java.lang.String text, int min, int type, boolean reserved, java.lang.Object extra)
text
- Full text form of the keyword.min
- Minimum number of leftmost characters which will still match
the full text. Set to 0 to disable abbreviation support.type
- Constant representing the Lexer or Parser token type
associated with this keyword.reserved
- If true, this keyword is a reserved keyword and may not be
used in user-defined symbols. If false, this is an
unreserved keyword.extra
- User-defined object that is associated with this keyword. This
object is stored but not altered in any way.public java.lang.String toString()
Keyword
object into a String
representation.toString
in class java.lang.Object
Object.toString()
public java.lang.String getFullText()
public void setFullText(java.lang.String text)
text
- The text to seet as the keyword's full text.public int getMinChars()
public void setMinChars(int min)
min
- Minimum number of left-most characters that still is a match.public int getTokenType()
public void setTokenType(int type)
type
- The token type.public boolean isReserved()
public void setReserved(boolean reserved)
reserved
- The keyword's reserved status.public java.lang.Object getExtra()
public void setExtra(java.lang.Object extra)
extra
- User-defined object.