org.odftoolkit.odfdom.pkg
Class OdfNamespace

java.lang.Object
  extended by org.odftoolkit.odfdom.pkg.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 as a single entity.


Method Summary
 int compareTo(OdfNamespace namespace)
           
 boolean equals(Object obj)
           
static String getLocalPart(String qname)
           
static OdfNamespace getNamespace(String uri)
          Returns the namespace for the given uri.
 String getPrefix()
           
static String getPrefixPart(String qname)
           
 String getUri()
           
 int hashCode()
           
static OdfNamespace newNamespace(NamespaceName name)
          Returns the OdfNamespace for the given name.
static OdfNamespace newNamespace(String prefix, String uri)
          Returns the OdfNamespace for the given name.
static String[] splitQName(String qname)
          Splits the XML Qname into the local name and the prefix.
 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(String prefix,
                                        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(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.

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString 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 splitted.
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.

compareTo

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


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