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. This implementation reloads the table from the resource if a lookup fails and if the resource was modified since.
 int stringToIndex(String nsUri)
          Returns the index for a given string. This implementation reloads the table from the resource if a lookup fails and if the resource was modified since.
 
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 string does not exist in the underlying index map a new index needs to be created. 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 string to return the index for
Returns:
the index of that string.

indexToString

public String indexToString(int i)
Returns the string for a given index. if the index does not exist in the underlying index map, null is returned. 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 - the index tp returns the string for.
Returns:
the string or null


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