Class OdfName

  • All Implemented Interfaces:
    Comparable<OdfName>

    public class OdfName
    extends Object
    implements Comparable<OdfName>
    The class provides a simplified interface for XML names. The class defines a name for an XML node. It embraces XML NamespaceURI, XML prefix and XML localname.
    • Method Detail

      • newName

        public static OdfName newName​(String name)
        Returns the OdfName for the given namespace and name. Creates a new one, if the OdfName was not asked before.
        Parameters:
        name - of the XML node
        Returns:
        the OdfName for the given OdfNamesapce and name.
      • newName

        public static OdfName newName​(OdfNamespace odfNamespace,
                                      String name)
        Returns the OdfName for the given namespace and name. Creates a new one, if the OdfName was not asked before.
        Parameters:
        odfNamespace - the namespace of the name to be created
        name - of the XML node. Can be both local or qualified name.
        Returns:
        the OdfName for the given OdfNamesapce and name.
      • newName

        public static OdfName newName​(NamespaceName namespaceNamed,
                                      String name)
        Returns the OdfName for the given namespace and name. Creates a new one, if the OdfName was not asked before.
        Parameters:
        namespaceNamed - represents a W3C Namespace Name. The interface NamespaceName is often implemented by an enum.
        name - of the XML node. Can be both local or qualified name.
        Returns:
        the OdfName for the given OdfNamesapce and name.
      • getOdfName

        public static OdfName getOdfName​(OdfNamespace odfNamespace,
                                         String localName)
        Used for receiving an OdfName, in case of a default nameaspace, when there is no prefix.
      • getUri

        public String getUri()
        Returns:
        the XML Namespace URI, for it would be urn:oasis:names:tc:opendocument:xmlns:text:1.0
      • getLocalName

        public String getLocalName()
        Returns:
        the XML localname, for it would be p.
      • getPrefix

        public String getPrefix()
        Returns:
        the XML prefix, for it would be text.
      • getQName

        public String getQName()
        Returns:
        the XML QName, the qualified name e.g. for it is text:p.
      • toString

        public String toString()
        Overrides:
        toString in class Object
        Returns:
        the OdfName as String, represented by a concatenation of XML Namespace URI (within brackets) and local name, as for it would be {urn:oasis:names:tc:opendocument:xmlns:text:1.0}p
      • equals

        public boolean equals​(String namespaceUri,
                              String name)
        Parameters:
        namespaceUri - of the XML node to be compared.
        name - of the XML node to be compared. Can be qualifed name or localname.
        Returns:
        true if the given OdfName has the same namespaceURI and localname.
      • hashCode

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

        public int compareTo​(OdfName o)
        Compares the by parameter given OdfName with this OdfName
        Specified by:
        compareTo in interface Comparable<OdfName>