Class KeywordMap
- java.lang.Object
-
- net.sf.gridarta.textedit.textarea.tokenmarker.KeywordMap
-
public class KeywordMap extends java.lang.ObjectMaps (parts of)Segmentstobytevalues. It allows lookups of text sub-strings without the overhead of creating new string objects.The keys are stored in a tree consisting of
Nodes. Each node represents one character of the key string. The root noderootNoderepresents the first character.
-
-
Constructor Summary
Constructors Constructor Description KeywordMap(boolean ignoreCase)Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(java.lang.CharSequence keyword, byte id)Adds a key-value mapping.bytelookup(javax.swing.text.Segment text, int offset, int length)Looks up a key.
-
-
-
Method Detail
-
lookup
public byte lookup(javax.swing.text.Segment text, int offset, int length)Looks up a key.- Parameters:
text- the text segment to look upoffset- the starting offset of the key within the text segmentlength- the length of the key- Returns:
- the id registered for the key, or
Token.NULLif no key matches
-
add
public void add(java.lang.CharSequence keyword, byte id)Adds a key-value mapping.- Parameters:
keyword- the key to addid- the value to map to
-
-