Class AbstractArrayItem

    • Constructor Detail

      • AbstractArrayItem

        public AbstractArrayItem()
    • Method Detail

      • getOperandRoles

        public OperandRole[] getOperandRoles()
        Get the roles of the arguments, for the purposes of streaming
        Specified by:
        getOperandRoles in interface Function
        Returns:
        an array of OperandRole objects, one for each argument
      • isArray

        public boolean isArray()
        Ask whether this function item is an array
        Specified by:
        isArray in interface Function
        Returns:
        true (it is an array)
      • isMap

        public boolean isMap()
        Ask whether this function item is a map
        Specified by:
        isMap in interface Function
        Returns:
        false (it is not a map)
      • getAnnotations

        public AnnotationList getAnnotations()
        Get the function annotations (as defined in XQuery). Returns an empty list if there are no function annotations.
        Specified by:
        getAnnotations in interface Function
        Returns:
        the function annotations
      • getFunctionName

        public StructuredQName getFunctionName()
        Get the name of the function, or null if it is anonymous
        Specified by:
        getFunctionName in interface Function
        Returns:
        the function name, or null for an anonymous function (which this one is)
      • getDescription

        public java.lang.String getDescription()
        Get a description of this function for use in error messages. For named functions, the description is the function name (as a lexical QName). For others, it might be, for example, "inline function", or "partially-applied ends-with function".
        Specified by:
        getDescription in interface Function
        Returns:
        a description of the function for use in error messages
      • getArity

        public int getArity()
        Get the arity of the function
        Specified by:
        getArity in interface Function
        Returns:
        the number of arguments in the function signature (in this case, 1 (one))
      • makeNewContext

        public XPathContext makeNewContext​(XPathContext callingContext,
                                           ContextOriginator originator)
        Prepare an XPathContext object for evaluating the function
        Specified by:
        makeNewContext in interface Function
        Parameters:
        callingContext - the XPathContext of the function calling expression
        originator -
        Returns:
        a suitable context for evaluating the function (which may or may not be the same as the caller's context)
      • call

        public GroundedValue call​(XPathContext context,
                                  Sequence[] args)
                           throws XPathException
        Invoke the array in its role as a function
        Specified by:
        call in interface Callable
        Specified by:
        call in interface Function
        Parameters:
        context - the XPath dynamic evaluation context
        args - the actual arguments to be supplied (a single integer, one-based)
        Returns:
        the result of invoking the function
        Throws:
        XPathException - if the index is out of bounds
      • deepEquals

        public boolean deepEquals​(Function other,
                                  XPathContext context,
                                  AtomicComparer comparer,
                                  int flags)
                           throws XPathException
        Test whether this array is deep-equal to another array, under the rules of the deep-equal function
        Specified by:
        deepEquals in interface Function
        Parameters:
        other - the other function item
        context - the dynamic evaluation context
        comparer - the object to perform the comparison
        flags - options for how the comparison is performed
        Returns:
        true if the two array items are deep-equal; false if they are not deep equal or if the other item is not an array
        Throws:
        XPathException - if the comparison cannot be performed
      • effectiveBooleanValue

        public boolean effectiveBooleanValue()
                                      throws XPathException
        Get the effective boolean value of this sequence
        Specified by:
        effectiveBooleanValue in interface GroundedValue
        Returns:
        the effective boolean value
        Throws:
        XPathException - if the sequence has no effective boolean value (for example a sequence of two integers)
      • getStringValue

        public java.lang.String getStringValue()
        Get the value of the item as a string. For arrays, there is no string value, so an exception is thrown.
        Specified by:
        getStringValue in interface GroundedValue
        Specified by:
        getStringValue in interface Item
        Returns:
        the string value of the item
        Throws:
        java.lang.UnsupportedOperationException - if the item is an array (an unchecked exception is used here to avoid introducing exception handling to a large number of paths where it is not needed)
        Since:
        8.4
        See Also:
        getStringValueCS()
      • getStringValueCS

        public java.lang.CharSequence getStringValueCS()
        Get the value of the item as a CharSequence. For arrays, there is no string value, so an exception is thrown.
        Specified by:
        getStringValueCS in interface GroundedValue
        Specified by:
        getStringValueCS in interface Item
        Returns:
        the string value of the item
        Throws:
        java.lang.UnsupportedOperationException - if the item is an array (an unchecked exception is used here to avoid introducing exception handling to a large number of paths where it is not needed)
        Since:
        8.4
        See Also:
        getStringValueCS()
      • isTrustedResultType

        public boolean isTrustedResultType()
        Description copied from interface: Function
        Check that result type is of the trusted system functions to return a result of the correct type
        Specified by:
        isTrustedResultType in interface Function
      • toString

        public java.lang.String toString()
        Output a string representation of the array, suitable for diagnostics
        Overrides:
        toString in class java.lang.Object
      • getMemberType

        public SequenceType getMemberType​(TypeHierarchy th)
        Get the lowest common item type of the members of the array
        Specified by:
        getMemberType in interface ArrayItem
        Returns:
        the most specific type to which all the members belong.