public class FileBasedNamespaceMappings extends AbstractNamespaceMappings
NamespaceMappings
implements a
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 and Description |
---|
FileBasedNamespaceMappings(File file)
Creates
NamespaceMappings instance. |
Modifier and Type | Method and Description |
---|---|
String |
getPrefix(String uri)
Returns a prefix for the namespace
uri . |
String |
getURI(String prefix)
Returns a namespace uri for a
prefix . |
translateName, translatePath
public FileBasedNamespaceMappings(File file) throws IOException
NamespaceMappings
instance. Initial mappings are
loaded from file
.file
- the File
to load initial mappings.IOException
- if an error occurs while reading initial namespace
mappings from file
.public String getURI(String prefix) throws javax.jcr.NamespaceException
prefix
.prefix
- the namespace prefix.javax.jcr.NamespaceException
- if no namespace uri is registered for
prefix
.public String getPrefix(String uri) throws javax.jcr.NamespaceException
uri
. If a namespace
mapping exists, the already known prefix is returned; otherwise a new
prefix is created and assigned to the namespace uri.uri
- the namespace uri.javax.jcr.NamespaceException
- if an yet unknown namespace uri / prefix
mapping could not be stored.Copyright © 2004-2020 The Apache Software Foundation. All Rights Reserved.