public class HashMapIndex extends Object implements StringIndex
StringIndex
that is based on a hashmap. Subclasses
can override the protected load()
and save()
methods
to implement persistent storage of the string index.
This class is thread-safe.
Modifier and Type | Field and Description |
---|---|
protected HashMap<Integer,String> |
indexToString
holds the index-to-string lookups.
|
protected HashMap<String,Integer> |
stringToIndex
holds the string-to-index lookups.
|
Constructor and Description |
---|
HashMapIndex() |
Modifier and Type | Method and Description |
---|---|
String |
indexToString(int i)
Returns the string for a given index.
|
protected void |
load()
Loads the lookup table.
|
protected void |
save()
Saves the lookup table.
|
int |
stringToIndex(String nsUri)
Returns the index for a given string.
|
protected final HashMap<String,Integer> stringToIndex
protected void load()
protected void save()
public int stringToIndex(String nsUri)
stringToIndex
in interface StringIndex
nsUri
- the indexed (or to be indexed) stringpublic String indexToString(int i)
indexToString
in interface StringIndex
i
- index of a stringCopyright © 2004-2020 The Apache Software Foundation. All Rights Reserved.