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.| Constructor and Description |
|---|
KeywordMap(boolean ignoreCase)
Creates a new
KeywordMap. |
KeywordMap(boolean ignoreCase,
int mapLength)
Creates a new
KeywordMap. |
| Modifier and Type | Method and Description |
|---|---|
void |
add(char[] keyword,
byte id)
Adds a key-value mapping.
|
void |
add(KeywordMap map)
Adds the content of another keyword map to this one.
|
void |
add(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.
|
String[] |
getKeywords()
Returns an array containing all keywords in this keyword map.
|
String |
getNonAlphaNumericChars()
Returns all non-alphanumeric characters that appear in the
keywords of this keyword map.
|
protected int |
getSegmentMapKey(Segment s,
int off,
int len) |
byte |
lookup(Segment text,
int offset,
int length)
Looks up a key.
|
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 KeywordMap(boolean ignoreCase,
int mapLength)
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.public byte lookup(Segment text, int offset, int length)
text - The text segmentoffset - The offset of the substring within the text segmentlength - The length of the substringpublic void add(String keyword, byte id)
keyword - The keyid - The valuepublic void add(char[] keyword,
byte id)
keyword - The keyid - The valuepublic String getNonAlphaNumericChars()
public String[] getKeywords()
public boolean getIgnoreCase()
public void setIgnoreCase(boolean ignoreCase)
ignoreCase - True if the keyword map should be case
insensitive, false otherwisepublic void add(KeywordMap map)
protected int getSegmentMapKey(Segment s, int off, int len)
Copyright © 2017 etc.to. All rights reserved.