|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.jidesoft.editor.KeywordMap
public class KeywordMap
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.
Field Summary | |
---|---|
protected int |
mapLength
|
Constructor Summary | |
---|---|
KeywordMap(boolean ignoreCase)
Creates a new KeywordMap . |
|
KeywordMap(boolean ignoreCase,
int mapLength)
Creates a new KeywordMap . |
Method Summary | |
---|---|
void |
add(String keyword,
byte id)
Adds a key-value mapping. |
byte |
get(String keyword)
Get the keyword's id. |
boolean |
getIgnoreCase()
Returns true if the keyword map is set to be case insensitive, false otherwise. |
protected int |
getSegmentMapKey(Segment s,
int off,
int len)
|
protected int |
getStringMapKey(String s)
|
Set<String> |
keyWordSet()
Returns the set of keyword inside the map. |
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected int mapLength
Constructor Detail |
---|
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.Method Detail |
---|
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 substring
public void add(String keyword, byte id)
keyword
- The keyid
- The valuepublic byte get(String keyword)
keyword
- the keyword
Token.NULL
if not found.public Set<String> keyWordSet()
public boolean getIgnoreCase()
public void setIgnoreCase(boolean ignoreCase)
ignoreCase
- True if the keyword map should be case
insensitive, false otherwiseprotected int getStringMapKey(String s)
protected int getSegmentMapKey(Segment s, int off, int len)
|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |