Package net.sf.saxon.type
Class UType
- java.lang.Object
-
- net.sf.saxon.type.UType
-
public class UType extends java.lang.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 Summary
Fields Modifier and Type Field Description static UType
ANY
static UType
ANY_ATOMIC
static UType
ANY_NODE
static UType
ANY_URI
static UType
ATTRIBUTE
static UType
BASE64_BINARY
static UType
BOOLEAN
static UType
CHILD_NODE_KINDS
static UType
COMMENT
static UType
DATE
static UType
DATE_TIME
static UType
DECIMAL
static UType
DOCUMENT
static UType
DOUBLE
static UType
DURATION
static UType
ELEMENT
static UType
ELEMENT_OR_ATTRIBUTE
static UType
EXTENSION
static UType
FLOAT
static UType
FUNCTION
static UType
G_DAY
static UType
G_MONTH
static UType
G_MONTH_DAY
static UType
G_YEAR
static UType
G_YEAR_MONTH
static UType
HEX_BINARY
static UType
NAMESPACE
static UType
NOTATION
static UType
NUMERIC
static UType
PARENT_NODE_KINDS
static UType
PI
static UType
QNAME
static UType
STRING
static UType
STRING_LIKE
static UType
TEXT
static UType
TIME
static UType
UNTYPED_ATOMIC
static UType
VOID
-
Constructor Summary
Constructors Constructor Description UType(int bits)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Set<PrimitiveUType>
decompose()
Get a set containing all the primitive types in this UTypeboolean
equals(java.lang.Object obj)
Indicates whether some other object is "equal to" this one.UType
except(UType other)
static UType
fromTypeCode(int code)
static UType
getUType(GroundedValue sequence)
Get the UType of a Sequencestatic UType
getUType(Item item)
Get the UType of an Itemint
hashCode()
Returns a hash code value for the object.UType
intersection(UType other)
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)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" operatorstatic 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)boolean
matches(Item item)
Ask whether a given Item is an instance of this UTypeboolean
overlaps(UType other)
Determine whether two UTypes have overlapping membershipboolean
subsumes(UType other)
Ask whether one UType subsumes anotherItemType
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.java.lang.String
toString()
Produce a string representation of a UTypejava.lang.String
toStringWithIndefiniteArticle()
UType
union(UType other)
Form a UType as the union of two other UTypes
-
-
-
Field Detail
-
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
-
-
Method Detail
-
hashCode
public int hashCode()
Returns a hash code value for the object.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- a hash code value for this object.
- See Also:
Object.equals(Object)
,Hashtable
-
equals
public boolean equals(java.lang.Object obj)
Indicates whether some other object is "equal to" this one.- Overrides:
equals
in classjava.lang.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:
hashCode()
,Hashtable
-
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
-
fromTypeCode
public static UType fromTypeCode(int code)
-
decompose
public java.util.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 java.lang.String toString()
Produce a string representation of a UType- Overrides:
toString
in classjava.lang.Object
- Returns:
- the string representation
-
toStringWithIndefiniteArticle
public java.lang.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 byItemType.getPrimitiveType()
t2
- the second type to compared. This must be a primitive atomic type as defined byItemType.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 byItemType.getPrimitiveType()
t2
- the second type to compared. This must be a primitive atomic type as defined byItemType.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 byItemType.getPrimitiveType()
t2
- the second type to compared. This must be a primitive atomic type as defined byItemType.getPrimitiveType()
- Returns:
- true if the types are comparable, as defined by the rules of the "=" operator
-
-