Class ItemType

  • All Implemented Interfaces:
    java.util.function.Predicate<XdmItem>
    Direct Known Subclasses:
    ItemType.BuiltInAtomicItemType

    public abstract class ItemType
    extends java.lang.Object
    implements java.util.function.Predicate<XdmItem>
    An item type, as defined in the XPath/XQuery specifications.

    This class contains a number of static constant fields referring to instances that represent simple item types, such as item(), node(), and xs:anyAtomicType. These named types are currently based on the definitions in XSD 1.0 and XML 1.0. They may be changed in a future version to be based on a later version.

    More complicated item types, especially those that are dependent on information in a schema, are available using factory methods on the ItemTypeFactory object. The factory methods can also be used to create variants of the types that use the rules given in the XML 1.1 and/or XSD 1.1 specifications. In addition the method ItemTypeFactory.parseItemType(java.lang.String) can be used to construct ItemType objects from their representation in XPath syntax.

    An ItemType can be used as a predicate in contexts where a predicate is required to filter items, for example in Step.where(java.util.function.Predicate<? super T>).

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      protected static class  ItemType.BuiltInAtomicItemType
      ItemType representing a built-in atomic type
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static ItemType ANY_ARRAY
      ItemType representing the type array(*), that is, any array
      static ItemType ANY_ATOMIC_VALUE
      ItemType representing the type xs:anyAtomicType, that is, any atomic value
      static ItemType ANY_FUNCTION
      ItemType representing the type function(*), that is, any function
      static ItemType ANY_ITEM
      ItemType representing the type item(), that is, any item at all
      static ItemType ANY_MAP
      ItemType representing the type map(*), that is, any map
      static ItemType ANY_NODE
      ItemType representing the type node(), that is, any node
      static ItemType ANY_URI
      ItemType representing the primitive type xs:anyURI
      static ItemType ATTRIBUTE_NODE
      ItemType representing the ATTRIBUTE node() type
      static ItemType BASE64_BINARY
      ItemType representing the primitive type xs:base64Binary
      static ItemType BOOLEAN
      ItemType representing the primitive type xs:boolean
      static ItemType BYTE
      ItemType representing the built-in (but non-primitive) type xs:byte
      static ItemType COMMENT_NODE
      ItemType representing the COMMENT node() type
      static ItemType DATE
      ItemType representing the primitive type xs:date
      static ItemType DATE_TIME
      ItemType representing the primitive type xs:dateTime
      static ItemType DATE_TIME_STAMP
      ItemType representing the built-in (but non-primitive) type xs:dateTimeStamp (introduced in XSD 1.1)
      static ItemType DAY_TIME_DURATION
      ItemType representing the built-in (but non-primitive) type xs:dayTimeDuration
      static ItemType DECIMAL
      ItemType representing the primitive type xs:decimal
      static ItemType DOCUMENT_NODE
      ItemType representing the DOCUMENT node() type
      static ItemType DOUBLE
      ItemType representing the primitive type xs:double
      static ItemType DURATION
      ItemType representing the primitive type xs:duration
      static ItemType ELEMENT_NODE
      ItemType representing the ELEMENT node() type
      static ItemType ENTITY
      ItemType representing the built-in (but non-primitive) type xs:ENTITY
      static ItemType ERROR
      ItemType representing the type xs:error: a type with no instances
      static ItemType FLOAT
      ItemType representing the primitive type xs:float
      static ItemType G_DAY
      ItemType representing the primitive type xs:gDay
      static ItemType G_MONTH
      ItemType representing the primitive type xs:gMonth
      static ItemType G_MONTH_DAY
      ItemType representing the primitive type xs:gMonthDay
      static ItemType G_YEAR
      ItemType representing the primitive type xs:gYear
      static ItemType G_YEAR_MONTH
      ItemType representing the primitive type xs:gYearMonth
      static ItemType HEX_BINARY
      ItemType representing the primitive type xs:hexBinary
      static ItemType ID
      ItemType representing the built-in (but non-primitive) type xs:ID
      static ItemType IDREF
      ItemType representing the built-in (but non-primitive) type xs:IDREF
      static ItemType INT
      ItemType representing the built-in (but non-primitive) type xs:int
      static ItemType INTEGER
      ItemType representing the built-in (but non-primitive) type xs:integer
      static ItemType LANGUAGE
      ItemType representing the built-in (but non-primitive) type xs:language
      static ItemType LONG
      ItemType representing the built-in (but non-primitive) type xs:long
      static ItemType NAME
      ItemType representing the built-in (but non-primitive) type xs:Name
      static ItemType NAMESPACE_NODE
      ItemType representing the NAMESPACE node() type
      static ItemType NCNAME
      ItemType representing the built-in (but non-primitive) type xs:NCName
      static ItemType NEGATIVE_INTEGER
      ItemType representing the built-in (but non-primitive) type xs:negativeInteger
      static ItemType NMTOKEN
      ItemType representing the built-in (but non-primitive) type xs:NMTOKEN
      static ItemType NON_NEGATIVE_INTEGER
      ItemType representing the built-in (but non-primitive) type xs:nonNegativeInteger
      static ItemType NON_POSITIVE_INTEGER
      ItemType representing the built-in (but non-primitive) type xs:nonPositiveInteger
      static ItemType NORMALIZED_STRING
      ItemType representing the built-in (but non-primitive) type xs:normalizedString
      static ItemType NOTATION
      ItemType representing the primitive type xs:NOTATION
      static ItemType NUMERIC
      ItemType representing the built-in union type xs:numeric defined in XDM 3.1
      static ItemType POSITIVE_INTEGER
      ItemType representing the built-in (but non-primitive) type xs:positiveInteger
      static ItemType PROCESSING_INSTRUCTION_NODE
      ItemType representing the PROCESSING_INSTRUCTION node() type
      static ItemType QNAME
      ItemType representing the primitive type xs:QName
      static ItemType SHORT
      ItemType representing the built-in (but non-primitive) type xs:short
      static ItemType STRING
      ItemType representing the primitive type xs:string
      static ItemType TEXT_NODE
      ItemType representing the TEXT node() type
      static ItemType TIME
      ItemType representing the primitive type xs:time
      static ItemType TOKEN
      ItemType representing the built-in (but non-primitive) type xs:token
      protected ItemType underlyingType  
      static ItemType UNSIGNED_BYTE
      ItemType representing the built-in (but non-primitive) type xs:unsignedByte
      static ItemType UNSIGNED_INT
      ItemType representing the built-in (but non-primitive) type xs:unsignedInt
      static ItemType UNSIGNED_LONG
      ItemType representing the built-in (but non-primitive) type xs:unsignedLong
      static ItemType UNSIGNED_SHORT
      ItemType representing the built-in (but non-primitive) type xs:unsignedShort
      static ItemType UNTYPED_ATOMIC
      ItemType representing the XPath-defined type xs:untypedAtomic
      static ItemType YEAR_MONTH_DURATION
      ItemType representing the built-in (but non-primitive) type xs:yearMonthDuration
    • Constructor Summary

      Constructors 
      Constructor Description
      ItemType​(ItemType underlyingType)  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object other)
      Test whether two ItemType objects represent the same type
      ConversionRules getConversionRules()
      Get the conversion rules implemented by this type.
      QName getTypeName()
      Get the name of the type, if it has one
      ItemType getUnderlyingItemType()
      Method to get the underlying Saxon implementation object
      int hashCode()
      Get a hash code with semantics corresponding to the equals() method
      abstract boolean matches​(XdmItem item)
      Determine whether this item type matches a given item.
      SequenceType one()
      Combine the item type with the occurrence indicator "exactly one" to form a sequence type.
      SequenceType oneOrMore()
      Combine the item type with the occurrence indicator "one or more" (+) to form a sequence type.
      abstract boolean subsumes​(ItemType other)
      Determine whether this ItemType subsumes another ItemType.
      boolean test​(XdmItem item)
      Determine whether this item type matches a given item.
      java.lang.String toString()
      Get a string representation of the type.
      SequenceType with​(OccurrenceIndicator occurrenceIndicator)
      Combine an item type with an occurrence indicator to produce a SequenceType.
      SequenceType zeroOrMore()
      Combine the item type with the occurrence indicator "zero or more" (*) to form a sequence type.
      SequenceType zeroOrOne()
      Combine the item type with the occurrence indicator "zero or one" (?) to form a sequence type.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.function.Predicate

        and, negate, or
    • Field Detail

      • underlyingType

        protected final ItemType underlyingType
      • ANY_ITEM

        public static ItemType ANY_ITEM
        ItemType representing the type item(), that is, any item at all
      • ANY_FUNCTION

        public static ItemType ANY_FUNCTION
        ItemType representing the type function(*), that is, any function
      • ANY_NODE

        public static final ItemType ANY_NODE
        ItemType representing the type node(), that is, any node
      • ATTRIBUTE_NODE

        public static final ItemType ATTRIBUTE_NODE
        ItemType representing the ATTRIBUTE node() type
      • COMMENT_NODE

        public static final ItemType COMMENT_NODE
        ItemType representing the COMMENT node() type
      • TEXT_NODE

        public static final ItemType TEXT_NODE
        ItemType representing the TEXT node() type
      • ELEMENT_NODE

        public static final ItemType ELEMENT_NODE
        ItemType representing the ELEMENT node() type
      • DOCUMENT_NODE

        public static final ItemType DOCUMENT_NODE
        ItemType representing the DOCUMENT node() type
      • NAMESPACE_NODE

        public static final ItemType NAMESPACE_NODE
        ItemType representing the NAMESPACE node() type
      • PROCESSING_INSTRUCTION_NODE

        public static final ItemType PROCESSING_INSTRUCTION_NODE
        ItemType representing the PROCESSING_INSTRUCTION node() type
      • ANY_MAP

        public static final ItemType ANY_MAP
        ItemType representing the type map(*), that is, any map
      • ANY_ARRAY

        public static final ItemType ANY_ARRAY
        ItemType representing the type array(*), that is, any array
      • ANY_ATOMIC_VALUE

        public static final ItemType ANY_ATOMIC_VALUE
        ItemType representing the type xs:anyAtomicType, that is, any atomic value
      • ERROR

        public static final ItemType ERROR
        ItemType representing the type xs:error: a type with no instances
      • STRING

        public static final ItemType STRING
        ItemType representing the primitive type xs:string
      • BOOLEAN

        public static final ItemType BOOLEAN
        ItemType representing the primitive type xs:boolean
      • DURATION

        public static final ItemType DURATION
        ItemType representing the primitive type xs:duration
      • DATE_TIME

        public static final ItemType DATE_TIME
        ItemType representing the primitive type xs:dateTime
      • DATE

        public static final ItemType DATE
        ItemType representing the primitive type xs:date
      • TIME

        public static final ItemType TIME
        ItemType representing the primitive type xs:time
      • G_YEAR_MONTH

        public static final ItemType G_YEAR_MONTH
        ItemType representing the primitive type xs:gYearMonth
      • G_MONTH

        public static final ItemType G_MONTH
        ItemType representing the primitive type xs:gMonth
      • G_MONTH_DAY

        public static final ItemType G_MONTH_DAY
        ItemType representing the primitive type xs:gMonthDay
      • G_YEAR

        public static final ItemType G_YEAR
        ItemType representing the primitive type xs:gYear
      • G_DAY

        public static final ItemType G_DAY
        ItemType representing the primitive type xs:gDay
      • HEX_BINARY

        public static final ItemType HEX_BINARY
        ItemType representing the primitive type xs:hexBinary
      • BASE64_BINARY

        public static final ItemType BASE64_BINARY
        ItemType representing the primitive type xs:base64Binary
      • ANY_URI

        public static final ItemType ANY_URI
        ItemType representing the primitive type xs:anyURI
      • QNAME

        public static final ItemType QNAME
        ItemType representing the primitive type xs:QName
      • NOTATION

        public static final ItemType NOTATION
        ItemType representing the primitive type xs:NOTATION
      • UNTYPED_ATOMIC

        public static final ItemType UNTYPED_ATOMIC
        ItemType representing the XPath-defined type xs:untypedAtomic
      • DECIMAL

        public static final ItemType DECIMAL
        ItemType representing the primitive type xs:decimal
      • FLOAT

        public static final ItemType FLOAT
        ItemType representing the primitive type xs:float
      • DOUBLE

        public static final ItemType DOUBLE
        ItemType representing the primitive type xs:double
      • INTEGER

        public static final ItemType INTEGER
        ItemType representing the built-in (but non-primitive) type xs:integer
      • NON_POSITIVE_INTEGER

        public static final ItemType NON_POSITIVE_INTEGER
        ItemType representing the built-in (but non-primitive) type xs:nonPositiveInteger
      • NEGATIVE_INTEGER

        public static final ItemType NEGATIVE_INTEGER
        ItemType representing the built-in (but non-primitive) type xs:negativeInteger
      • LONG

        public static final ItemType LONG
        ItemType representing the built-in (but non-primitive) type xs:long
      • INT

        public static final ItemType INT
        ItemType representing the built-in (but non-primitive) type xs:int
      • SHORT

        public static final ItemType SHORT
        ItemType representing the built-in (but non-primitive) type xs:short
      • BYTE

        public static final ItemType BYTE
        ItemType representing the built-in (but non-primitive) type xs:byte
      • NON_NEGATIVE_INTEGER

        public static final ItemType NON_NEGATIVE_INTEGER
        ItemType representing the built-in (but non-primitive) type xs:nonNegativeInteger
      • POSITIVE_INTEGER

        public static final ItemType POSITIVE_INTEGER
        ItemType representing the built-in (but non-primitive) type xs:positiveInteger
      • UNSIGNED_LONG

        public static final ItemType UNSIGNED_LONG
        ItemType representing the built-in (but non-primitive) type xs:unsignedLong
      • UNSIGNED_INT

        public static final ItemType UNSIGNED_INT
        ItemType representing the built-in (but non-primitive) type xs:unsignedInt
      • UNSIGNED_SHORT

        public static final ItemType UNSIGNED_SHORT
        ItemType representing the built-in (but non-primitive) type xs:unsignedShort
      • UNSIGNED_BYTE

        public static final ItemType UNSIGNED_BYTE
        ItemType representing the built-in (but non-primitive) type xs:unsignedByte
      • YEAR_MONTH_DURATION

        public static final ItemType YEAR_MONTH_DURATION
        ItemType representing the built-in (but non-primitive) type xs:yearMonthDuration
      • DAY_TIME_DURATION

        public static final ItemType DAY_TIME_DURATION
        ItemType representing the built-in (but non-primitive) type xs:dayTimeDuration
      • NORMALIZED_STRING

        public static final ItemType NORMALIZED_STRING
        ItemType representing the built-in (but non-primitive) type xs:normalizedString
      • TOKEN

        public static final ItemType TOKEN
        ItemType representing the built-in (but non-primitive) type xs:token
      • LANGUAGE

        public static final ItemType LANGUAGE
        ItemType representing the built-in (but non-primitive) type xs:language
      • NAME

        public static final ItemType NAME
        ItemType representing the built-in (but non-primitive) type xs:Name
      • NMTOKEN

        public static final ItemType NMTOKEN
        ItemType representing the built-in (but non-primitive) type xs:NMTOKEN
      • NCNAME

        public static final ItemType NCNAME
        ItemType representing the built-in (but non-primitive) type xs:NCName
      • ID

        public static final ItemType ID
        ItemType representing the built-in (but non-primitive) type xs:ID
      • IDREF

        public static final ItemType IDREF
        ItemType representing the built-in (but non-primitive) type xs:IDREF
      • ENTITY

        public static final ItemType ENTITY
        ItemType representing the built-in (but non-primitive) type xs:ENTITY
      • DATE_TIME_STAMP

        public static final ItemType DATE_TIME_STAMP
        ItemType representing the built-in (but non-primitive) type xs:dateTimeStamp (introduced in XSD 1.1)
      • NUMERIC

        public static final ItemType NUMERIC
        ItemType representing the built-in union type xs:numeric defined in XDM 3.1
    • Constructor Detail

      • ItemType

        public ItemType​(ItemType underlyingType)
    • Method Detail

      • with

        public SequenceType with​(OccurrenceIndicator occurrenceIndicator)
        Combine an item type with an occurrence indicator to produce a SequenceType. For example ItemType.ANY_ITEM.with(OccurrenceIndicator.ONE_OR_MORE) returns the sequence type item()+.
        Parameters:
        occurrenceIndicator - the occurrence indicator to be used
        Returns:
        the corresponding sequence type
      • one

        public SequenceType one()
        Combine the item type with the occurrence indicator "exactly one" to form a sequence type.
        Returns:
        the result of with(OccurrenceIndicator.ONE)
      • oneOrMore

        public SequenceType oneOrMore()
        Combine the item type with the occurrence indicator "one or more" (+) to form a sequence type.
        Returns:
        the result of with(OccurrenceIndicator.ONE_OR_MORE)
      • zeroOrMore

        public SequenceType zeroOrMore()
        Combine the item type with the occurrence indicator "zero or more" (*) to form a sequence type.
        Returns:
        the result of with(OccurrenceIndicator.ZERO_OR_MORE)
      • zeroOrOne

        public SequenceType zeroOrOne()
        Combine the item type with the occurrence indicator "zero or one" (?) to form a sequence type.
        Returns:
        the result of with(OccurrenceIndicator.ZERO_OR_ONE)
      • getConversionRules

        public ConversionRules getConversionRules()
        Get the conversion rules implemented by this type. The conversion rules reflect variations between different versions of the W3C specifications, for example XSD 1.1 allows "+INF" as a lexical representation of xs:double, while XSD 1.0 does not.
        Returns:
        the conversion rules
      • test

        public boolean test​(XdmItem item)
        Determine whether this item type matches a given item. This is a synonym of the matches(net.sf.saxon.s9api.XdmItem) method, provided so that an ItemType can be used as a Predicate.
        Specified by:
        test in interface java.util.function.Predicate<XdmItem>
        Parameters:
        item - the item to be tested against this item type
        Returns:
        true if the item matches this item type, false if it does not match.
      • matches

        public abstract boolean matches​(XdmItem item)
        Determine whether this item type matches a given item.
        Parameters:
        item - the item to be tested against this item type
        Returns:
        true if the item matches this item type, false if it does not match.
      • subsumes

        public abstract boolean subsumes​(ItemType other)
        Determine whether this ItemType subsumes another ItemType. Specifically, A.subsumes(B) is true if every value that matches the ItemType B also matches the ItemType A.
        Parameters:
        other - the other ItemType
        Returns:
        true if this ItemType subsumes the other ItemType. This includes the case where A and B represent the same ItemType.
        Since:
        9.1
      • getUnderlyingItemType

        public ItemType getUnderlyingItemType()
        Method to get the underlying Saxon implementation object

        This gives access to Saxon methods that may change from one release to another.

        Returns:
        the underlying Saxon implementation object
      • getTypeName

        public QName getTypeName()
        Get the name of the type, if it has one
        Returns:
        the name of the type, or null if it is either an anonymous schema-defined type, or an XDM-defined type such as node() or map().
        Since:
        9.7
      • equals

        public final boolean equals​(java.lang.Object other)
        Test whether two ItemType objects represent the same type
        Overrides:
        equals in class java.lang.Object
        Parameters:
        other - the other ItemType object
        Returns:
        true if the other object is an ItemType representing the same type
        Since:
        9.5
      • hashCode

        public final int hashCode()
        Get a hash code with semantics corresponding to the equals() method
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        the hash code
        Since:
        9.5
      • toString

        public java.lang.String toString()
        Get a string representation of the type. This will be generally a string that conforms to the XPath ItemType production, for example a QName, or a construct such as "node()" or "map(*)".

        QNames are generally in EQName (Q{uri}local) format, except that the prefix xs: is used for the XML Schema namespace.

        If the type is an anonymous schema type, the name of the nearest named base type will be given, preceded by the character "<".

        In the case of a function item type, the returned string will be in parentheses (for example (function() as xs:string)) so that an occurrence indicator can be added without ambiguity.

        Overrides:
        toString in class java.lang.Object
        Returns:
        a string representation of the type
        Since:
        9.7