Class SelfReferenceRecordTest

  • All Implemented Interfaces:
    RecordType, FunctionItemType, ItemType

    public class SelfReferenceRecordTest
    extends AnyFunctionType
    implements RecordType
    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.
    • Constructor Detail

      • SelfReferenceRecordTest

        public SelfReferenceRecordTest​(RecordTest containingType)
        Construct a RecordTest
        containingType - the record test containing the self-reference
    • Method Detail

      • 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:
        isMapType in interface FunctionItemType
        isMapType in class AnyFunctionType
        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:
        isArrayType in interface FunctionItemType
        isArrayType in class AnyFunctionType
        true if this FunctionItemType is an array type
      • getFieldNames

        public java.lang.Iterable<java.lang.String> getFieldNames()
        Get the names of all the fields
        Specified by:
        getFieldNames in interface RecordType
        the names of the fields (in arbitrary order)
      • getFieldType

        public SequenceType getFieldType​(java.lang.String field)
        Get the type of a given field
        Specified by:
        getFieldType in interface RecordType
        field - the name of the field
        the type of the field if it is defined, or null otherwise
      • isOptionalField

        public boolean isOptionalField​(java.lang.String field)
        Ask whether a given field is optional
        Specified by:
        isOptionalField in interface RecordType
        field - the name of the field
        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:
        isExtensible in interface RecordType
        true if fields other than the named fields are permitted to appear
      • matches

        public boolean matches​(Item item,
                               TypeHierarchy th)
        Test whether a given item conforms to this type
        Specified by:
        matches in interface ItemType
        matches in class AnyFunctionType
        item - The item to be tested
        th - type hierarchy data
        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
        the number of argument types in the function signature
      • toString

        public java.lang.String toString()
        Produce a representation of this type name for use in error messages.
        toString in class AnyFunctionType
        a string representation of the type, in notation resembling but not necessarily identical to XPath syntax
      • toExportString

        public java.lang.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 record types.
        Specified by:
        toExportString in interface ItemType
        the string representation as an instance of the XPath ItemType construct
      • getBasicAlphaCode

        public java.lang.String 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:
        getBasicAlphaCode in interface ItemType
        getBasicAlphaCode in class AnyFunctionType
        the alphacode for the nearest containing built-in type
      • equals

        public boolean equals​(java.lang.Object other)
        Test whether this function type equals another function type
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Returns a hash code value for the object.
        hashCode in class java.lang.Object
      • makeFunctionSequenceCoercer

        public Expression makeFunctionSequenceCoercer​(Expression exp,
                                                      java.util.function.Supplier<RoleDiagnostic> role,
                                                      boolean allow40)
                                               throws XPathException
        Description copied from class: AnyFunctionType
        Create an expression whose effect is to apply function coercion to coerce a function from this type to another type
        Specified by:
        makeFunctionSequenceCoercer in interface FunctionItemType
        makeFunctionSequenceCoercer in class AnyFunctionType
        exp - the expression that delivers the supplied sequence of function items (the ones in need of coercion)
        role - information for use in diagnostics
        allow40 - true if 4.0 coercions are allowed, such as reducing the arity of the function
        the sequence of coerced functions, each on a function that calls the corresponding original function after checking the parameters
        XPathException - if an error is detected