Package net.sf.saxon.ma.arrays
Class ArrayItemType
- java.lang.Object
-
- net.sf.saxon.type.AnyFunctionType
-
- net.sf.saxon.ma.arrays.ArrayItemType
-
- All Implemented Interfaces:
FunctionItemType,ItemType
public class ArrayItemType extends AnyFunctionType
An instance of this class represents a specific array item type, for example function(xs:int) as xs:boolean
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.sf.saxon.type.ItemType
ItemType.WithSequenceTypeCache
-
-
Field Summary
Fields Modifier and Type Field Description static ArrayItemTypeANY_ARRAY_TYPEstatic SequenceTypeSINGLE_ARRAY-
Fields inherited from class net.sf.saxon.type.AnyFunctionType
ANY_FUNCTION
-
-
Constructor Summary
Constructors Constructor Description ArrayItemType(SequenceType memberType)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object other)Test whether this array type equals another array typeOptional<String>explainMismatch(Item item, TypeHierarchy th)Get extra diagnostic information about why a supplied item does not conform to this item type, if available.StringgenerateJavaScriptItemTypeTest(ItemType knownToBe, int targetVersion)Generate Javascript code to test whether an item conforms to this item typeStringgetAlphaCode()Get an alphabetic code representing the type, or at any rate, the nearest built-in type from which this type is derived.SequenceType[]getArgumentTypes()Get the argument types of this array, viewed as a functionintgetArity()Get the arity (number of arguments) of this function typePlainTypegetAtomizedItemType()Get the item type of the atomic values that will be produced when an item of this type is atomizedGenregetGenre()Determine the Genre (top-level classification) of this typeSequenceTypegetMemberType()Get the type of the members of the arraySequenceTypegetResultType()Get the result type of this array, viewed as a functioninthashCode()Returns a hash code value for the object.booleanisArrayType()Ask whether this function item type is an array type.booleanisAtomizable(TypeHierarchy th)Ask whether values of this type are atomizablebooleanisMapType()Ask whether this function item type is a map type.ExpressionmakeFunctionSequenceCoercer(Expression exp, RoleDiagnostic role)Create an expression whose effect is to apply function coercion to coerce a function from this type to another typebooleanmatches(Item item, TypeHierarchy th)Test whether a given item conforms to this typeintrelationship(FunctionItemType other, TypeHierarchy th)Determine the relationship of one function item type to anotherStringtoExportString()Return a string representation of this ItemType suitable for use in stylesheet export files.StringtoString()Produce a representation of this type name for use in error messages.-
Methods inherited from class net.sf.saxon.type.AnyFunctionType
generateJavaScriptItemTypeAcceptor, getAnnotationAssertions, getInstance, getPrimitiveItemType, getPrimitiveType, getUType, isAtomicType, isPlainType
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.sf.saxon.type.ItemType
isTrueItemType
-
-
-
-
Field Detail
-
ANY_ARRAY_TYPE
public static final ArrayItemType ANY_ARRAY_TYPE
-
SINGLE_ARRAY
public static final SequenceType SINGLE_ARRAY
-
-
Constructor Detail
-
ArrayItemType
public ArrayItemType(SequenceType memberType)
-
-
Method Detail
-
getGenre
public Genre getGenre()
Determine the Genre (top-level classification) of this type- Returns:
- the Genre to which this type belongs, specifically
Genre.ARRAY
-
getMemberType
public SequenceType getMemberType()
Get the type of the members of the array- Returns:
- the type to which all members of the array must conform
-
isMapType
public boolean isMapType()
Ask whether this function item type is a map type. In this case function coercion (to the map type) will never succeed.- Specified by:
isMapTypein interfaceFunctionItemType- Overrides:
isMapTypein classAnyFunctionType- Returns:
- true if this FunctionItemType is a map type
-
isArrayType
public boolean isArrayType()
Ask whether this function item type is an array type. In this case function coercion (to the array type) will never succeed.- Specified by:
isArrayTypein interfaceFunctionItemType- Overrides:
isArrayTypein classAnyFunctionType- Returns:
- true if this FunctionItemType is an array type
-
getAlphaCode
public String getAlphaCode()
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:
getAlphaCodein interfaceItemType- Overrides:
getAlphaCodein classAnyFunctionType- Returns:
- the alphacode for the nearest containing built-in type
-
isAtomizable
public boolean isAtomizable(TypeHierarchy th)
Ask whether values of this type are atomizable- Specified by:
isAtomizablein interfaceItemType- Overrides:
isAtomizablein classAnyFunctionType- Parameters:
th- The type hierarchy cache- Returns:
- true unless it is known that these items will be elements with element-only content, in which case return false
-
getAtomizedItemType
public PlainType getAtomizedItemType()
Get the item type of the atomic values that will be produced when an item of this type is atomized- Specified by:
getAtomizedItemTypein interfaceItemType- Overrides:
getAtomizedItemTypein classAnyFunctionType- Returns:
- the item type of the atomic values that will be produced when an item of this type is atomized
-
getArity
public int getArity()
Get the arity (number of arguments) of this function type- Returns:
- the number of argument types in the function signature
-
getArgumentTypes
public SequenceType[] getArgumentTypes()
Get the argument types of this array, viewed as a function- Specified by:
getArgumentTypesin interfaceFunctionItemType- Overrides:
getArgumentTypesin classAnyFunctionType- Returns:
- the list of argument types of this array, viewed as a function
-
matches
public boolean matches(Item item, TypeHierarchy th) throws XPathException
Test whether a given item conforms to this type- Specified by:
matchesin interfaceItemType- Overrides:
matchesin classAnyFunctionType- Parameters:
item- The item to be testedth- The type hierarchy cache- Returns:
- true if the item is an instance of this type; false otherwise
- Throws:
XPathException
-
getResultType
public SequenceType getResultType()
Get the result type of this array, viewed as a function- Specified by:
getResultTypein interfaceFunctionItemType- Overrides:
getResultTypein classAnyFunctionType- Returns:
- the result type of this array, viewed as a function
-
toString
public String toString()
Produce a representation of this type name for use in error messages.- Specified by:
toStringin interfaceItemType- Overrides:
toStringin classAnyFunctionType- Returns:
- a string representation of the type, in notation resembling but not necessarily identical to XPath syntax
-
toExportString
public String toExportString()
Return 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().- Returns:
- the string representation as an instance of the XPath SequenceType construct
-
equals
public boolean equals(Object other)
Test whether this array type equals another array type
-
hashCode
public int hashCode()
Returns a hash code value for the object.
-
relationship
public int relationship(FunctionItemType other, TypeHierarchy th)
Determine the relationship of one function item type to another- Specified by:
relationshipin interfaceFunctionItemType- Overrides:
relationshipin classAnyFunctionType- Returns:
- for example
TypeHierarchy.SUBSUMES,TypeHierarchy.SAME_TYPE
-
makeFunctionSequenceCoercer
public Expression makeFunctionSequenceCoercer(Expression exp, RoleDiagnostic role) throws XPathException
Description copied from class:AnyFunctionTypeCreate an expression whose effect is to apply function coercion to coerce a function from this type to another type- Specified by:
makeFunctionSequenceCoercerin interfaceFunctionItemType- Overrides:
makeFunctionSequenceCoercerin classAnyFunctionType- Parameters:
exp- the expression that delivers the supplied sequence of function items (the ones in need of coercion)role- information for use in diagnostics- Returns:
- the sequence of coerced functions, each on a function that calls the corresponding original function after checking the parameters
- Throws:
XPathException
-
explainMismatch
public Optional<String> explainMismatch(Item item, TypeHierarchy th)
Get 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.- 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
-
generateJavaScriptItemTypeTest
public String generateJavaScriptItemTypeTest(ItemType knownToBe, int targetVersion) throws XPathException
Generate Javascript code to test whether an item conforms to this item type- Specified by:
generateJavaScriptItemTypeTestin interfaceItemType- Overrides:
generateJavaScriptItemTypeTestin classAnyFunctionType- Parameters:
knownToBe- a type that this item is known to conform totargetVersion- the version of Saxon-JS SEF format- Returns:
- a Javascript instruction or sequence of instructions, which can be used as the body of a Javascript function, and which returns a boolean indication whether the value of the variable "item" is an instance of this item type.
- Throws:
XPathException- if JS code cannot be generated for this item type, for example because the test is schema-aware.
-
-