org.odftoolkit.odfdom.pkg
Class OdfNamespace

java.lang.Object
  extended by org.odftoolkit.odfdom.pkg.OdfNamespace
All Implemented Interfaces:
java.lang.Comparable<OdfNamespace>, NamespaceName

public class OdfNamespace
extends java.lang.Object
implements java.lang.Comparable<OdfNamespace>, NamespaceName

Class wrapping the XML Namespace URI and XML Namespace prefix as a single entity.


Method Summary
 int compareTo(OdfNamespace namespace)
           
 boolean equals(java.lang.Object obj)
           
static java.lang.String getLocalPart(java.lang.String qname)
           
static OdfNamespace getNamespace(java.lang.String uri)
          Returns the namespace for the given uri.
 java.lang.String getPrefix()
           
static java.lang.String getPrefixPart(java.lang.String qname)
           
 java.lang.String getUri()
           
 int hashCode()
           
static OdfNamespace newNamespace(NamespaceName name)
          Returns the OdfNamespace for the given name.
static OdfNamespace newNamespace(java.lang.String prefix, java.lang.String uri)
          Returns the OdfNamespace for the given name.
static java.lang.String[] splitQName(java.lang.String qname)
          Splits the XML Qname into the local name and the prefix.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

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(java.lang.String prefix,
                                        java.lang.String uri)
Returns the OdfNamespace for the given name. Creates a new one, if the name was not asked before.

Parameters:
uri - identifying the namespace.
Returns:
the namespace.

getNamespace

public static OdfNamespace getNamespace(java.lang.String uri)
Returns the namespace for the given uri.

Parameters:
uri - identifying the namespace.
Returns:
the namespace identified by the given uri.

getPrefix

public java.lang.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 java.lang.String getUri()
Specified by:
getUri in interface NamespaceName
Returns:
the URI identifiying the XML Namespace.

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

splitQName

public static java.lang.String[] splitQName(java.lang.String qname)
                                     throws java.lang.IllegalArgumentException
Splits the XML Qname into the local name and the prefix.

Parameters:
qname - is the qualified name to be splitted.
Returns:
an array of two strings containing first the prefix and the second the local part.
Throws:
java.lang.IllegalArgumentException - if no qualified name was given.

getPrefixPart

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

getLocalPart

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

compareTo

public int compareTo(OdfNamespace namespace)
Specified by:
compareTo in interface java.lang.Comparable<OdfNamespace>


Copyright © 2008-2012 The Apache Software Foundation. All Rights Reserved.