Class KeywordMap
- java.lang.Object
-
- com.inductiveautomation.ignition.client.jedittextarea.KeywordMap
-
public class KeywordMap extends java.lang.ObjectAKeywordMapis 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
CTokenMarkerto map keywords to ids.
-
-
Field Summary
Fields Modifier and Type Field Description protected intmapLength
-
Constructor Summary
Constructors Constructor Description KeywordMap(boolean ignoreCase)Creates a newKeywordMap.KeywordMap(boolean ignoreCase, int mapLength)Creates a newKeywordMap.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(java.lang.String keyword, byte id)Adds a key-value mapping.booleangetIgnoreCase()Returns true if the keyword map is set to be case insensitive, false otherwise.protected intgetSegmentMapKey(javax.swing.text.Segment s, int off, int len)protected intgetStringMapKey(java.lang.String s)bytelookup(javax.swing.text.Segment text, int offset, int length)Looks up a key.voidsetIgnoreCase(boolean ignoreCase)Sets if the keyword map should be case insensitive.
-
-
-
Constructor Detail
-
KeywordMap
public KeywordMap(boolean ignoreCase)
Creates a newKeywordMap.- Parameters:
ignoreCase- True if keys are case insensitive
-
KeywordMap
public KeywordMap(boolean ignoreCase, int mapLength)Creates a newKeywordMap.- Parameters:
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
-
lookup
public byte lookup(javax.swing.text.Segment text, int offset, int length)Looks up a key.- Parameters:
text- The text segmentoffset- The offset of the substring within the text segmentlength- The length of the substring
-
add
public void add(java.lang.String keyword, byte id)Adds a key-value mapping.- Parameters:
keyword- The keyid- The value
-
getIgnoreCase
public boolean getIgnoreCase()
Returns true if the keyword map is set to be case insensitive, false otherwise.
-
setIgnoreCase
public void setIgnoreCase(boolean ignoreCase)
Sets if the keyword map should be case insensitive.- Parameters:
ignoreCase- True if the keyword map should be case insensitive, false otherwise
-
getStringMapKey
protected int getStringMapKey(java.lang.String s)
-
getSegmentMapKey
protected int getSegmentMapKey(javax.swing.text.Segment s, int off, int len)
-
-