Interface XQItemType

All Superinterfaces:
XQSequenceType
All Known Implementing Classes:
SaxonXQItemType

public interface XQItemType extends XQSequenceType
The XQItemType interface represents an item type as defined in XQuery 1.0: An XML Query language.

The XQItemType extends the XQSequenceType but restricts the occurrance indicator to be exactly one. This derivation allows passing an item type wherever a sequence type is expected, but not the other way.

The XQItemType interface contains methods to represent information about the following aspects of an item type:

  • The kind of the item - one of XQITEMKIND_* constants
  • The base type of the item - one of the XQBASETYPE_* constants. 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.
  • Name of the node, if any
  • Type name, if any. If present, then also whether the typename is an anonymous type
  • XML Schema URI associated with the type, if any
  • The nillability characteristics, if any

An instance of the XQItemType is a standalone object that is independant of the XQConnection and any XQuery static or dynamic context.

  • Field Details

    • XQITEMKIND_ATOMIC

      static final int XQITEMKIND_ATOMIC
      Some atomic type.
      See Also:
    • XQITEMKIND_ATTRIBUTE

      static final int XQITEMKIND_ATTRIBUTE
      Attribute node
      See Also:
    • XQITEMKIND_COMMENT

      static final int XQITEMKIND_COMMENT
      Comment node
      See Also:
    • XQITEMKIND_DOCUMENT

      static final int XQITEMKIND_DOCUMENT
      Document type (the type information represents the type of the document element)
      See Also:
    • XQITEMKIND_DOCUMENT_ELEMENT

      static final int XQITEMKIND_DOCUMENT_ELEMENT
      Document node containing a single element node as its child (type information represents type of the element child)
      See Also:
    • XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT

      static final int XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT
      Document node containing a single schema element node as its child (type information represents type of the schema element child)
      See Also:
    • XQITEMKIND_ELEMENT

      static final int XQITEMKIND_ELEMENT
      Element node
      See Also:
    • XQITEMKIND_ITEM

      static final int XQITEMKIND_ITEM
      Any kind of item
      See Also:
    • XQITEMKIND_NODE

      static final int XQITEMKIND_NODE
      Some node type
      See Also:
    • XQITEMKIND_PI

      static final int XQITEMKIND_PI
      Processing instruction node
      See Also:
    • XQITEMKIND_TEXT

      static final int XQITEMKIND_TEXT
      Text node
      See Also:
    • XQITEMKIND_SCHEMA_ELEMENT

      static final int XQITEMKIND_SCHEMA_ELEMENT
      Schema element node
      See Also:
    • XQITEMKIND_SCHEMA_ATTRIBUTE

      static final int XQITEMKIND_SCHEMA_ATTRIBUTE
      Schema attribute node
      See Also:
    • XQBASETYPE_UNTYPED

      static final int XQBASETYPE_UNTYPED
      Represents the schema type xs:untyped
      See Also:
    • XQBASETYPE_ANYTYPE

      static final int XQBASETYPE_ANYTYPE
      Represents the schema type xs:anyType
      See Also:
    • XQBASETYPE_ANYSIMPLETYPE

      static final int XQBASETYPE_ANYSIMPLETYPE
      Represents the schema type xs:anySimpleType
      See Also:
    • XQBASETYPE_ANYATOMICTYPE

      static final int XQBASETYPE_ANYATOMICTYPE
      Represents the schema type xs:anyAtomicType
      See Also:
    • XQBASETYPE_UNTYPEDATOMIC

      static final int XQBASETYPE_UNTYPEDATOMIC
      Represents the schema type xs:untypedAtomic
      See Also:
    • XQBASETYPE_DAYTIMEDURATION

      static final int XQBASETYPE_DAYTIMEDURATION
      Represents the schema type xs:dayTimeDuration
      See Also:
    • XQBASETYPE_YEARMONTHDURATION

      static final int XQBASETYPE_YEARMONTHDURATION
      Represents the schema type xs:yearMonthDuration
      See Also:
    • XQBASETYPE_ANYURI

      static final int XQBASETYPE_ANYURI
      Represents the schema type xs:anyURI
      See Also:
    • XQBASETYPE_BASE64BINARY

      static final int XQBASETYPE_BASE64BINARY
      Represents the schema type xs:base64Binary
      See Also:
    • XQBASETYPE_BOOLEAN

      static final int XQBASETYPE_BOOLEAN
      Represents the schema type xs:boolean
      See Also:
    • XQBASETYPE_DATE

      static final int XQBASETYPE_DATE
      Represents the schema type xs:date
      See Also:
    • XQBASETYPE_INT

      static final int XQBASETYPE_INT
      Represents the schema type xs:int
      See Also:
    • XQBASETYPE_INTEGER

      static final int XQBASETYPE_INTEGER
      Represents the schema type xs:integer
      See Also:
    • XQBASETYPE_SHORT

      static final int XQBASETYPE_SHORT
      Represents the schema type xs:short
      See Also:
    • XQBASETYPE_LONG

      static final int XQBASETYPE_LONG
      Represents the schema type xs:long
      See Also:
    • XQBASETYPE_DATETIME

      static final int XQBASETYPE_DATETIME
      Represents the schema type xs:dateTime
      See Also:
    • XQBASETYPE_DECIMAL

      static final int XQBASETYPE_DECIMAL
      Represents the schema type xs:decimal
      See Also:
    • XQBASETYPE_DOUBLE

      static final int XQBASETYPE_DOUBLE
      Represents the schema type xs:double
      See Also:
    • XQBASETYPE_DURATION

      static final int XQBASETYPE_DURATION
      Represents the schema type xs:duration
      See Also:
    • XQBASETYPE_FLOAT

      static final int XQBASETYPE_FLOAT
      Represents the schema type xs:float
      See Also:
    • XQBASETYPE_GDAY

      static final int XQBASETYPE_GDAY
      Represents the schema type xs:gDay
      See Also:
    • XQBASETYPE_GMONTH

      static final int XQBASETYPE_GMONTH
      Represents the schema type xs:gMonth
      See Also:
    • XQBASETYPE_GMONTHDAY

      static final int XQBASETYPE_GMONTHDAY
      Represents the schema type xs:gMonthDay
      See Also:
    • XQBASETYPE_GYEAR

      static final int XQBASETYPE_GYEAR
      Represents the schema type xs:gYear
      See Also:
    • XQBASETYPE_GYEARMONTH

      static final int XQBASETYPE_GYEARMONTH
      Represents the schema type xs:gYearMonth
      See Also:
    • XQBASETYPE_HEXBINARY

      static final int XQBASETYPE_HEXBINARY
      Represents the schema type xs:hexBinary
      See Also:
    • XQBASETYPE_NOTATION

      static final int XQBASETYPE_NOTATION
      Represents the schema type xs:NOTATION
      See Also:
    • XQBASETYPE_QNAME

      static final int XQBASETYPE_QNAME
      Represents the schema type xs:QName
      See Also:
    • XQBASETYPE_STRING

      static final int XQBASETYPE_STRING
      Represents the schema type xs:string
      See Also:
    • XQBASETYPE_TIME

      static final int XQBASETYPE_TIME
      Represents the schema type xs:time
      See Also:
    • XQBASETYPE_BYTE

      static final int XQBASETYPE_BYTE
      Represents the schema type xs:byte
      See Also:
    • XQBASETYPE_NONPOSITIVE_INTEGER

      static final int XQBASETYPE_NONPOSITIVE_INTEGER
      Represents the schema type xs:nonPositiveInteger
      See Also:
    • XQBASETYPE_NONNEGATIVE_INTEGER

      static final int XQBASETYPE_NONNEGATIVE_INTEGER
      Represents the schema type xs:nonNegativeInteger
      See Also:
    • XQBASETYPE_NEGATIVE_INTEGER

      static final int XQBASETYPE_NEGATIVE_INTEGER
      Represents the schema type xs:negativeInteger
      See Also:
    • XQBASETYPE_POSITIVE_INTEGER

      static final int XQBASETYPE_POSITIVE_INTEGER
      Represents the schema type xs:positiveInteger
      See Also:
    • XQBASETYPE_UNSIGNED_LONG

      static final int XQBASETYPE_UNSIGNED_LONG
      Represents the schema type xs:unsignedLong
      See Also:
    • XQBASETYPE_UNSIGNED_INT

      static final int XQBASETYPE_UNSIGNED_INT
      Represents the schema type xs:unsignedInt
      See Also:
    • XQBASETYPE_UNSIGNED_SHORT

      static final int XQBASETYPE_UNSIGNED_SHORT
      Represents the schema type xs:unsignedShort
      See Also:
    • XQBASETYPE_UNSIGNED_BYTE

      static final int XQBASETYPE_UNSIGNED_BYTE
      Represents the schema type xs:unsignedByte
      See Also:
    • XQBASETYPE_NORMALIZED_STRING

      static final int XQBASETYPE_NORMALIZED_STRING
      Represents the schema type xs:normalizedString
      See Also:
    • XQBASETYPE_TOKEN

      static final int XQBASETYPE_TOKEN
      Represents the schema type xs:token
      See Also:
    • XQBASETYPE_LANGUAGE

      static final int XQBASETYPE_LANGUAGE
      Represents the schema type xs:language
      See Also:
    • XQBASETYPE_NAME

      static final int XQBASETYPE_NAME
      Represents the schema type xs:Name
      See Also:
    • XQBASETYPE_NCNAME

      static final int XQBASETYPE_NCNAME
      Represents the schema type xs:NCName
      See Also:
    • XQBASETYPE_NMTOKEN

      static final int XQBASETYPE_NMTOKEN
      Represents the schema type xs:NMToken
      See Also:
    • XQBASETYPE_ID

      static final int XQBASETYPE_ID
      Represents the schema type xs:ID
      See Also:
    • XQBASETYPE_IDREF

      static final int XQBASETYPE_IDREF
      Represents the schema type xs:IDREF
      See Also:
    • XQBASETYPE_ENTITY

      static final int XQBASETYPE_ENTITY
      Represents the schema type xs:ENTITY
      See Also:
    • XQBASETYPE_IDREFS

      static final int XQBASETYPE_IDREFS
      Represents the schema type xs:IDREFS. Valid only if the item kind is XQITEMKIND_ELEMENT, XQITEMKIND_DOCUMENT_ELEMENT, or XQITEMKIND_ATTRIBUTE
      See Also:
    • XQBASETYPE_ENTITIES

      static final int XQBASETYPE_ENTITIES
      Represents the schema type xs:ENTITIES
      See Also:
    • XQBASETYPE_NMTOKENS

      static final int XQBASETYPE_NMTOKENS
      Represents the schema type xs:NMTOKENS
      See Also:
  • Method Details

    • getBaseType

      int getBaseType() throws XQException
      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.

      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

      int getItemKind()
      Returns the kind of the item. One of the XQITEMKIND_* constants.
      Returns:
      int one of the XQITEMKIND_* constants indicating the basic kind of the item
    • getItemOccurrence

      int getItemOccurrence()
      Returns the occurrence indicator for the item type. This method will always return the value XQSequenceType.OCC_EXACTLY_ONE.
      Specified by:
      getItemOccurrence in interface XQSequenceType
      Returns:
      int indicating the occurrence indicator
    • toString

      String toString()
      Returns a human-readable implementation-defined string representation of the item type.
      Specified by:
      toString in interface XQSequenceType
      Overrides:
      toString in class Object
      Returns:
      String a string representation of the item type
    • getNodeName

      QName getNodeName() throws XQException
      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.

      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
    • getSchemaURI

      URI getSchemaURI()
      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

      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.
    • getTypeName

      QName getTypeName() throws XQException
      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.
      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

      boolean isAnonymousType()
      Represents whether the item type is an anonymous type in the schema.
      Returns:
      true if the item type is an anonymous type in the schema, false otherwise
    • isElementNillable

      boolean isElementNillable()
      Returns whether the element type is nillable or not.
      Returns:
      true if the element type is nillable, false otherwise
    • getPIName

      String getPIName() throws XQException
      Returns the name of the processing instruction type. As such the item kind of this XQItemType must be XQITEMKIND_PI.
      Returns:
      the name of the processing instruction type. null if it is a wildcard
      Throws:
      XQException - if the item kind is not XQITEMKIND_PI
    • equals

      boolean equals(Object o)
      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 XQSequenceType
      Overrides:
      equals in class Object
      Parameters:
      o - 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

      int hashCode()
      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 XQSequenceType
      Overrides:
      hashCode in class Object
      Returns:
      hash code for this item type