Class NamespaceMapping
- java.lang.Object
-
- org.apache.jackrabbit.spi.commons.namespace.NamespaceMapping
-
- All Implemented Interfaces:
NamespaceResolver
public class NamespaceMapping extends java.lang.Object implements NamespaceResolver
A Simple Namespace Mapping table. Mappings can be added and then the object can be used as a NamespaceResolver. Additionally, it can be based on a underlying NamespaceResolver
-
-
Constructor Summary
Constructors Constructor Description NamespaceMapping()
NamespaceMapping(NamespaceResolver base)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
java.lang.String
getPrefix(java.lang.String uri)
Returns the prefix which is mapped to the given URI.java.util.Map<java.lang.String,java.lang.String>
getPrefixToURIMapping()
Return a Map of prefix to URI mappings currently registered.java.lang.String
getURI(java.lang.String prefix)
Returns the URI to which the given prefix is mapped.java.util.Map<java.lang.String,java.lang.String>
getURIToPrefixMapping()
Return a Map of URI to prefix mappings currently registered.boolean
hasPrefix(java.lang.String prefix)
Returns true if prefix is already mapped to some URI.java.lang.String
removeMapping(java.lang.String uri)
Clear the mapping for an URIvoid
setMapping(java.lang.String prefix, java.lang.String uri)
Set a prefix == URI one-to-one mappingjava.lang.String
toString()
OverrideObject.toString()
-
-
-
Constructor Detail
-
NamespaceMapping
public NamespaceMapping()
-
NamespaceMapping
public NamespaceMapping(NamespaceResolver base)
Constructor- Parameters:
base
- fallback resolver
-
-
Method Detail
-
getPrefix
public java.lang.String getPrefix(java.lang.String uri) throws NamespaceException
Returns the prefix which is mapped to the given URI.- Specified by:
getPrefix
in interfaceNamespaceResolver
- Parameters:
uri
- namespace URI- Returns:
- the prefix mapped to the given URI.
- Throws:
NamespaceException
- if the URI is unknown.
-
getURI
public java.lang.String getURI(java.lang.String prefix) throws NamespaceException
Returns the URI to which the given prefix is mapped.- Specified by:
getURI
in interfaceNamespaceResolver
- Parameters:
prefix
- namespace prefix- Returns:
- the namespace URI to which the given prefix is mapped.
- Throws:
NamespaceException
- if the prefix is unknown.
-
hasPrefix
public boolean hasPrefix(java.lang.String prefix)
Returns true if prefix is already mapped to some URI. Returns false otherwise.- Parameters:
prefix
- prefix to check- Returns:
true
if prefix is mapped
-
setMapping
public void setMapping(java.lang.String prefix, java.lang.String uri) throws NamespaceException
Set a prefix == URI one-to-one mapping- Parameters:
prefix
- prefix to mapuri
- uri to map- Throws:
NamespaceException
- if an error occurs
-
removeMapping
public java.lang.String removeMapping(java.lang.String uri)
Clear the mapping for an URI- Parameters:
uri
- URI to clear the mapping for- Returns:
- The prefix the URI was mapped to or
null
if it was not mapped.
-
getPrefixToURIMapping
public java.util.Map<java.lang.String,java.lang.String> getPrefixToURIMapping()
Return a Map of prefix to URI mappings currently registered. The returned Map is a copy of the internal Map.- Returns:
- Map
-
getURIToPrefixMapping
public java.util.Map<java.lang.String,java.lang.String> getURIToPrefixMapping()
Return a Map of URI to prefix mappings currently registered. The returned Map is a copy of the internal Map.- Returns:
- Map
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()
OverrideObject.toString()
- Overrides:
toString
in classjava.lang.Object
- Returns:
- String
-
-