Class AbstractNamespaceLabelManager

  • All Implemented Interfaces:
    java.util.Map<java.net.URI,​java.lang.String>

    public abstract class AbstractNamespaceLabelManager
    extends MapDecorator<java.net.URI,​java.lang.String>
    Map managing namespace URIs and labels for serialization. Mapping labels to the null namespace or to the null label is allowed.

    This class is not thread safe.

    Author:
    Garret Wilson
    • Field Detail

      • KNOWN_NAMESPACE_URIS

        public static final java.util.Set<java.net.URI> KNOWN_NAMESPACE_URIS
        The set of known namespace URIs.
      • DEFAULT_NAMESPACE_URI_LABEL_MAP

        public static final java.util.Map<java.net.URI,​java.lang.String> DEFAULT_NAMESPACE_URI_LABEL_MAP
        The default map of namespace-label mappings.
    • Constructor Detail

      • AbstractNamespaceLabelManager

        public AbstractNamespaceLabelManager()
        Default constructor using a hash map.
      • AbstractNamespaceLabelManager

        public AbstractNamespaceLabelManager​(java.util.Map<java.net.URI,​java.lang.String> map)
        Map constructor.
        Parameters:
        map - The map this map should decorate.
        Throws:
        java.lang.NullPointerException - if the provided map is null.
    • Method Detail

      • isRecognized

        public boolean isRecognized​(java.net.URI namespaceURI)
        Determines whether the given namespace URI is that of a recognized namespace. A namespace is recognized if a label has been associated with the given namespace URI or the default namespace URI label map has a record of this namespace.
        Parameters:
        namespaceURI - A namespace URId
        Returns:
        true if a label has been associated with the given namespace URI or if a label is known that could be associated with this namespace URI.
        See Also:
        DEFAULT_NAMESPACE_URI_LABEL_MAP
      • addNamespaceURI

        public boolean addNamespaceURI​(java.net.URI namespaceURI)
        Adds a namespace URI and associates it with a default label.
        Parameters:
        namespaceURI - The namespace URI to add.
        Returns:
        true if the namespace was not previously known.
        Throws:
        java.lang.NullPointerException - if the given namespace URI is null.
      • determineNamespaceLabel

        public java.lang.String determineNamespaceLabel​(java.net.URI namespaceURI)
        Retrieves the label to use for the given namespace. If a namespace is unrecognized (i.e. no label, including the null label, has been registered with the given namespace), a new one will be created and stored in the map for future use. The last package segment of any hierarchical URIs will be used as the namespace label if possible.
        Parameters:
        namespaceURI - The namespace URI for which a label should be returned
        Returns:
        A label for use with the given namespace, or null if the null label is assigned to the given namespace.
        See Also:
        isLabel(String)
      • isLabel

        protected abstract boolean isLabel​(java.lang.String string)
        Determines whether the given string is a valid label
        Parameters:
        string - The string to check for being a label.
        Returns:
        true if the given string represents a valid label.
        Throws:
        java.lang.NullPointerException - if the given string is null.