com.jamesmurty.utils
Class NamespaceContextImpl

java.lang.Object
  extended by com.jamesmurty.utils.NamespaceContextImpl
All Implemented Interfaces:
NamespaceContext

public class NamespaceContextImpl
extends Object
implements NamespaceContext

Mappings between prefix strings and namespace URI strings, as required to perform XPath queries on namespaced XML documents.

Author:
jmurty

Field Summary
protected  Element element
           
protected  Map<String,Set<String>> nsUriToPrefixesMap
           
protected  Map<String,String> prefixToNsUriMap
           
 
Constructor Summary
NamespaceContextImpl()
          Create an empty namespace context.
NamespaceContextImpl(Element element)
          Create a namespace context that will lookup namespace information in the given element.
 
Method Summary
 void addNamespace(String prefix, String namespaceURI)
          Add a custom mapping from prefix to a namespace.
 String getNamespaceURI(String prefix)
           
 String getPrefix(String namespaceURI)
           
 Iterator getPrefixes(String namespaceURI)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

element

protected Element element

prefixToNsUriMap

protected Map<String,String> prefixToNsUriMap

nsUriToPrefixesMap

protected Map<String,Set<String>> nsUriToPrefixesMap
Constructor Detail

NamespaceContextImpl

public NamespaceContextImpl()
Create an empty namespace context.


NamespaceContextImpl

public NamespaceContextImpl(Element element)
Create a namespace context that will lookup namespace information in the given element.

Method Detail

addNamespace

public void addNamespace(String prefix,
                         String namespaceURI)
Add a custom mapping from prefix to a namespace. This mapping will override any mappings present in this class's XML Element (if provided).

Parameters:
prefix - the namespace's prefix. Use an empty string for the default prefix.
namespaceURI - the namespace URI to map.

getNamespaceURI

public String getNamespaceURI(String prefix)
Specified by:
getNamespaceURI in interface NamespaceContext

getPrefix

public String getPrefix(String namespaceURI)
Specified by:
getPrefix in interface NamespaceContext

getPrefixes

public Iterator getPrefixes(String namespaceURI)
Specified by:
getPrefixes in interface NamespaceContext


Copyright © 2013. All Rights Reserved.