Class DeclaredNamespaces


  • public final class DeclaredNamespaces
    extends Object
    A immutable namespace collection. Any attempt to modify the declared namespaces creates a new copy of the map.
    Author:
    Thomas Morgner
    • Constructor Detail

      • DeclaredNamespaces

        public DeclaredNamespaces()
        Creates a new namespaces collection.
      • DeclaredNamespaces

        public DeclaredNamespaces​(DeclaredNamespaces namespaces)
        Creates a new namespaces collection using the given namespaces as initial values.
        Parameters:
        namespaces - the namespaces, never null.
    • Method Detail

      • add

        public DeclaredNamespaces add​(HashMap newNamespaces)
        Adds all namespaces from the given hashmap into this map. The namespaces map must only contain string keys and string values and must not contain either null-keys or null-values.
        Parameters:
        newNamespaces - the namespaces collection.
        Returns:
        the created namespaces object.
      • add

        public DeclaredNamespaces add​(AttributeList attributes)
        Adds all declared namespaces from the given attribute-list into the namespaces collection.
        Parameters:
        attributes - the attribute list containing namespace definitions.
        Returns:
        the new namespaces collection.
      • add

        public DeclaredNamespaces add​(String uri,
                                      String prefix)
        Adds a single namespace definition to the collection.
        Parameters:
        uri - the URI of the namespace.
        prefix - the prefix to be used for the namespace.
        Returns:
        the new namespaces collection.
      • getPrefix

        public String getPrefix​(String uri)
        Looksup the prefix for the given URI. This returns null if the URI is not a declared namespace.
        Parameters:
        uri - the URI.
        Returns:
        the prefix for the given URI or null, if the URI is not part of this collection.
      • isNamespaceDefined

        public boolean isNamespaceDefined​(String uri)
        Checks, whether the namespace marked by the given URI is defined in this collection.
        Parameters:
        uri - the URI to be checked.
        Returns:
        true, if the URI is known, false otherwise.
      • getNamespaces

        public Map getNamespaces()
        Returns all known namespaces as unmodifiable map.
        Returns:
        the namespaces.
      • isPrefixDefined

        public boolean isPrefixDefined​(String prefix)
        Checks whether the given prefix is already defined in the collection.
        Parameters:
        prefix - the prefix.
        Returns:
        true, if the prefix is already used, false otherwise.