org.apache.jackrabbit.core.persistence.bundle.util
Class HashMapIndex

java.lang.Object
  extended by org.apache.jackrabbit.core.persistence.bundle.util.HashMapIndex
All Implemented Interfaces:
StringIndex

public class HashMapIndex
extends Object
implements StringIndex

Implements a StringIndex that is based on a hashmap and persists the names as property file.

Please note that this class is not synchronized and the calls need to ensure thread safeness.


Constructor Summary
HashMapIndex(FileSystemResource file)
          Creates a new hashmap index and loads the lookup tables from the filesystem resource.
 
Method Summary
 String indexToString(int i)
          Returns the string for a given index.
 int stringToIndex(String nsUri)
          Returns the index for a given string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HashMapIndex

public HashMapIndex(FileSystemResource file)
             throws FileSystemException,
                    IOException
Creates a new hashmap index and loads the lookup tables from the filesystem resource. If it does not exist yet, it will create a new one.

Parameters:
file - the filesystem resource that stores the lookup tables.
Throws:
IOException - if an I/O error occurs.
FileSystemException - if an I/O error occurs.
Method Detail

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 interface StringIndex
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 interface StringIndex
Parameters:
i - index of a string
Returns:
the indexed string


Copyright © 2004-2009 The Apache Software Foundation. All Rights Reserved.