Class LastItemExpression

  • All Implemented Interfaces:
    ExportAgent, Locatable, IdentityComparable, Traceable

    public final class LastItemExpression
    extends SingleItemFilter
    A LastItemExpression returns the last item in the sequence returned by a given base expression. The evaluation strategy is to read the input sequence with a one-item lookahead.
    • Constructor Detail

      • LastItemExpression

        public LastItemExpression​(Expression base)
        Constructor
        Parameters:
        base - A sequence expression denoting sequence whose first item is to be returned
    • Method Detail

      • copy

        public Expression copy​(RebindingMap rebindings)
        Copy an expression. This makes a deep copy.
        Specified by:
        copy in class Expression
        Parameters:
        rebindings - variables that need to be re-bound
        Returns:
        the copy of the original expression
      • getImplementationMethod

        public int getImplementationMethod()
        An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process(). This method indicates which of these methods is provided directly. The other methods will always be available indirectly, using an implementation that relies on one of the other methods.
        Specified by:
        getImplementationMethod in class Expression
        Returns:
        the implementation method, for example Expression.ITERATE_METHOD or Expression.EVALUATE_METHOD or Expression.PROCESS_METHOD
      • evaluateItem

        public Item evaluateItem​(XPathContext context)
                          throws XPathException
        Evaluate the expression
        Overrides:
        evaluateItem in class Expression
        Parameters:
        context - The context in which the expression is to be evaluated
        Returns:
        the node or atomic value that results from evaluating the expression; or null to indicate that the result is an empty sequence
        Throws:
        XPathException - if any dynamic error occurs evaluating the expression
      • getExpressionName

        public java.lang.String getExpressionName()
        Description copied from class: Expression
        Get a name identifying the kind of expression, in terms meaningful to a user.
        Overrides:
        getExpressionName in class Expression
        Returns:
        a name identifying the kind of expression, in terms meaningful to a user. The name will always be in the form of a lexical XML QName, and should match the name used in export() output displaying the expression.
      • getElaborator

        public Elaborator getElaborator()
        Make an elaborator for this expression
        Overrides:
        getElaborator in class Expression
        Returns:
        a suitable elaborator
      • getLast

        public static Item getLast​(SequenceIterator iter)
        Get the last item delivered by an iterator, or null if the iterator is empty
        Parameters:
        iter - the supplied iterator (which may or may not be consumed)
        Returns:
        the last item returned by the iterator, or null if there are none.