Package mars.venus.editor.jeditsyntax
Class KeywordMap
java.lang.Object
mars.venus.editor.jeditsyntax.KeywordMap
A
KeywordMap
is similar to a hashtable in that it maps keys
to values. However, the `keys' are Swing Segment
s. This allows lookups of
text substrings without the overhead of creating a new string object.
This class is used by MIPSTokenMarker
to map keywords to ids.
- Version:
- $Id: KeywordMap.java,v 1.16 1999/12/13 03:40:30 sp Exp $
- Author:
- Slava Pestov, Mike Dillon
-
Constructor Summary
ConstructorsConstructorDescriptionKeywordMap
(boolean ignoreCase) Creates a newKeywordMap
.KeywordMap
(boolean ignoreCase, int capacity) Creates a newKeywordMap
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a key-value mapping.boolean
Returns true if the keyword map is set to be case insensitive, false otherwise.protected int
getSegmentMapKey
(Segment segment, int offset, int length) protected int
getStringMapKey
(String string) byte
Looks up a key.void
setIgnoreCase
(boolean ignoreCase) Sets if the keyword map should be case insensitive.toString()
-
Constructor Details
-
KeywordMap
public KeywordMap(boolean ignoreCase) Creates a newKeywordMap
.- Parameters:
ignoreCase
- True if keys are case insensitive
-
KeywordMap
public KeywordMap(boolean ignoreCase, int capacity) Creates a newKeywordMap
.- Parameters:
ignoreCase
- True if the keys are case insensitivecapacity
- The number of `buckets' to create. A value of 52 will give good performance for most maps.
-
-
Method Details
-
lookup
Looks up a key.- Parameters:
text
- The text segmentoffset
- The offset of the substring within the text segmentlength
- The length of the substring- Returns:
- The token type for the keyword
-
add
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
-
getSegmentMapKey
-
toString
-