org.springframework.util.xml
Class SimpleNamespaceContext

java.lang.Object
  extended by org.springframework.util.xml.SimpleNamespaceContext
All Implemented Interfaces:
javax.xml.namespace.NamespaceContext

public class SimpleNamespaceContext
extends java.lang.Object
implements javax.xml.namespace.NamespaceContext

Simple javax.xml.namespace.NamespaceContext implementation. Follows the standard NamespaceContext contract, and is loadable via a java.util.Map or java.util.Properties object

Since:
3.0
Author:
Arjen Poutsma

Field Summary
private  java.lang.String defaultNamespaceUri
           
private  java.util.Map<java.lang.String,java.util.List<java.lang.String>> namespaceUriToPrefixes
           
private  java.util.Map<java.lang.String,java.lang.String> prefixToNamespaceUri
           
 
Constructor Summary
SimpleNamespaceContext()
           
 
Method Summary
 void bindDefaultNamespaceUri(java.lang.String namespaceUri)
          Binds the given namespace as default namespace.
 void bindNamespaceUri(java.lang.String prefix, java.lang.String namespaceUri)
          Binds the given prefix to the given namespace.
 void clear()
          Removes all declared prefixes.
 java.util.Iterator<java.lang.String> getBoundPrefixes()
          Returns all declared prefixes.
 java.lang.String getNamespaceURI(java.lang.String prefix)
           
 java.lang.String getPrefix(java.lang.String namespaceUri)
           
 java.util.Iterator getPrefixes(java.lang.String namespaceUri)
           
private  java.util.List<java.lang.String> getPrefixesInternal(java.lang.String namespaceUri)
           
 void removeBinding(java.lang.String prefix)
          Removes the given prefix from this context.
 void setBindings(java.util.Map<java.lang.String,java.lang.String> bindings)
          Sets the bindings for this namespace context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

prefixToNamespaceUri

private java.util.Map<java.lang.String,java.lang.String> prefixToNamespaceUri

namespaceUriToPrefixes

private java.util.Map<java.lang.String,java.util.List<java.lang.String>> namespaceUriToPrefixes

defaultNamespaceUri

private java.lang.String defaultNamespaceUri
Constructor Detail

SimpleNamespaceContext

public SimpleNamespaceContext()
Method Detail

getNamespaceURI

public java.lang.String getNamespaceURI(java.lang.String prefix)
Specified by:
getNamespaceURI in interface javax.xml.namespace.NamespaceContext

getPrefix

public java.lang.String getPrefix(java.lang.String namespaceUri)
Specified by:
getPrefix in interface javax.xml.namespace.NamespaceContext

getPrefixes

public java.util.Iterator getPrefixes(java.lang.String namespaceUri)
Specified by:
getPrefixes in interface javax.xml.namespace.NamespaceContext

setBindings

public void setBindings(java.util.Map<java.lang.String,java.lang.String> bindings)
Sets the bindings for this namespace context. The supplied map must consist of string key value pairs.

Parameters:
bindings - the bindings

bindDefaultNamespaceUri

public void bindDefaultNamespaceUri(java.lang.String namespaceUri)
Binds the given namespace as default namespace.

Parameters:
namespaceUri - the namespace uri

bindNamespaceUri

public void bindNamespaceUri(java.lang.String prefix,
                             java.lang.String namespaceUri)
Binds the given prefix to the given namespace.

Parameters:
prefix - the namespace prefix
namespaceUri - the namespace uri

clear

public void clear()
Removes all declared prefixes.


getBoundPrefixes

public java.util.Iterator<java.lang.String> getBoundPrefixes()
Returns all declared prefixes.

Returns:
the declared prefixes

getPrefixesInternal

private java.util.List<java.lang.String> getPrefixesInternal(java.lang.String namespaceUri)

removeBinding

public void removeBinding(java.lang.String prefix)
Removes the given prefix from this context.

Parameters:
prefix - the prefix to be removed