Class OdfNamespace

  • All Implemented Interfaces:
    Comparable<OdfNamespace>, NamespaceName

    public class OdfNamespace
    extends Object
    implements Comparable<OdfNamespace>, NamespaceName
    Class wrapping the XML Namespace URI and XML Namespace prefix (used by default) as a single entity For instance, the ODF paragraph element uses by default in the ODF specification the prefix "text" and is bound to this prefix heres
    • Method Detail

      • newNamespace

        public static OdfNamespace newNamespace​(NamespaceName name)
        Returns the OdfNamespace for the given name. Creates a new one, if the name was not asked before.
        Parameters:
        name - represents a W3C Namespace Name. The interface NamespaceName is often implemented by an enum.
        Returns:
        the OdfNamespace for the given name.
      • newNamespace

        public static OdfNamespace newNamespace​(String prefix,
                                                String uri)
        Returns the OdfNamespace for the given name. Creates a new one, if the name was not asked before.
        Parameters:
        prefix - abbreviation for the URL, might be null when a default namespace was set
        uri - identifying the namespace.
        Returns:
        the namespace.
      • initializeUrl2DefaultPrefixMap

        public static void initializeUrl2DefaultPrefixMap()
        In case of a default namespace no prefix is given, but we require the prefix for our class loader
      • getNamespace

        public static OdfNamespace getNamespace​(String uri)
        Returns the namespace for the given uri.
        Parameters:
        uri - identifying the namespace.
        Returns:
        the namespace identified by the given uri.
      • getPrefix

        public String getPrefix()
        Specified by:
        getPrefix in interface NamespaceName
        Returns:
        the prefix currently related to XML Namespace. Note: Even in a single XML file, a user might assign different prefixes to a XML Namespace, different NamespaceNames might exist.
      • getUri

        public String getUri()
        Specified by:
        getUri in interface NamespaceName
        Returns:
        the URI identifiying the XML Namespace.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • splitQName

        public static String[] splitQName​(String qname)
                                   throws IllegalArgumentException
        Splits the XML Qname into the local name and the prefix.
        Parameters:
        qname - is the qualified name to be split.
        Returns:
        an array of two strings containing first the prefix and the second the local part.
        Throws:
        IllegalArgumentException - if no qualified name was given.
      • getPrefixPart

        public static String getPrefixPart​(String qname)
        Parameters:
        qname - is the qualified name to be splitted.
        Returns:
        the local name of the XML Qname.
        Throws:
        IllegalArgumentException - if no qualified name was given.
      • getLocalPart

        public static String getLocalPart​(String qname)
        Parameters:
        qname - is the qualified name to be splitted.
        Returns:
        the prefix of the XML Qname.
        Throws:
        IllegalArgumentException - if no qualified name was given.