javax.xml.namespace
Class QName

java.lang.Object
  extended byjavax.xml.namespace.QName
All Implemented Interfaces:
java.io.Serializable

public class QName
extends java.lang.Object
implements java.io.Serializable

QName represents an immutable qualified name. The value of a QName contains a Namespace URI, local part and prefix. The prefix is included in QName to retain lexical information when present in an XML input source. The prefix is NOT used in QName.equals(Object) or to compute the QName.hashCode(). Equality and the hash code are defined using only the Namespace URI and local part. If not specified, the Namespace URI is set to "" (the empty string). If not specified, the prefix is set to "" (the empty string).

See Also:
Serialized Form

Constructor Summary
QName(java.lang.String localPart)
           
QName(java.lang.String namespaceURI, java.lang.String localPart)
           
QName(java.lang.String namespaceURI, java.lang.String localPart, java.lang.String prefix)
          QName constructor specifying the Namespace URI, local part and prefix.
 
Method Summary
 int compareTo(java.lang.Object o)
          Compares this object with the specified object for order.
 boolean equals(java.lang.Object obj)
          Equality is based on the namespaceURI and localPart
 java.lang.String getLocalPart()
           
 java.lang.String getNamespaceURI()
           
 java.lang.String getPrefix()
           
 int hashCode()
          Calculate the hash of namespaceURI and localPart
 java.lang.String toString()
          There is NO standard specification for representing a QName as a String.
static QName (src) valueOf(java.lang.String toStringName)
          QName derived from parsing the formatted String.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

QName

public QName(java.lang.String localPart)

QName

public QName(java.lang.String namespaceURI,
             java.lang.String localPart)

QName

public QName(java.lang.String namespaceURI,
             java.lang.String localPart,
             java.lang.String prefix)
QName constructor specifying the Namespace URI, local part and prefix. If the Namespace URI is null, it is set to "". This value represents no explicitly defined Namespace as defined by the Namespaces in XML specification. This action preserves compatible behavior with QName 1.0. If the local part is null, an IllegalArgumentException is thrown. If the prefix is null, an IllegalArgumentException is thrown. Use "" to explicitly indicate that no prefix is present or the prefix is not relevant.

Parameters:
namespaceURI - - Namespace URI of the QName
localPart - - local part of the QName
prefix - - prefix of the QName
Method Detail

valueOf

public static QName (src)  valueOf(java.lang.String toStringName)
QName derived from parsing the formatted String. If the String is null or does not conform to QName.toString() formatting, an IllegalArgumentException is thrown. The String MUST be in the form returned by QName.toString(). There is NO standard specification for representing a QName as a String. The String format is NOT portable across implementations and will change when a standard String representation is defined. This implementation currently parses a String formatted as: "{" + Namespace URI + "}" + local part. If the Namespace URI .equals(""), only the local part should be provided. The prefix value CANNOT be represented in the String and will be set to "" This method does not do full validation of the resulting QName. In particular, the local part is not validated as a NCName as specified in Namespaces in XML.

Parameters:
toStringName - - a QName string in the format of toString().
Returns:
QName for the toStringName
See Also:
toString()

getNamespaceURI

public java.lang.String getNamespaceURI()

getLocalPart

public java.lang.String getLocalPart()

getPrefix

public java.lang.String getPrefix()

toString

public java.lang.String toString()
There is NO standard specification for representing a QName as a String. The returned String is not portable across implementations and will change when a standard String representation is defined. This implementation currently represents a QName as: "{" + Namespace URI + "}" + local part. If the Namespace URI .equals(""), only the local part is returned. An appropriate use of this method is for debugging or logging for human consumption. Note the prefix value is NOT returned as part of the String representation.

Returns:
'{' + namespaceURI + '}' + localPart

equals

public boolean equals(java.lang.Object obj)
Equality is based on the namespaceURI and localPart

Parameters:
obj - the QName to compare too
Returns:
true if both namespaceURI and localPart, false otherwise

hashCode

public int hashCode()
Calculate the hash of namespaceURI and localPart

Returns:
namespaceURI.hashCode() + localPart.hashCode()

compareTo

public int compareTo(java.lang.Object o)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.