A 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.
CTokenMarker
to map keywords to ids.
Constructor and description |
---|
KeywordMap
(boolean ignoreCase) Creates a new KeywordMap . |
KeywordMap
(boolean ignoreCase, int mapLength) Creates a new KeywordMap . |
Type Params | Return Type | Name and description |
---|---|---|
|
void |
add(java.lang.String keyword, byte id) Adds a key-value mapping. |
|
boolean |
getIgnoreCase() Returns true if the keyword map is set to be case insensitive, false otherwise. |
|
byte |
lookup(javax.swing.text.Segment text, int offset, int length) Looks up a key. |
|
void |
setIgnoreCase(boolean ignoreCase) Sets if the keyword map should be case insensitive. |
Methods inherited from class | Name |
---|---|
class java.lang.Object |
java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Creates a new KeywordMap
.
ignoreCase
- True if keys are case insensitive Creates a new KeywordMap
.
ignoreCase
- True if the keys are case insensitivemapLength
- The number of `buckets' to create. A value of 52 will give good
performance for most maps.Adds a key-value mapping.
keyword
- The keyReturns true if the keyword map is set to be case insensitive, false otherwise.
Looks up a key.
text
- The text segmentoffset
- The offset of the substring within the text segmentlength
- The length of the substringSets if the keyword map should be case insensitive.
ignoreCase
- True if the keyword map should be case insensitive, false
otherwise