Class SimpleNamespaceContext

  • All Implemented Interfaces:
    NamespaceContext

    public class SimpleNamespaceContext
    extends java.lang.Object
    implements NamespaceContext
    Implementation of NamespaceContext that's backed by a map.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static SimpleNamespaceContext EMPTY_CONTEXT
      An empty context containing no prefixes at all.
      private java.util.Map<java.lang.String,​java.lang.String> prefixMap  
    • Constructor Summary

      Constructors 
      Constructor Description
      SimpleNamespaceContext​(java.util.Map prefixMap)
      Creates a NamespaceContext backed by the given map.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getNamespaceURI​(java.lang.String prefix)
      Obtain the URI for a given prefix.
      java.util.Iterator<java.lang.String> getPrefixes()
      Get all prefixes of this context.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • prefixMap

        private final java.util.Map<java.lang.String,​java.lang.String> prefixMap
      • EMPTY_CONTEXT

        public static final SimpleNamespaceContext EMPTY_CONTEXT
        An empty context containing no prefixes at all.
    • Constructor Detail

      • SimpleNamespaceContext

        public SimpleNamespaceContext​(java.util.Map prefixMap)
        Creates a NamespaceContext backed by the given map.

        Copies the map, changes made to the given map after calling the constructor are not reflected into the NamespaceContext.

        Parameters:
        prefixMap - maps prefix to Namespace URI
    • Method Detail

      • getNamespaceURI

        public java.lang.String getNamespaceURI​(java.lang.String prefix)
        Description copied from interface: NamespaceContext
        Obtain the URI for a given prefix.

        Unlike the method in javax.xml.namespace.NamespaceContext doesn't have to implement any special handling for predefined prefix values.

        Specified by:
        getNamespaceURI in interface NamespaceContext
        Returns:
        null if the prefix is unknown.
      • getPrefixes

        public java.util.Iterator<java.lang.String> getPrefixes()
        Description copied from interface: NamespaceContext
        Get all prefixes of this context.
        Specified by:
        getPrefixes in interface NamespaceContext