Package net.sf.saxon.type
Class ChoiceItemType
java.lang.Object
net.sf.saxon.type.ChoiceItemType
- All Implemented Interfaces:
ChoiceType,ItemType
- Direct Known Subclasses:
LocalUnionType
A class that represents a union type declared locally, for example using
the XPath 4.0 choice item-type syntax (a|b|c), or internally in Java code.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ChoiceItemTypestatic final ChoiceItemTypestatic final ChoiceItemTypestatic final ChoiceItemType -
Constructor Summary
ConstructorsConstructorDescriptionChoiceItemType(List<? extends ItemType> memberTypes) Creates a new ChoiceItemType. -
Method Summary
Modifier and TypeMethodDescriptionExpand this item type to a choice item type.eliminating(Predicate<? super ItemType> condition) Return an item type that eliminates one (or more) of the alternativesbooleanIndicates whether some other object is "equal to" this one.expand()explainMismatch(Item item, TypeHierarchy th) Get extra diagnostic information about why a supplied item does not conform to this item type, if available.Get the alternative types available within this choice typesGet the item type of the atomic values that will be produced when an item of this type is atomizedGet an alphabetic code representing the type, or at any rate, the nearest built-in type from which this type is derived.getCoercionPlan(int version) Get the coercion plan for use when this type is the required type for (say) coercion of arguments in a function calldoubleGet the default priority when this ItemType is used as an XSLT patterngetGenre()Get the genre of this item typeGet the alternative member types as a listMethod defined in ItemType: get a primitive supertype in the ItemType type hierarchyintMethod defined in ItemType: get a primitive supertype in the ItemType type hierarchygetUType()Get the correspondingUType.inthashCode()booleanAsk whether this Simple Type is an atomic typebooleanAsk whether values of this type are atomizablebooleanDetermine whether this is a built-in type or a user-defined typebooleanDetermine whether this is a list typebooleanAsk whether this Union type is a "plain type", defined as a union type whose member types are all atomic types or plain unions.booleanReturn true if this type is a union type (that is, if its variety is union)static ItemTypemakeChoiceItemType(List<ItemType> memberTypes) booleanTest whether a given item conforms to this typestatic ChoiceItemTypestatic ChoiceItemTypebooleansomeMemberTypeSatisfies(Predicate<? super ItemType> condition) Ask whether there is an alternative in the choice type that satisfies a given conditionReturn a string representation of this ItemType suitable for use in stylesheet export files.Convert, if possible, to a multiple node kind testtoString()Produce a string representation of the type name.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface net.sf.saxon.type.ItemType
getNormalizedDefaultPriority, normalizeItemType
-
Field Details
-
memberTypes
-
CHOICE_OF_ANY
-
CHOICE_OF_GNODE
-
CHOICE_OF_XNODE
-
CHOICE_OF_ATOMIC
-
-
Constructor Details
-
ChoiceItemType
Creates a new ChoiceItemType.- Parameters:
memberTypes- the atomic member types of the union
-
-
Method Details
-
makeChoiceItemType
-
of
-
of
-
getMemberTypes
Get the alternative member types as a list- Returns:
- the alternatives making up this choice type
-
getAlternatives
Description copied from interface:ChoiceTypeGet the alternative types available within this choice types- Specified by:
getAlternativesin interfaceChoiceType- Returns:
- the alternative item types
-
getGenre
Get the genre of this item type -
getDescription
-
isAtomicType
public boolean isAtomicType()Ask whether this Simple Type is an atomic type- Specified by:
isAtomicTypein interfaceItemType- Returns:
- false, this is not an atomic type
-
isPlainType
public boolean isPlainType()Ask whether this Union type is a "plain type", defined as a union type whose member types are all atomic types or plain unions. That is, it disallows unions that are derived by restriction from another union. The significance of this is that an atomic value will never match a non-plain union type- Specified by:
isPlainTypein interfaceItemType- Returns:
- true if this is ANY_ATOMIC_TYPE or a subtype thereof, or a "plain" union type (that is, unions of atomic types that impose no further restrictions). Return false if this is a union type whose member types are not all known.
-
someMemberTypeSatisfies
Ask whether there is an alternative in the choice type that satisfies a given condition- Parameters:
condition- the given condition- Returns:
- true if a matching alternative is found
-
eliminating
Return an item type that eliminates one (or more) of the alternatives- Parameters:
condition- predicate determining which alternatives to drop- Returns:
- an ItemType that eliminates the selected choices
-
isBuiltInType
public boolean isBuiltInType()Determine whether this is a built-in type or a user-defined type -
isListType
public boolean isListType()Determine whether this is a list type -
isUnionType
public boolean isUnionType()Return true if this type is a union type (that is, if its variety is union)- Returns:
- true for a union type
-
getUType
Get the correspondingUType. A UType is a union of primitive item types. -
getBasicAlphaCode
Get an alphabetic code representing the type, or at any rate, the nearest built-in type from which this type is derived. The codes are designed so that for any two built-in types A and B, alphaCode(A) is a prefix of alphaCode(B) if and only if A is a supertype of B.- Specified by:
getBasicAlphaCodein interfaceItemType- Returns:
- the alphacode for the nearest containing built-in type
-
matches
Test whether a given item conforms to this type -
getPrimitiveItemType
Method defined in ItemType: get a primitive supertype in the ItemType type hierarchy- Specified by:
getPrimitiveItemTypein interfaceItemType- Returns:
- BuiltInAtomicType.ANY_ATOMIC
-
toMultipleNodeKindTest
Convert, if possible, to a multiple node kind test- Returns:
- the equivalent
MultipleNodeKindTestor null if there is no equivalent
-
getPrimitiveType
public int getPrimitiveType()Method defined in ItemType: get a primitive supertype in the ItemType type hierarchy- Specified by:
getPrimitiveTypein interfaceItemType- Returns:
- StandardNames.XS_ANY_ATOMIC_TYPE
-
getAtomizedItemType
Description copied from interface:ItemTypeGet the item type of the atomic values that will be produced when an item of this type is atomized- Specified by:
getAtomizedItemTypein interfaceItemType- Returns:
- the best available item type of the atomic values that will be produced when an item of this type is atomized, or null if it is known that atomization will throw an error.
-
isAtomizable
Description copied from interface:ItemTypeAsk whether values of this type are atomizable- Specified by:
isAtomizablein interfaceItemType- Parameters:
th- the type hierarchy cache- Returns:
- true if some or all instances of this type can be successfully atomized; false if no instances of this type can be atomized
-
getDefaultPriority
public double getDefaultPriority()Get the default priority when this ItemType is used as an XSLT pattern- Specified by:
getDefaultPriorityin interfaceItemType- Returns:
- the default priority. For a choice type this is defined as the maximum of the default priorities of the member types.
-
equals
Indicates whether some other object is "equal to" this one. -
hashCode
public int hashCode() -
asChoiceItemType
Description copied from interface:ItemTypeExpand this item type to a choice item type. The default delivers a choice with this type as its only member. Implementations for abstract types return a choice of the corresponding concrete types, for examplenode()expands to a choice of the seven node kinds. The implementation for a choice type that includes abstract member types should expand these recursively.- Specified by:
asChoiceItemTypein interfaceItemType
-
expand
-
toString
Produce a string representation of the type name. If the type is anonymous, an internally-allocated type name will be returned. -
toExportString
Description copied from interface:ItemTypeReturn a string representation of this ItemType suitable for use in stylesheet export files. This differs from the result of toString() in that it will not contain any references to anonymous types. Note that it may also use the Saxon extended syntax for union types and tuple types. The default implementation returns the result of callingtoString().- Specified by:
toExportStringin interfaceItemType- Returns:
- the string representation as an instance of the XPath SequenceType construct
-
getCoercionPlan
Get the coercion plan for use when this type is the required type for (say) coercion of arguments in a function call- Specified by:
getCoercionPlanin interfaceItemType- Parameters:
version- the XPath language version (40 or 31)
-
explainMismatch
Description copied from interface:ItemTypeGet extra diagnostic information about why a supplied item does not conform to this item type, if available. If extra information is returned, it should be in the form of a complete sentence, minus the closing full stop. No information should be returned for obvious cases.- Specified by:
explainMismatchin interfaceItemType- Parameters:
item- the item that doesn't match this typeth- the type hierarchy cache- Returns:
- optionally, a message explaining why the item does not match the type
-