java.lang.Object
alice.util.jedit.KeywordMap
- public class KeywordMap
- extends java.lang.Object
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.
This class is used by CTokenMarker
to map keywords to ids.
- Version:
- $Id: KeywordMap.java,v 1.16 1999/12/13 03:40:30 sp Exp $
Constructor Summary |
KeywordMap(boolean ignoreCase)
Creates a new KeywordMap . |
KeywordMap(boolean ignoreCase,
int mapLength)
Creates a new KeywordMap . |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
mapLength
protected int mapLength
map
private KeywordMap.Keyword[] map
ignoreCase
private boolean ignoreCase
KeywordMap
public KeywordMap(boolean ignoreCase)
- Creates a new
KeywordMap
.
KeywordMap
public KeywordMap(boolean ignoreCase,
int mapLength)
- Creates a new
KeywordMap
.
lookup
public byte lookup(javax.swing.text.Segment text,
int offset,
int length)
- Looks up a key.
add
public void add(java.lang.String keyword,
byte id)
- Adds a key-value mapping.
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.
getStringMapKey
protected int getStringMapKey(java.lang.String s)
getSegmentMapKey
protected int getSegmentMapKey(javax.swing.text.Segment s,
int off,
int len)