Class NamespaceBinding

  • All Implemented Interfaces:
    java.lang.Iterable<NamespaceBinding>, NamespaceBindingSet

    public final class NamespaceBinding
    extends java.lang.Object
    implements NamespaceBindingSet
    Represents the binding of a prefix to a URI. Also, in some contexts, represents an unbinding, by virtue of the URI being set to a zero length string.
    Since:
    9.4
    • Constructor Summary

      Constructors 
      Constructor Description
      NamespaceBinding​(java.lang.String prefix, java.lang.String uri)
      Create a binding of a prefix to a URI
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)
      Test if this namespace binding is the same as another
      java.lang.String getPrefix()
      Get the prefix part of the binding
      java.lang.String getURI()
      Get the URI part of the binding
      java.lang.String getURI​(java.lang.String prefix)  
      int hashCode()  
      boolean isDefaultUndeclaration()
      Ask whether this is an undeclaration of the default prefix, that is, a namespace binding corresponding to xmlns=""
      boolean isXmlNamespace()
      Ask whether this is a binding for the XML namespace
      java.util.Iterator<NamespaceBinding> iterator()
      Returns an iterator over this singleton set of namespace bindings.
      static NamespaceBinding makeNamespaceBinding​(java.lang.CharSequence prefix, java.lang.CharSequence uri)
      Create a binding of a prefix to a URI.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Constructor Detail

      • NamespaceBinding

        public NamespaceBinding​(java.lang.String prefix,
                                java.lang.String uri)
        Create a binding of a prefix to a URI
        Parameters:
        prefix - the prefix: either an NCName, or a zero-length string to bind the default namespace. Must not be null.
        uri - the namespace URI: either a URI, or a zero-length string to unbind the prefix. Must not be null.
    • Method Detail

      • getURI

        public java.lang.String getURI​(java.lang.String prefix)
        Specified by:
        getURI in interface NamespaceBindingSet
      • makeNamespaceBinding

        public static NamespaceBinding makeNamespaceBinding​(java.lang.CharSequence prefix,
                                                            java.lang.CharSequence uri)
        Create a binding of a prefix to a URI. Static factory method for the convenience of compiled bytecode; reuses standard NamespaceBinding objects where possible
        Parameters:
        prefix - the prefix: either an NCName, or a zero-length string to bind the default namespace. Must not be null.
        uri - the namespace URI: either a URI, or a zero-length string to unbind the prefix. Must not be null.
        Returns:
        the namespace binding object
      • getPrefix

        public java.lang.String getPrefix()
        Get the prefix part of the binding
        Returns:
        the prefix. Never null. The zero-length string indicates a binding for the default namespace.
      • getURI

        public java.lang.String getURI()
        Get the URI part of the binding
        Returns:
        the URI. Never null. The zero-length string indicates an unbinding of the prefix. For the default namespace (prefix="") this indicates that the prefix refers to names in no namespace; for other prefixes, it indicates that the prefix is not bound to any namespace and therefore cannot be used.
      • isXmlNamespace

        public boolean isXmlNamespace()
        Ask whether this is a binding for the XML namespace
        Returns:
        true if this is the binding of the prefix "xml" to the standard XML namespace.
      • isDefaultUndeclaration

        public boolean isDefaultUndeclaration()
        Ask whether this is an undeclaration of the default prefix, that is, a namespace binding corresponding to xmlns=""
        Returns:
        true if this corresponding to xmlns=""
      • iterator

        public java.util.Iterator<NamespaceBinding> iterator()
        Returns an iterator over this singleton set of namespace bindings.
        Specified by:
        iterator in interface java.lang.Iterable<NamespaceBinding>
        Returns:
        an Iterator.
      • equals

        public boolean equals​(java.lang.Object obj)
        Test if this namespace binding is the same as another
        Overrides:
        equals in class java.lang.Object
        Parameters:
        obj - the comparand
        Returns:
        true if the comparand is a Namespace binding of the same prefix to the same URI
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object