Class HashMapIndex
- java.lang.Object
-
- org.apache.jackrabbit.core.persistence.util.HashMapIndex
-
- All Implemented Interfaces:
StringIndex
- Direct Known Subclasses:
FileBasedIndex
public class HashMapIndex extends Object implements StringIndex
Implements aStringIndex
that is based on a hashmap. Subclasses can override the protectedload()
andsave()
methods to implement persistent storage of the string index.This class is thread-safe.
-
-
Field Summary
Fields Modifier and Type Field Description protected HashMap<Integer,String>
indexToString
holds the index-to-string lookups.protected HashMap<String,Integer>
stringToIndex
holds the string-to-index lookups.
-
Constructor Summary
Constructors Constructor Description HashMapIndex()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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.
-
-
-
Method Detail
-
load
protected void load()
Loads the lookup table.
-
save
protected void save()
Saves the lookup table.
-
stringToIndex
public int stringToIndex(String nsUri)
Returns the index for a given string. If the given string is not already indexed, the implementation can either automatically index it or throw an exception. This implementation reloads the table from the resource if a lookup fails and if the resource was modified since.- Specified by:
stringToIndex
in interfaceStringIndex
- Parameters:
nsUri
- the indexed (or to be indexed) string- Returns:
- index of the string
-
indexToString
public String indexToString(int i)
Returns the string for a given index. This implementation reloads the table from the resource if a lookup fails and if the resource was modified since.- Specified by:
indexToString
in interfaceStringIndex
- Parameters:
i
- index of a string- Returns:
- the indexed string
-
-