Class 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 Detail

      • FingerprintedQName

        public FingerprintedQName​(java.lang.String prefix,
                                  java.lang.String uri,
                                  java.lang.String localName)
      • FingerprintedQName

        public FingerprintedQName​(java.lang.String prefix,
                                  java.lang.String uri,
                                  java.lang.String localName,
                                  int nameCode)
    • Method Detail

      • fromClarkName

        public static FingerprintedQName fromClarkName​(java.lang.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:
        java.lang.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​(java.lang.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