public class KeywordMap
extends Object
KeywordMap is similar to a hashtable in that it maps keys
to values. However, the `keys' are Swing segments. This allows lookups of
text substrings without the overhead of creating a new string object.
This class is used by CTokenMarker to map keywords to ids.
| Constructor and Description |
|---|
KeywordMap(boolean ignoreCase)
Creates a new
KeywordMap. |
| Modifier and Type | Method and Description |
|---|---|
void |
add(String keyword,
byte id,
boolean paren)
Adds a key-value mapping.
|
boolean |
getIgnoreCase()
Returns true if the keyword map is set to be case insensitive,
false otherwise.
|
byte |
lookup(Segment text,
int offset,
int length,
boolean paren)
Looks up a key.
|
static boolean |
regionMatches(boolean ignoreCase,
Segment text,
int offset,
char[] match)
Checks if a subregion of a
Segment is equal to a
character array. |
void |
setIgnoreCase(boolean ignoreCase)
Sets if the keyword map should be case insensitive.
|
public KeywordMap(boolean ignoreCase)
KeywordMap.ignoreCase - True if keys are case insensitivepublic byte lookup(Segment text,
int offset,
int length,
boolean paren)
text - The text segmentoffset - The offset of the substring within the text segmentlength - The length of the substringpublic static boolean regionMatches(boolean ignoreCase,
Segment text,
int offset,
char[] match)
Segment is equal to a
character array.ignoreCase - True if case should be ignored, false otherwisetext - The segmentoffset - The offset into the segmentmatch - The character array to matchpublic void add(String keyword,
byte id,
boolean paren)
keyword - The keyid - The valuepublic boolean getIgnoreCase()
public void setIgnoreCase(boolean ignoreCase)
ignoreCase - True if the keyword map should be case
insensitive, false otherwise