org.inria.ns.reflex.xml
Class NamespaceContext.Impl

java.lang.Object
  extended by org.inria.ns.reflex.xml.NamespaceContext.Impl
All Implemented Interfaces:
NamespaceContext, NamespaceContext.Mutable
Enclosing interface:
NamespaceContext

public static class NamespaceContext.Impl
extends Object
implements NamespaceContext, NamespaceContext.Mutable

A mutable default implementation of a NamespaceContext.

Author:
Philippe Poulard

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.inria.ns.reflex.xml.NamespaceContext
NamespaceContext.Elem, NamespaceContext.Impl, NamespaceContext.Mutable
 
Field Summary
 
Fields inherited from interface org.inria.ns.reflex.xml.NamespaceContext
VOID_NAMESPACE_CONTEXT
 
Constructor Summary
NamespaceContext.Impl()
          Create an empty namespace context.
NamespaceContext.Impl(Map namespaceURIs)
          Create a new namespace context backed by the given map.
NamespaceContext.Impl(NamespaceContext.Impl namespaceContext)
          Create a new namespace context that has the same entries than an other namespace context.
 
Method Summary
 void addElementNamespaces(Element element)
          Add the namespace bindings known by the given element or its ancestor.
 void addNamespace(String prefix, String namespaceURI)
          Add a single binding to this context.
 Map getMappings()
          Return a map of { prefix, namespace URI }.
 String getNamespaceURI(String prefix)
          Retrieve the namespace URI bound to the given prefix.
 Iterator getPrefixes(String namespaceURI)
          Retrieve an iterator on the prefixes bound to the given namespace URI.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NamespaceContext.Impl

public NamespaceContext.Impl()
Create an empty namespace context.


NamespaceContext.Impl

public NamespaceContext.Impl(NamespaceContext.Impl namespaceContext)
Create a new namespace context that has the same entries than an other namespace context.

Changes made on this namespace context are not reflected on the given namespace context, and vice versa.

Parameters:
namespaceContext - The model to copy.

NamespaceContext.Impl

public NamespaceContext.Impl(Map namespaceURIs)
Create a new namespace context backed by the given map.

Changes made in this namespace context are reflected in the given map.

Parameters:
namespaceURIs - A map of { prefix, namespace URI }.
Method Detail

getMappings

public Map getMappings()
Return a map of { prefix, namespace URI }.

Returns:
A map of { prefix, namespace URI }.

getNamespaceURI

public String getNamespaceURI(String prefix)
Retrieve the namespace URI bound to the given prefix.

Specified by:
getNamespaceURI in interface NamespaceContext
Parameters:
prefix - The prefix for which the namespace URI is needed.
Returns:
The namespace URI bound to the given prefix, that is "" if the prefix is unknown.

getPrefixes

public Iterator getPrefixes(String namespaceURI)
Retrieve an iterator on the prefixes bound to the given namespace URI.

Specified by:
getPrefixes in interface NamespaceContext
Parameters:
namespaceURI - The namespace URI to look for.
Returns:
A non-null iterator on the prefixes bound to the given namespace URI.
See Also:
NamespaceContext.getPrefixes(java.lang.String)

addElementNamespaces

public void addElementNamespaces(Element element)
Add the namespace bindings known by the given element or its ancestor.

Parameters:
element - The element that might define namespace bindings.

addNamespace

public void addNamespace(String prefix,
                         String namespaceURI)
Add a single binding to this context.

Specified by:
addNamespace in interface NamespaceContext.Mutable
Parameters:
prefix - The prefix.
namespaceURI - The namespace URI.