public interface NodeName extends IdentityComparable
An important requirement of an implementation of this interface is that the hashCode() and
equals() methods are implemented correctly, so that any two node names compare equal if and only
if the local name and namespace URI parts are equal under Unicode codepoint comparison. To ensure this,
the hashCode must be computed using an algorithm equivalent to that used by the implementation class
FingerprintedQName
This class is used to carry name information for elements and attributes on the Receiver pipeline. An advantage of this is that NodeName can include a fingerprint where this is available, but the fingerprint does not need to be computed if it is not needed. For example, names of nodes constructed by an XSLT stylesheet and sent down an output pipeline to a Serializer will generally not have fingerprints.
Equality comparisons between NodeNames work reasonably well: the comparison can use the fingerprints if available, or the QNames otherwise. However, computing hashCodes is inefficient; it is not possible to take advantage of the fingerprints, because they are not always there. Therefore, using NodeName objects in structures such as maps and sets is generally a bad idea: it's better to use either the StructuredQName or the fingerprint as the key.
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getDisplayName()
Get the display name, that is the lexical QName in the form [prefix:]local-part
|
int |
getFingerprint()
Get the fingerprint of this name if known.
|
java.lang.String |
getLocalPart()
Get the local part of the QName
|
NamespaceBinding |
getNamespaceBinding()
Get a
NamespaceBinding whose (prefix, uri) pair are the prefix and URI of this
node name |
java.lang.String |
getPrefix()
Get the prefix of the QName.
|
StructuredQName |
getStructuredQName()
Get the name in the form of a StructuredQName
|
java.lang.String |
getURI()
Get the namespace URI of the QName.
|
boolean |
hasFingerprint()
Ask whether this node name representation has a known fingerprint
|
boolean |
hasURI(java.lang.String ns)
Test whether this name is in a given namespace
|
boolean |
isInSameNamespace(NodeName other)
Test whether this name is in the same namespace as another name
|
int |
obtainFingerprint(NamePool namePool)
Get the fingerprint of this name, allocating a new code from the namepool if necessary
|
identityHashCode, isIdentical
java.lang.String getPrefix()
java.lang.String getURI()
java.lang.String getLocalPart()
java.lang.String getDisplayName()
StructuredQName getStructuredQName()
boolean isInSameNamespace(NodeName other)
other
- the other nameboolean hasURI(java.lang.String ns)
ns
- the namespace to be tested againstNamespaceBinding getNamespaceBinding()
NamespaceBinding
whose (prefix, uri) pair are the prefix and URI of this
node nameboolean hasFingerprint()
int getFingerprint()
int obtainFingerprint(NamePool namePool)
namePool
- the NamePool used to allocate the nameCopyright (c) 2004-2020 Saxonica Limited. All rights reserved.