Class SaxonXQItemType

  • All Implemented Interfaces:
    XQItemType, XQSequenceType

    public class SaxonXQItemType
    extends java.lang.Object
    implements XQItemType
    Saxon implementation of the XQJ XQItemType interface
    • Constructor Detail

      • SaxonXQItemType

        protected SaxonXQItemType​(NodeInfo node)
    • Method Detail

      • getBaseType

        public int getBaseType()
                        throws XQException
        Description copied from interface: XQItemType
        Returns the base type of the item. One of the XQBASETYPE_* constants.

        XQJ defines a constant for each of the built-in schema types defined in XML Schema. For atomic types this is the closest matching built-in XML Schema type, for element and attributes the closest matching built-in XML Schema type this node is based on.

        Specified by:
        getBaseType in interface XQItemType
        Returns:
        int one of the XQBASETYPE_* constants indicating the basic type of the item
        Throws:
        XQException - if the item kind is not one of: XQITEMKIND_DOCUMENT_ELEMENT, XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT, XQITEMKIND_ELEMENT, XQITEMKIND_SCHEMA_ELEMENT, XQITEMKIND_ATTRIBUTE, XQITEMKIND_SCHEMA_ATTRIBUTE, or XQITEMKIND_ATOMIC
      • getItemKind

        public int getItemKind()
        Description copied from interface: XQItemType
        Returns the kind of the item. One of the XQITEMKIND_* constants.
        Specified by:
        getItemKind in interface XQItemType
        Returns:
        int one of the XQITEMKIND_* constants indicating the basic kind of the item
      • getItemOccurrence

        public int getItemOccurrence()
        Description copied from interface: XQItemType
        Returns the occurrence indicator for the item type. This method will always return the value XQSequenceType.OCC_EXACTLY_ONE.
        Specified by:
        getItemOccurrence in interface XQItemType
        Specified by:
        getItemOccurrence in interface XQSequenceType
        Returns:
        int indicating the occurrence indicator
      • getNodeName

        public javax.xml.namespace.QName getNodeName()
                                              throws XQException
        Description copied from interface: XQItemType
        Returns the name of the node in case the item kind is an XQITEMKIND_DOCUMENT_ELEMENT, XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT, XQITEMKIND_ELEMENT, XQITEMKIND_SCHEMA_ELEMENT, XQITEMKIND_ATTRIBUTE, or XQITEMKIND_SCHEMA_ATTRIBUTE.

        For example, in the case of a type for element "foo" this will return the QName foo. For wildcard entries a null value will be returned.

        Specified by:
        getNodeName in interface XQItemType
        Returns:
        QName for the name of the element, attribute, or document element node. null if it is a wildcard
        Throws:
        XQException - if the item kind is not one of: XQITEMKIND_DOCUMENT_ELEMENT, XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT, XQITEMKIND_ELEMENT, XQITEMKIND_SCHEMA_ELEMENT, XQITEMKIND_ATTRIBUTE, or XQITEMKIND_SCHEMA_ATTRIBUTE
      • getPIName

        public java.lang.String getPIName()
                                   throws XQException
        Description copied from interface: XQItemType
        Returns the name of the processing instruction type. As such the item kind of this XQItemType must be XQITEMKIND_PI.
        Specified by:
        getPIName in interface XQItemType
        Returns:
        the name of the processing instruction type. null if it is a wildcard
        Throws:
        XQException - if the item kind is not XQITEMKIND_PI
      • getSchemaURI

        public java.net.URI getSchemaURI()
        Description copied from interface: XQItemType
        Returns the schema location URI of the schema that contains the item's element or type definition. This method is implementation-definied and an implementation will return a null value if it does not support retrieving the schema location URI.

        If the item corresponds to a validated global element in a schema, the result will be the schema location URI to the XMLSchema containing the element definition. Otherwise if the item is a schema validated node, the result will be the schema location URI of the XMLSchema containing the type definition of that node. If the item is not schema validated, the result is null

        Specified by:
        getSchemaURI in interface XQItemType
        Returns:
        URI representing the schema location URI of the XMLSchema containing the global element definition or the type definition of the current item. null in case the item is not schema validated or if the implementation does not support retrieving the schema URI.
      • toString

        public java.lang.String toString()
        Description copied from interface: XQItemType
        Returns a human-readable implementation-defined string representation of the item type.
        Specified by:
        toString in interface XQItemType
        Specified by:
        toString in interface XQSequenceType
        Overrides:
        toString in class java.lang.Object
        Returns:
        String a string representation of the item type
      • getTypeName

        public javax.xml.namespace.QName getTypeName()
                                              throws XQException
        Description copied from interface: XQItemType
        Represents a type name (global or local). This can be used to represent specific type name such as, element foo of type hatsize. The schema type name is represented as a single QName. If the return type is an anonymous type, the actual QName value returned is implementation defined.
        Specified by:
        getTypeName in interface XQItemType
        Returns:
        the QName of the schema type in case of a user defined or anonoymous types. For a built-in type, returns a predefined type name as QName (e.g.xs:anyType, xs:decimal, etc). Cannot be null
        Throws:
        XQException - if the item kind is not one of: XQITEMKIND_DOCUMENT_ELEMENT, XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT, XQITEMKIND_ATOMIC, XQITEMKIND_ELEMENT, XQITEMKIND_SCHEMA_ELEMENT, XQITEMKIND_ATTRIBUTE, or XQITEMKIND_SCHEMA_ATTRIBUTE
      • isAnonymousType

        public boolean isAnonymousType()
        Description copied from interface: XQItemType
        Represents whether the item type is an anonymous type in the schema.
        Specified by:
        isAnonymousType in interface XQItemType
        Returns:
        true if the item type is an anonymous type in the schema, false otherwise
      • isElementNillable

        public boolean isElementNillable()
        Description copied from interface: XQItemType
        Returns whether the element type is nillable or not.
        Specified by:
        isElementNillable in interface XQItemType
        Returns:
        true if the element type is nillable, false otherwise
      • getItemType

        public XQItemType getItemType()
        Description copied from interface: XQSequenceType
        Returns the type of the item in the sequence type.
        Specified by:
        getItemType in interface XQSequenceType
        Returns:
        XQItemType representing the item type in the sequence. null is returned in case of an empty sequence.
      • equals

        public boolean equals​(java.lang.Object obj)
        Description copied from interface: XQItemType
        Compares the specified object with this item type for equality. The result is true only if the argument is an item type object which represents the same XQuery item type.

        In order to comply with the general contract of equals and hashCode across different implementations the following algorithm must be used. Return true if and only if both objects are XQItemType and:

        • getItemKind() is equal
        • if getBaseType() is supported for the item kind, it must be equal
        • if getNodeName() is supported for the item kind, it must be equal
        • getSchemaURI() is equal
        • if getTypeName() is supported for the item kind, it must be equal
        • isAnonymousType() is equal
        • isElementNillable() is equal
        • if getPIName() is supported for the item kind, it must be equal
        Specified by:
        equals in interface XQItemType
        Specified by:
        equals in interface XQSequenceType
        Overrides:
        equals in class java.lang.Object
        Parameters:
        obj - an XQItemType object representing an XQuery item type
        Returns:
        true if the input item type object represents the same XQuery item type, false otherwise
      • hashCode

        public int hashCode()
        Description copied from interface: XQItemType
        Returns a hash code consistent with the definition of the equals method.

        In order to comply with the general contract of equals and hashCode across different implementations the following algorithm must be used:

          hashCode = this.getItemKind();
          if this.getSchemaURI != null
            hashCode = 31*hashCode + this.getSchemaURI().hashCode();
          if this.getBaseType() is supported for the item kind
            hashCode = 31*hashCode + this.getbaseType();
          if this.getNodeName () is supported for the item kind and
            this.getNodeName() != null
            hashCode = 31*hashCode + this.getNodeName().hashCode()
          if this.getTypeName () is supported for the item kind
            hashCode = 31*hashCode + this.getTypeName().hashCode();
          if this.getPIName () is supported for the item kind and
            this.getPIName () != null
            hashCode = 31*hashCode + this.getPIName().hashCode();
         
        Specified by:
        hashCode in interface XQItemType
        Specified by:
        hashCode in interface XQSequenceType
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        hash code for this item type