Class FileBasedNamespaceMappings
- java.lang.Object
-
- org.apache.jackrabbit.core.query.lucene.AbstractNamespaceMappings
-
- org.apache.jackrabbit.core.query.lucene.FileBasedNamespaceMappings
-
- All Implemented Interfaces:
NamespaceMappings
,NamespaceResolver
public class FileBasedNamespaceMappings extends AbstractNamespaceMappings
The classNamespaceMappings
implements aNamespaceResolver
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
Constructors Constructor Description FileBasedNamespaceMappings(File file)
CreatesNamespaceMappings
instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getPrefix(String uri)
Returns a prefix for the namespaceuri
.String
getURI(String prefix)
Returns a namespace uri for aprefix
.-
Methods inherited from class org.apache.jackrabbit.core.query.lucene.AbstractNamespaceMappings
translateName, translatePath
-
-
-
-
Constructor Detail
-
FileBasedNamespaceMappings
public FileBasedNamespaceMappings(File file) throws IOException
CreatesNamespaceMappings
instance. Initial mappings are loaded fromfile
.- Parameters:
file
- theFile
to load initial mappings.- Throws:
IOException
- if an error occurs while reading initial namespace mappings fromfile
.
-
-
Method Detail
-
getURI
public String getURI(String prefix) throws NamespaceException
Returns a namespace uri for aprefix
.- Parameters:
prefix
- the namespace prefix.- Returns:
- the namespace uri.
- Throws:
NamespaceException
- if no namespace uri is registered forprefix
.
-
getPrefix
public String getPrefix(String uri) throws NamespaceException
Returns a prefix for the namespaceuri
. If a namespace mapping exists, the already known prefix is returned; otherwise a new prefix is created and assigned to the namespace uri.- 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.
-
-