org.apache.jackrabbit.spi.commons.namespace
Class NamespaceMapping

java.lang.Object
  extended by org.apache.jackrabbit.spi.commons.namespace.NamespaceMapping
All Implemented Interfaces:
NamespaceResolver

public class NamespaceMapping
extends 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
NamespaceMapping()
           
NamespaceMapping(NamespaceResolver base)
          Constructor
 
Method Summary
 boolean equals(Object obj)
          
 String getPrefix(String uri)
          Returns the prefix which is mapped to the given URI.
 Map<String,String> getPrefixToURIMapping()
          Return a Map of prefix to URI mappings currently registered.
 String getURI(String prefix)
          Returns the URI to which the given prefix is mapped.
 Map<String,String> getURIToPrefixMapping()
          Return a Map of URI to prefix mappings currently registered.
 boolean hasPrefix(String prefix)
          Returns true if prefix is already mapped to some URI.
 void setMapping(String prefix, String uri)
          Set a prefix == URI one-to-one mapping
 String toString()
          Override toString()
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NamespaceMapping

public NamespaceMapping()

NamespaceMapping

public NamespaceMapping(NamespaceResolver base)
Constructor

Parameters:
base - fallback resolver
Method Detail

getPrefix

public String getPrefix(String uri)
                 throws NamespaceException
Returns the prefix which is mapped to the given URI.

Specified by:
getPrefix in interface NamespaceResolver
Parameters:
uri - namespace URI
Returns:
the prefix mapped to the given URI.
Throws:
NamespaceException - if the URI is unknown.

getURI

public String getURI(String prefix)
              throws NamespaceException
Returns the URI to which the given prefix is mapped.

Specified by:
getURI in interface NamespaceResolver
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(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(String prefix,
                       String uri)
                throws NamespaceException
Set a prefix == URI one-to-one mapping

Parameters:
prefix - prefix to map
uri - uri to map
Throws:
NamespaceException - if an error occurs

getPrefixToURIMapping

public Map<String,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 Map<String,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(Object obj)

Overrides:
equals in class Object

toString

public String toString()
Override toString()

Overrides:
toString in class Object
Returns:
String


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