net.sf.saxon.om
Class FingerprintedQName

java.lang.Object
  extended by net.sf.saxon.om.StructuredQName
      extended by net.sf.saxon.om.FingerprintedQName
All Implemented Interfaces:
NodeName

public class FingerprintedQName
extends StructuredQName
implements NodeName

A QName triple (prefix, URI, local) with the additional ability to hold an integer fingerprint. The integer fingerprint provides a fast way of checking equality. A FingerprintedQName makes sense only in the context of a known NamePool, and instances must be compared only if they relate to the same NamePool. The fingerprint is optional, and is used only if present.


Constructor Summary
FingerprintedQName(String prefix, String uri, String localName)
           
FingerprintedQName(String prefix, String uri, String localName, int nameCode)
           
 
Method Summary
 int allocateNameCode(NamePool pool)
          Allocate a nameCode from the NamePool (if none has already been allocated).
 boolean equals(Object other)
          Compare two StructuredQName values for equality.
static FingerprintedQName fromClarkName(String expandedName)
          Make a structuredQName from a Clark name
 int getFingerprint()
          Get the fingerprint of this name if known.
 int getNameCode()
          Get the nameCode of this name if known.
 boolean hasFingerprint()
          Ask whether this node name representation has a known namecode and fingerprint
 void setNameCode(int nameCode)
          Set the nameCode for this QName.
 
Methods inherited from class net.sf.saxon.om.StructuredQName
computeHashCode, fromLexicalQName, getClarkName, getDisplayName, getLocalPart, getNamespaceBinding, getPrefix, getStructuredQName, getURI, hashCode, isInNamespace, isInSameNamespace, toJaxpQName, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.sf.saxon.om.NodeName
getDisplayName, getLocalPart, getNamespaceBinding, getPrefix, getStructuredQName, getURI, isInNamespace, isInSameNamespace
 

Constructor Detail

FingerprintedQName

public FingerprintedQName(String prefix,
                          String uri,
                          String localName)

FingerprintedQName

public FingerprintedQName(String prefix,
                          String uri,
                          String localName,
                          int nameCode)
Method Detail

fromClarkName

public static FingerprintedQName fromClarkName(String expandedName)
Make a structuredQName from a Clark name

Parameters:
expandedName - the name in Clark notation "{uri}local" if in a namespace, or "local" otherwise. The format "{}local" is also accepted for a name in no namespace.
Returns:
the constructed StructuredQName
Throws:
IllegalArgumentException - if the Clark name is malformed

hasFingerprint

public boolean hasFingerprint()
Ask whether this node name representation has a known namecode and fingerprint

Specified by:
hasFingerprint in interface NodeName
Overrides:
hasFingerprint in class StructuredQName
Returns:
true if the methods getFingerprint() and getNameCode() will return a result other than -1

getFingerprint

public int getFingerprint()
Get the fingerprint of this name if known. This method should not to any work to allocate a fingerprint if none is already available

Specified by:
getFingerprint in interface NodeName
Overrides:
getFingerprint in class StructuredQName
Returns:
the fingerprint if known; otherwise -1

getNameCode

public int getNameCode()
Get the nameCode of this name if known. This method should not to any work to allocate a nameCode if none is already available

Specified by:
getNameCode in interface NodeName
Overrides:
getNameCode in class StructuredQName
Returns:
the fingerprint if known; otherwise -1

setNameCode

public void setNameCode(int nameCode)
Set the nameCode for this QName. Note that this modifies the FingerprintedQName object and makes it unusable with a different NamePool.

Parameters:
nameCode - the nameCode associated with this QName by the NamePool

allocateNameCode

public int allocateNameCode(NamePool pool)
Allocate a nameCode from the NamePool (if none has already been allocated). Note that this modifies the FingerprintedQName object and makes it unusable with a different NamePool.

Specified by:
allocateNameCode in interface NodeName
Parameters:
pool - the namePool
Returns:
the allocated name code (or the existing namecode if there already was one)

equals

public boolean equals(Object other)
Description copied from class: StructuredQName
Compare two StructuredQName values for equality. This compares the URI and local name parts, excluding any prefix

Overrides:
equals in class StructuredQName


Copyright (c) 2004-2011 Saxonica Limited. All rights reserved.