Package net.sf.saxon.ma.map
Class SelfReferenceRecordTest
java.lang.Object
net.sf.saxon.type.AnyFunctionType
net.sf.saxon.ma.map.SelfReferenceRecordTest
- All Implemented Interfaces:
RecordType,FunctionItemType,ItemType
An instance of this class represents a self-reference within a record type, that is the ".."
construct in a record test such as
record(data as xs:string, next? as ..).
It contains a reference to the containing record type, and delegates matching operations
to the containing type, but needs to handle operations differently such as conversion to a string
or alpha-code, or comparison of item types for equality, to avoid going into infinite recursion.-
Field Summary
Fields inherited from class net.sf.saxon.type.AnyFunctionType
ANY_FUNCTION -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanTest whether this function type equals another function typeGet the argument types of this map, viewed as a functionintgetArity()Get the arity (number of arguments) of this function typeGet an alphabetic code representing the type, or at any rate, the nearest built-in type from which this type is derived.doubleGet the default priority when this ItemType is used as an XSLT patternGet the names of all the fieldsgetFieldType(String field) Get the type of a given fieldgetGenre()Determine the Genre (top-level classification) of this typeGet the result type of this record type, viewed as a functioninthashCode()Returns a hash code value for the object.booleanAsk whether this function item type is an array type.booleanAsk whether the record type is extensible, that is, whether fields other than those named are permittedbooleanAsk whether this function item type is a map type.booleanisOptionalField(String field) Ask whether a given field is optionalmakeFunctionSequenceCoercer(Expression exp, Supplier<RoleDiagnostic> role, boolean allow40) 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 typerelationship(FunctionItemType other, TypeHierarchy th) Determine the relationship of one function item type to anotherReturn a string representation of this ItemType suitable for use in stylesheet export files.toString()Produce a representation of this type name for use in error messages.Methods inherited from class net.sf.saxon.type.AnyFunctionType
getAnnotationAssertions, getAtomizedItemType, getInstance, getPrimitiveItemType, getPrimitiveType, getUType, isAtomicType, isAtomizable, isPlainTypeMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface net.sf.saxon.type.FunctionItemType
getAnnotationAssertionsMethods inherited from interface net.sf.saxon.type.ItemType
explainMismatch, getAtomizedItemType, getFullAlphaCode, getNormalizedDefaultPriority, getPrimitiveItemType, getPrimitiveType, getUType, isAtomicType, isAtomizable, isPlainType
-
Constructor Details
-
SelfReferenceRecordTest
Construct a RecordTest- Parameters:
containingType- the record test containing the self-reference
-
-
Method Details
-
getGenre
Determine the Genre (top-level classification) of this type- Specified by:
getGenrein interfaceFunctionItemType- Specified by:
getGenrein interfaceItemType- Returns:
- the Genre to which this type belongs, specifically
Genre.MAP
-
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
-
getFieldNames
Get the names of all the fields- Specified by:
getFieldNamesin interfaceRecordType- Returns:
- the names of the fields (in arbitrary order)
-
getFieldType
Get the type of a given field- Specified by:
getFieldTypein interfaceRecordType- Parameters:
field- the name of the field- Returns:
- the type of the field if it is defined, or null otherwise
-
isOptionalField
Ask whether a given field is optional- Specified by:
isOptionalFieldin interfaceRecordType- Parameters:
field- the name of the field- Returns:
- true if the field is defined as an optional field
-
isExtensible
public boolean isExtensible()Ask whether the record type is extensible, that is, whether fields other than those named are permitted- Specified by:
isExtensiblein interfaceRecordType- Returns:
- true if fields other than the named fields are permitted to appear
-
matches
Test whether a given item conforms to this type- Specified by:
matchesin interfaceItemType- Overrides:
matchesin classAnyFunctionType- Parameters:
item- The item to be testedth- type hierarchy data- Returns:
- true if the item is an instance of this type; false otherwise
-
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
Get the argument types of this map, viewed as a function- Specified by:
getArgumentTypesin interfaceFunctionItemType- Overrides:
getArgumentTypesin classAnyFunctionType- Returns:
- the list of argument types of this map, viewed as a function
-
getResultType
Get the result type of this record type, viewed as a function- Specified by:
getResultTypein interfaceFunctionItemType- Overrides:
getResultTypein classAnyFunctionType- Returns:
- the result type of this record type, viewed as a function
-
getDefaultPriority
public double getDefaultPriority()Get the default priority when this ItemType is used as an XSLT pattern- Specified by:
getDefaultPriorityin interfaceItemType- Overrides:
getDefaultPriorityin classAnyFunctionType- Returns:
- the default priority
-
toString
Produce a representation of this type name for use in error messages.- Overrides:
toStringin classAnyFunctionType- Returns:
- a string representation of the type, in notation resembling but not necessarily identical to XPath syntax
-
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 record types.- Specified by:
toExportStringin interfaceItemType- Returns:
- the string representation as an instance of the XPath ItemType construct
-
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- Overrides:
getBasicAlphaCodein classAnyFunctionType- Returns:
- the alphacode for the nearest containing built-in type
-
equals
Test whether this function type equals another function type -
hashCode
public int hashCode()Returns a hash code value for the object. -
relationship
Determine the relationship of one function item type to another- Specified by:
relationshipin interfaceFunctionItemType- Overrides:
relationshipin classAnyFunctionType- Parameters:
other- the other function item typeth- the type hierarchy cache- Returns:
- for example
Affinity.SUBSUMES,Affinity.SAME_TYPE
-
makeFunctionSequenceCoercer
public Expression makeFunctionSequenceCoercer(Expression exp, Supplier<RoleDiagnostic> role, boolean allow40) 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 diagnosticsallow40-- Returns:
- the sequence of coerced functions, each on a function that calls the corresponding original function after checking the parameters
- Throws:
XPathException- if an error is detected
-