Package org.odftoolkit.odfdom.pkg
Class OdfNamespace
java.lang.Object
org.odftoolkit.odfdom.pkg.OdfNamespace
- All Implemented Interfaces:
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 <text:p> uses by default in the ODF specification
the prefix "text" and is bound to this prefix heres
-
Method Summary
Modifier and TypeMethodDescriptionint
compareTo
(OdfNamespace namespace) boolean
static String
getLocalPart
(String qname) static OdfNamespace
getNamespace
(String uri) Returns the namespace for the given uri.static String
getPrefixPart
(String qname) getUri()
int
hashCode()
static void
In case of a default namespace no prefix is given, but we require the prefix for our class loaderstatic OdfNamespace
newNamespace
(String prefix, String uri) Returns the OdfNamespace for the given name.static OdfNamespace
newNamespace
(NamespaceName name) Returns the OdfNamespace for the given name.static String[]
splitQName
(String qname) Splits the XML Qname into the local name and the prefix.toString()
-
Method Details
-
newNamespace
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 interfaceNamespaceName
is often implemented by an enum.- Returns:
- the OdfNamespace for the given name.
-
newNamespace
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 seturi
- 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
Returns the namespace for the given uri.- Parameters:
uri
- identifying the namespace.- Returns:
- the namespace identified by the given uri.
-
getPrefix
- Specified by:
getPrefix
in interfaceNamespaceName
- 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
- Specified by:
getUri
in interfaceNamespaceName
- Returns:
- the URI identifiying the XML Namespace.
-
equals
-
hashCode
public int hashCode() -
toString
-
splitQName
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
- 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
- Parameters:
qname
- is the qualified name to be splitted.- Returns:
- the prefix of the XML Qname.
- Throws:
IllegalArgumentException
- if no qualified name was given.
-
compareTo
- Specified by:
compareTo
in interfaceComparable<OdfNamespace>
-