Class QNameValue

  • All Implemented Interfaces:
    java.io.Serializable, Expression, Item, ValueRepresentation
    Direct Known Subclasses:
    NotationValue

    public class QNameValue
    extends AtomicValue
    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.
    See Also:
    Serialized Form
    • Constructor Detail

      • QNameValue

        public QNameValue​(NamePool namePool,
                          int nameCode)
        Constructor
        Parameters:
        namePool - The name pool containing the specified name code
        nameCode - The name code identifying this name in the name pool
      • QNameValue

        public QNameValue​(java.lang.String prefix,
                          java.lang.String uri,
                          java.lang.String localName,
                          NameChecker checker)
                   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 null or "" to represent the default prefix. 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 or "" to represent the null namespace.
        localName - The local part of the QName
        checker - NameChecker used to check the name against XML 1.0 or XML 1.1 rules. Supply null if the name does not need to be checked (the caller asserts that it is known to be valid)
        Throws:
        XPathException
    • Method Detail

      • getClarkName

        public java.lang.String getClarkName()
        Get the name in Clark notation, that is {uri}local
      • getLocalName

        public java.lang.String getLocalName()
        Get the local part
      • getNamespaceURI

        public java.lang.String getNamespaceURI()
        Get the namespace part (null means no namespace)
      • getPrefix

        public java.lang.String getPrefix()
        Get the prefix
      • allocateNameCode

        public int allocateNameCode​(NamePool pool)
        Allocate a nameCode for this QName in the NamePool
        Parameters:
        pool - the NamePool to be used
        Returns:
        the allocated nameCode
      • getComponent

        public AtomicValue getComponent​(int 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
      • convertPrimitive

        public AtomicValue convertPrimitive​(BuiltInAtomicType requiredType,
                                            boolean validate,
                                            XPathContext context)
        Convert to target data type
        Specified by:
        convertPrimitive in class AtomicValue
        Parameters:
        requiredType - an integer identifying the required atomic type
        context -
        validate - true if validation is required. If set to false, the caller guarantees that the value is valid for the target data type, and that further validation is therefore not required. Note that a validation failure may be reported even if validation was not requested.
        Returns:
        an AtomicValue, a value of the required type; or an ErrorValue
      • equals

        public boolean equals​(java.lang.Object other)
        Determine if two QName values are equal. This comparison ignores the prefix part of the value.
        Overrides:
        equals in class Value
        Throws:
        java.lang.ClassCastException - if they are not comparable
        java.lang.IllegalStateException - if the two QNames are in different name pools
      • hashCode

        public int hashCode()
        Description copied from class: Value
        Return a hash code to support the equals() function
        Overrides:
        hashCode in class Value
      • toString

        public java.lang.String toString()
        The toString() method returns the name in the form QName("uri", "local")
        Overrides:
        toString in class AtomicValue
        Returns:
        the name in in the form QName("uri", "local")
      • makeQName

        public java.lang.Object makeQName​(Configuration config)
        Temporary method to construct a javax.xml.namespace.QName without actually mentioning it by name (because the class is not available in JDK 1.4)