Top Description Fields Constructors Methods
groovy.xml

public Class QName

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Annotations
@Deprecated
Imports
java.io.Serializable

Deprecated

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.

Field Summary

Modifier and TypeField and Description
private static final String
EMPTY_STRING

comment/shared empty string

private String
localPart

Field localPart

private String
namespaceURI

Field namespaceURI

private String
prefix

Field prefix

private static final long

Constructor Summary

AccessConstructor and Description
public
QName(String
Local part of the QName
localPart
)

Constructor for the QName.

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

Constructor for the QName.

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

Constructor for the QName.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the given object is identical to this QName: false otherwise.
equals
(Object
the reference object with which to compare
o
)

Overrides java.lang.Object.equals.

Tests this QName for equality with another object.
public String

Returns:

Local part
getLocalPart
()

Gets the Local part for this QName

public String

Returns:

Namespace URI
getNamespaceURI
()

Gets the Namespace URI for this QName

public String

Returns:

Prefix
getPrefix
()

Gets the Prefix for this QName

public String

Returns:

a string representation of the QName
getQualifiedName
()

Returns the fully qualified name of this QName

public int

Returns:

a hash code value for this Qname object
hashCode
()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this QName object.
public boolean

Returns:

true if the given object matches this QName: false otherwise.
matches
(Object
the reference object with which to compare
o
)

Tests if this QName matches another object.

public String

Returns:

a string representation of the QName
toString
()

Overrides java.lang.Object.toString.

Returns a string representation of this QName
public static QName

Returns:

QName corresponding to the given String
valueOf
(String
the string to be parsed
s
)

Deprecated as a consequence of QName being deprecated.
Returns a QName holding the value of the specified String.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

EMPTY_STRINGback to summary
private static final String EMPTY_STRING

comment/shared empty string

localPartback to summary
private String localPart

Field localPart

namespaceURIback to summary
private String namespaceURI

Field namespaceURI

prefixback to summary
private String prefix

Field prefix

serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

QNameback to summary
public QName(String localPart)

Constructor for the QName.

Parameters
localPart:String

Local part of the QName

QNameback to summary
public QName(String namespaceURI, String localPart)

Constructor for the QName.

Parameters
namespaceURI:String

Namespace URI for the QName

localPart:String

Local part of the QName.

QNameback to summary
public QName(String namespaceURI, String localPart, String prefix)

Constructor for the QName.

Parameters
namespaceURI:String

Namespace URI for the QName

localPart:String

Local part of the QName.

prefix:String

Prefix of the QName.

Method Detail

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

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.

Parameters
o:Object

the reference object with which to compare

Returns:boolean

true if the given object is identical to this QName: false otherwise.

getLocalPartback to summary
public String getLocalPart()

Gets the Local part for this QName

Returns:String

Local part

getNamespaceURIback to summary
public String getNamespaceURI()

Gets the Namespace URI for this QName

Returns:String

Namespace URI

getPrefixback to summary
public String getPrefix()

Gets the Prefix for this QName

Returns:String

Prefix

getQualifiedNameback to summary
public String getQualifiedName()

Returns the fully qualified name of this QName

Returns:String

a string representation of the QName

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.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.

Returns:int

a hash code value for this Qname object

matchesback to summary
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

Parameters
o:Object

the reference object with which to compare

Returns:boolean

true if the given object matches this QName: false otherwise.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns a string representation of this QName

Returns:String

a string representation of the QName

valueOfback to summary
public static QName valueOf(String s)

Deprecated

as a consequence of QName being deprecated. See corresponding docs for further information.

Returns a QName holding the value of the specified String.

The string must be in the form returned by the QName.toString() method, i.e. "{namespaceURI}localPart", with the "{namespaceURI}" part being optional.

This method doesn't do a full validation of the resulting QName. In particular, it doesn't check that the resulting namespace URI is a legal URI (per RFC 2396 and RFC 2732), nor that the resulting local part is a legal NCName per the XML Namespaces specification.

Parameters
s:String

the string to be parsed

Returns:QName

QName corresponding to the given String

Exceptions
IllegalArgumentException:
If the specified String cannot be parsed as a QName