groovy.xml
Class QName

QName class represents the value of a qualified name as specified in XML Schema Part2: Datatypes specification.

The value of a QName contains a namespaceURI, a localPart and a prefix. The localPart provides the local part of the qualified name. The namespaceURI is a URI reference identifying the namespace.

version:
1.1

Field Summary
 String EMPTY_STRING
           
 String localPart
           
 String namespaceURI
           
 String prefix
           
 
Constructor Summary
QName(String localPart)
            comment/shared empty string
QName(String namespaceURI, String localPart)
            Constructor for the QName.
QName(String namespaceURI, String localPart, String prefix)
            Constructor for the QName.
 
Method Summary
boolean equals(Object o)
           Tests this QName for equality with another object.
String getLocalPart()
           Gets the Local part for this QName
String getNamespaceURI()
           Gets the Namespace URI for this QName
String getPrefix()
           Gets the Prefix for this QName
String getQualifiedName()
           Returns the fully qualified name of this QName
int hashCode()
           Returns a hash code value for this QName object.
boolean matches(Object o)
           Tests if this QName matches another object.
void readObject(ObjectInputStream in)
           Ensure that deserialization properly interns the results.
String toString()
           Returns a string representation of this QName
static QName valueOf(String s)
          
 

Constructor Detail

QName

public QName(String localPart)
comment/shared empty string


QName

public QName(String namespaceURI, String localPart)
Constructor for the QName.
param:
namespaceURI Namespace URI for the QName
param:
localPart Local part of the QName.


QName

public QName(String namespaceURI, String localPart, String prefix)
Constructor for the QName.
param:
namespaceURI Namespace URI for the QName
param:
localPart Local part of the QName.
param:
prefix Prefix of the QName.


Method Detail

equals

public boolean equals(Object o)
Tests this QName for equality with another object.

If the given object is not a QName or String equivalent or is null then this method returns false.

For two QNames to be considered equal requires that both localPart and namespaceURI must be equal. This method uses String.equals to check equality of localPart and namespaceURI. Any class that extends QName is required to satisfy this equality contract. If the supplied object is a String, then it is split in two on the last colon and the first half is compared against the prefix || namespaceURI and the second half is compared against the localPart i.e. assert new QName("namespace","localPart").equals("namespace:localPart") Intended Usage: for gpath accessors, e.g. root.'urn:mynamespace:node' Warning: this equivalence is not commutative, i.e. qname.equals(string) may be true/false but string.equals(qname) is always false

This method satisfies the general contract of the Object.equals method.

param:
o the reference object with which to compare
return:
true if the given object is identical to this
QName: false otherwise.


getLocalPart

public String getLocalPart()
Gets the Local part for this QName
return:
Local part


getNamespaceURI

public String getNamespaceURI()
Gets the Namespace URI for this QName
return:
Namespace URI


getPrefix

public String getPrefix()
Gets the Prefix for this QName
return:
Prefix


getQualifiedName

public String getQualifiedName()
Returns the fully qualified name of this QName
return:
a string representation of the QName


hashCode

public int hashCode()
Returns a hash code value for this QName object. The hash code is based on both the localPart and namespaceURI parts of the QName. This method satisfies the general contract of the Object.hashCode method.
return:
a hash code value for this Qname object


matches

public boolean matches(Object o)
Tests if this QName matches another object.

If the given object is not a QName or String equivalent or is null then this method returns false.

For two QNames to be considered matching requires that both localPart and namespaceURI must be equal or one of them is a wildcard. If the supplied object is a String, then it is split in two on the last colon and the first half is matched against the prefix || namespaceURI and the second half is matched against the localPart

param:
o the reference object with which to compare
return:
true if the given object matches
this QName: false otherwise.


readObject

void readObject(ObjectInputStream in)
Ensure that deserialization properly interns the results.
param:
in the ObjectInputStream to be read


toString

public String toString()
Returns a string representation of this QName
return:
a string representation of the QName


valueOf

public static QName valueOf(String s)