Class UType

java.lang.Object
net.sf.saxon.type.UType

public class UType extends Object
A UType is a union of primitive (atomic, node, or function) item types. It is represented as a simple integer, with bits representing which of the primitive types are present in the union.
  • Field Details

    • VOID

      public static final UType VOID
    • DOCUMENT

      public static final UType DOCUMENT
    • ELEMENT

      public static final UType ELEMENT
    • ATTRIBUTE

      public static final UType ATTRIBUTE
    • TEXT

      public static final UType TEXT
    • COMMENT

      public static final UType COMMENT
    • PI

      public static final UType PI
    • NAMESPACE

      public static final UType NAMESPACE
    • FUNCTION

      public static final UType FUNCTION
    • STRING

      public static final UType STRING
    • BOOLEAN

      public static final UType BOOLEAN
    • DECIMAL

      public static final UType DECIMAL
    • FLOAT

      public static final UType FLOAT
    • DOUBLE

      public static final UType DOUBLE
    • DURATION

      public static final UType DURATION
    • DATE_TIME

      public static final UType DATE_TIME
    • TIME

      public static final UType TIME
    • DATE

      public static final UType DATE
    • G_YEAR_MONTH

      public static final UType G_YEAR_MONTH
    • G_YEAR

      public static final UType G_YEAR
    • G_MONTH_DAY

      public static final UType G_MONTH_DAY
    • G_DAY

      public static final UType G_DAY
    • G_MONTH

      public static final UType G_MONTH
    • HEX_BINARY

      public static final UType HEX_BINARY
    • BASE64_BINARY

      public static final UType BASE64_BINARY
    • ANY_URI

      public static final UType ANY_URI
    • QNAME

      public static final UType QNAME
    • NOTATION

      public static final UType NOTATION
    • UNTYPED_ATOMIC

      public static final UType UNTYPED_ATOMIC
    • EXTENSION

      public static final UType EXTENSION
    • NUMERIC

      public static final UType NUMERIC
    • STRING_LIKE

      public static final UType STRING_LIKE
    • CHILD_NODE_KINDS

      public static final UType CHILD_NODE_KINDS
    • PARENT_NODE_KINDS

      public static final UType PARENT_NODE_KINDS
    • ELEMENT_OR_ATTRIBUTE

      public static final UType ELEMENT_OR_ATTRIBUTE
    • ANY_NODE

      public static final UType ANY_NODE
    • ANY_ATOMIC

      public static final UType ANY_ATOMIC
    • ANY

      public static final UType ANY
  • Constructor Details

    • UType

      public UType(int bits)
  • Method Details

    • hashCode

      public int hashCode()
      Returns a hash code value for the object.
      Overrides:
      hashCode in class Object
      Returns:
      a hash code value for this object.
      See Also:
    • equals

      public boolean equals(Object obj)
      Indicates whether some other object is "equal to" this one.
      Overrides:
      equals in class Object
      Parameters:
      obj - the reference object with which to compare.
      Returns:
      true if this object is the same as the obj argument; false otherwise.
      See Also:
    • union

      public UType union(UType other)
      Form a UType as the union of two other UTypes
      Parameters:
      other - the other UType
      Returns:
      the UType representing the union of this UType and the other UType
    • intersection

      public UType intersection(UType other)
    • except

      public UType except(UType other)
    • fromTypeCode

      public static UType fromTypeCode(int code)
    • decompose

      public Set<PrimitiveUType> decompose()
      Get a set containing all the primitive types in this UType
      Returns:
      a set of PrimitiveUTypes each of which represents exactly one primitive type
    • toString

      public String toString()
      Produce a string representation of a UType
      Overrides:
      toString in class Object
      Returns:
      the string representation
    • toStringWithIndefiniteArticle

      public String toStringWithIndefiniteArticle()
    • overlaps

      public boolean overlaps(UType other)
      Determine whether two UTypes have overlapping membership
      Parameters:
      other - the second UType
      Returns:
      true if the intersection between the two UTypes is non-empty
    • subsumes

      public boolean subsumes(UType other)
      Ask whether one UType subsumes another
      Parameters:
      other - the second UType
      Returns:
      true if every item type allowed by this UType is also allowed by the other item type
    • toItemType

      public ItemType toItemType()
      Obtain (that is, create or get) an itemType that matches all items whose primitive type is one of the types present in this UType.
      Returns:
      a corresponding ItemType
    • matches

      public boolean matches(Item item)
      Ask whether a given Item is an instance of this UType
      Parameters:
      item - the item to be tested
      Returns:
      true if this UType matches the supplied item
    • getUType

      public static UType getUType(Item item)
      Get the UType of an Item
      Parameters:
      item - the item whose UType is required
      Returns:
      the UType of the item
    • getUType

      public static UType getUType(GroundedValue sequence)
      Get the UType of a Sequence
      Parameters:
      sequence - the sequence whose UType is required
      Returns:
      the UType of the item
    • isPossiblyComparable

      public static boolean isPossiblyComparable(UType t1, UType t2, boolean ordered)
      Determine whether two primitive atomic types are comparable under the rules for ValueComparisons (that is, untyped atomic values treated as strings)
      Parameters:
      t1 - the first type to compared. This must be a primitive atomic type as defined by ItemType.getPrimitiveType()
      t2 - the second type to compared. This must be a primitive atomic type as defined by ItemType.getPrimitiveType()
      ordered - true if testing for an ordering comparison (lt, gt, le, ge). False if testing for an equality comparison (eq, ne)
      Returns:
      true if the types are guaranteed comparable, as defined by the rules of the "eq" operator, or if we don't yet know (because some subtypes of the static type are comparable and others are not). False if they are definitely not comparable.
    • isGuaranteedComparable

      public static boolean isGuaranteedComparable(UType t1, UType t2)
      Determine whether two primitive atomic types are comparable under the rules for ValueComparisons (that is, untyped atomic values treated as strings), using the "eq" operator
      Parameters:
      t1 - the first type to compared. This must be a primitive atomic type as defined by ItemType.getPrimitiveType()
      t2 - the second type to compared. This must be a primitive atomic type as defined by ItemType.getPrimitiveType()
      Returns:
      true if the types are comparable, as defined by the rules of the "eq" operator; false if they are not comparable, or if we don't yet know (because some subtypes of the static type are comparable and others are not)
    • isGenerallyComparable

      public static boolean isGenerallyComparable(UType t1, UType t2)
      Determine whether two primitive atomic types are comparable under the rules for GeneralComparisons for the "=" operator (that is, untyped atomic values treated as comparable to anything)
      Parameters:
      t1 - the first type to compared. This must be a primitive atomic type as defined by ItemType.getPrimitiveType()
      t2 - the second type to compared. This must be a primitive atomic type as defined by ItemType.getPrimitiveType()
      Returns:
      true if the types are comparable, as defined by the rules of the "=" operator