javax.xml.namespace
public class QName extends Object implements Serializable
A QName
is a qualified name, as specified by
XML Schema Part2: Datatypes specification, Namespaces in XML, Namespaces in XML Errata.
A qualified name is made up of a namespace URI, a local part, and a prefix.
The prefix is not really a part of the QName
and
remains only to provide lexical information. It is not
used in the {@link #equals(Object)} or {@link #hashCode()}
methods.
Namespace URI and prefix may be omitted, in which case the default value "" (empty string) is used.
Instances of QName
are immutable. You may safely
store references.
Constructor Summary | |
---|---|
QName(String pNamespaceURI, String pLocalPart) Creates a new | |
QName(String pNamespaceURI, String pLocalPart, String pPrefix) Creates a new | |
QName(String pLocalPart) Creates a new |
Method Summary | |
---|---|
boolean | equals(Object pOther) Returns true, if
|
String | getLocalPart() Returns the local part of the |
String | getNamespaceURI() Returns the namespace URI. |
String | getPrefix() Returns the namespace prefix. |
int | hashCode() Returns the |
String | toString() Converts the QName into a string representation. |
static QName | valueOf(String pQName) Parses the given string representation of a |
Creates a new QName
with the given
pNamespaceURI
and pLocalPart
. The
prefix is set to "" (empty string).
Parameters: pNamespaceURI The namespace URI; may be null, in which case the default value "" (empty string) is used. pLocalPart The local part.
Throws: IllegalArgumentException The local part was null.
Creates a new QName
with the given
pNamespaceURI
, pLocalPart
, and
pPrefix
.
Parameters: pNamespaceURI The namespace URI; may be null, in which case the default value "" (empty string) is used. pLocalPart The local part. pPrefix The prefix. Must not be null. Use "" (empty string) to indicate that no namespace URI is present or the namespace URI is not relevant.
Throws: IllegalArgumentException The local part or the prefix was null.
Creates a new QName
with the given
pLocalPart
, the namespace URI "" (empty string),
and the prefix "" (empty string).
Parameters: pLocalPart The local part.
Throws: IllegalArgumentException The local part or the prefix was null.
Returns true, if
pOther
instanceof QNameReturns the local part of the QName
.
Returns: The local part.
Returns the namespace URI.
Returns: Namespace URI or "" (empty string) to indicate the absence of a namespace.
Returns the namespace prefix.
Returns: The namespace prefix or "" (empty string) to indicate the default namespace
Returns the QName
's hash code.
The prefix is ignored when calculating the hash code.
Converts the QName into a string representation. The current implementation returns the local part, if the namespace URI is "" (empty string). Otherwise returns "{" + namespaceURI + "}" + localPart. The prefix is ignored.
The representation is subject to changes, as there is currently no
standard representation for a QName
. You should use this
method for debugging or logging purposes only.
Parses the given string representation of a pQName
.
The QName
is expected to have the same representation
than returned by {@link #toString()}.
It is not possible to specify a prefix. The returned
QName
will always have the prefix "" (empty string).
Parameters: pQName String representation of a QName, as generated by {@link #toString()}.
Returns: QName with the prefix "" (empty string)
Throws: IllegalArgumentException The given pQName
was null or empty.