Class QNameValue

All Implemented Interfaces:
Comparable<XPathComparable>, Iterable<AtomicValue>, AtomicMatchKey, XPathComparable, AtomicSequence, GroundedValue, IdentityComparable, Item, Sequence, ConversionResult

public class QNameValue extends QualifiedNameValue
A QName value. This implements the so-called "triples proposal", in which the prefix is retained as part of the value. The prefix is not used in any operation on a QName other than conversion of the QName to a string.
  • Constructor Details

    • QNameValue

      public QNameValue(StructuredQName qName, AtomicMetadata metadata)
      Constructor
      Parameters:
      qName - the name as a StructuredQName
      metadata - identifies a subtype of xs:QName or other metadata
    • QNameValue

      public QNameValue(String prefix, NamespaceUri uri, String localName)
      Constructor for a QName that is known to be valid. No validation takes place.
      Parameters:
      prefix - The prefix part of the QName (not used in comparisons). Use "" to represent the default prefix.
      uri - The namespace part of the QName. Use "" to represent the non-namespace.
      localName - The local part of the QName
    • QNameValue

      public QNameValue(String prefix, NamespaceUri uri, String localName, AtomicType type)
      Constructor for a QName that is known to be valid, allowing a user-defined subtype of QName to be specified. No validation takes place.
      Parameters:
      prefix - The prefix part of the QName (not used in comparisons). Use "" to represent the default prefix (but null is also accepted)
      uri - The namespace part of the QName. Use null to represent the non-namespace (but "" is also accepted).
      localName - The local part of the QName
      type - The type label, xs:QName or a subtype of xs:QName
    • QNameValue

      public QNameValue(String prefix, NamespaceUri uri, String localName, AtomicType type, boolean check) throws XPathException
      Constructor. This constructor validates that the local part is a valid NCName.
      Parameters:
      prefix - The prefix part of the QName (not used in comparisons). Use "" to represent the default prefix (but null is also accepted). Note that the prefix is not checked for lexical correctness, because in most cases it will already have been matched against in-scope namespaces. Where necessary the caller must check the prefix.
      uri - The namespace part of the QName. Use null to represent the non-namespace (but "" is also accepted).
      localName - The local part of the QName
      type - The atomic type, which must be either xs:QName, or a user-defined type derived from xs:QName by restriction
      check - Supply false if the name does not need to be checked (the caller asserts that it is known to be valid)
      Throws:
      XPathException - if the local part of the name is malformed or if the name has a null namespace with a non-empty prefix
  • Method Details

    • withMetadata

      public AtomicValue withMetadata(AtomicMetadata metadata)
      Create a copy of this atomic value, with a different type label
      Specified by:
      withMetadata in class AtomicValue
      Parameters:
      metadata - the type label of the new copy. The caller is responsible for checking that the value actually conforms to this type.
      Returns:
      the copied value
    • getPrimitiveType

      public BuiltInAtomicType getPrimitiveType()
      Determine the primitive type of the value. This delivers the same answer as getItemType().getPrimitiveItemType(). The primitive types are the 19 primitive types of XML Schema, plus xs:integer, xs:dayTimeDuration and xs:yearMonthDuration, and xs:untypedAtomic. For external objects, the result is AnyAtomicType.
      Specified by:
      getPrimitiveType in class AtomicValue
      Returns:
      the primitive type
    • getComponent

      public AtomicValue getComponent(AccessorFn.Component part)
      Get a component. Returns a zero-length string if the namespace-uri component is requested and is not present.
      Overrides:
      getComponent in class AtomicValue
      Parameters:
      part - either Component.LOCALNAME or Component.NAMESPACE indicating which component of the value is required
      Returns:
      either the local name or the namespace URI, in each case as a StringValue
    • equals

      public boolean equals(Object other)
      Determine if two QName values are equal. This comparison ignores the prefix part of the value.
      Overrides:
      equals in class AtomicValue
      Parameters:
      other - the other value
      Returns:
      true (in a subclass) if the other operand is an atomic value and the two values are equal as defined by the XPath eq operator
      Throws:
      ClassCastException - if they are not comparable
    • hashCode

      public int hashCode()
      Description copied from class: AtomicValue
      Returns a hash code value for the object.
      Overrides:
      hashCode in class QualifiedNameValue