Package net.sf.saxon.type
Class UType
- java.lang.Object
-
- net.sf.saxon.type.UType
-
public class UType extends java.lang.ObjectA 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 UTypeANYstatic UTypeANY_ATOMICstatic UTypeANY_NODEstatic UTypeANY_URIstatic UTypeATTRIBUTEstatic UTypeBASE64_BINARYstatic UTypeBOOLEANstatic UTypeCHILD_NODE_KINDSstatic UTypeCOMMENTstatic UTypeDATEstatic UTypeDATE_TIMEstatic UTypeDECIMALstatic UTypeDOCUMENTstatic UTypeDOUBLEstatic UTypeDURATIONstatic UTypeELEMENTstatic UTypeELEMENT_OR_ATTRIBUTEstatic UTypeEXTENSIONstatic UTypeFLOATstatic UTypeFUNCTIONstatic UTypeG_DAYstatic UTypeG_MONTHstatic UTypeG_MONTH_DAYstatic UTypeG_YEARstatic UTypeG_YEAR_MONTHstatic UTypeHEX_BINARYstatic UTypeNAMESPACEstatic UTypeNOTATIONstatic UTypeNUMERICstatic UTypePARENT_NODE_KINDSstatic UTypePIstatic UTypeQNAMEstatic UTypeSTRINGstatic UTypeSTRING_LIKEstatic UTypeTEXTstatic UTypeTIMEstatic UTypeUNTYPED_ATOMICstatic UTypeVOID
-
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 UTypebooleanequals(java.lang.Object obj)Indicates whether some other object is "equal to" this one.UTypeexcept(UType other)static UTypefromTypeCode(int code)static UTypegetUType(GroundedValue sequence)Get the UType of a Sequencestatic UTypegetUType(Item item)Get the UType of an IteminthashCode()Returns a hash code value for the object.UTypeintersection(UType other)static booleanisGenerallyComparable(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 booleanisGuaranteedComparable(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 booleanisPossiblyComparable(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)booleanmatches(Item item)Ask whether a given Item is an instance of this UTypebooleanoverlaps(UType other)Determine whether two UTypes have overlapping membershipbooleansubsumes(UType other)Ask whether one UType subsumes anotherItemTypetoItemType()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.StringtoString()Produce a string representation of a UTypejava.lang.StringtoStringWithIndefiniteArticle()UTypeunion(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:
hashCodein 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:
equalsin classjava.lang.Object- Parameters:
obj- the reference object with which to compare.- Returns:
trueif this object is the same as the obj argument;falseotherwise.- 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:
toStringin 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
-
-