org.apache.jackrabbit.core.query.lucene
Class FileBasedNamespaceMappings

java.lang.Object
  extended by org.apache.jackrabbit.spi.commons.namespace.AbstractNamespaceResolver
      extended by org.apache.jackrabbit.core.query.lucene.FileBasedNamespaceMappings
All Implemented Interfaces:
NamespaceMappings, NamespaceResolver

public class FileBasedNamespaceMappings
extends AbstractNamespaceResolver
implements NamespaceMappings

The class NamespaceMappings implements a org.apache.jackrabbit.core.NamespaceResolver that holds a namespace mapping that is used internally in the search index. Storing paths with the full uri of a namespace would require too much space in the search index.

Whenever a yet unknown namespace uri to prefix mapping is requested, a new prefix is created on the fly and associated with the namespace. Known namespace mappings are stored in a properties file.


Constructor Summary
FileBasedNamespaceMappings(File file)
          Creates NamespaceMappings instance.
 
Method Summary
 String getPrefix(String uri)
          Returns a prefix for the namespace uri.
 String getURI(String prefix)
          Returns a namespace uri for a prefix.
 String translatePropertyName(Name qName)
          Translates a property name from a session local namespace mapping into a search index private namespace mapping.
 
Methods inherited from class org.apache.jackrabbit.spi.commons.namespace.AbstractNamespaceResolver
addListener, notifyNamespaceAdded, notifyNamespaceRemapped, notifyNamespaceRemoved, removeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileBasedNamespaceMappings

public FileBasedNamespaceMappings(File file)
                           throws IOException
Creates NamespaceMappings instance. Initial mappings are loaded from file.

Parameters:
file - the File to load initial mappings.
Throws:
IOException - if an error occurs while reading initial namespace mappings from file.
Method Detail

getURI

public String getURI(String prefix)
              throws NamespaceException
Returns a namespace uri for a prefix.

Specified by:
getURI in interface NamespaceResolver
Parameters:
prefix - the namespace prefix.
Returns:
the namespace uri.
Throws:
NamespaceException - if no namespace uri is registered for prefix.

getPrefix

public String getPrefix(String uri)
                 throws NamespaceException
Returns a prefix for the namespace uri. If a namespace mapping exists, the already known prefix is returned; otherwise a new prefix is created and assigned to the namespace uri.

Specified by:
getPrefix in interface NamespaceResolver
Parameters:
uri - the namespace uri.
Returns:
the prefix for the namespace uri.
Throws:
NamespaceException - if an yet unknown namespace uri / prefix mapping could not be stored.

translatePropertyName

public String translatePropertyName(Name qName)
                             throws IllegalNameException
Translates a property name from a session local namespace mapping into a search index private namespace mapping.

Specified by:
translatePropertyName in interface NamespaceMappings
Parameters:
qName - the property name to translate
Returns:
the translated property name
Throws:
IllegalNameException


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