Class IndexedFilterExpression

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

    public final class IndexedFilterExpression
    extends Expression
    An IndexedFilterExpression contains a base expression and a filter predicate. The base expression will always be a local variable reference. The filter will always be a Comparison, and it will have no positional dependencies
    • Constructor Detail

      • IndexedFilterExpression

        public IndexedFilterExpression​(VariableReference start,
                                       ComparisonExpression filter,
                                       boolean indexFirstOperand)
        Constructor
        Parameters:
        start - Variable containing the sequence of items from which the selection will take place.
        filter - An expression defining the filter predicate
        indexFirstOperand - true if the first operand of the filter comparison is to be indexed, false if the second operand is to be indexed
    • Method Detail

      • operands

        public java.lang.Iterable<Operand> operands()
        Get the immediate sub-expressions of this expression, with information about the relationship of each expression to its parent expression. Default implementation works off the results of iterateSubExpressions()

        If the expression is a Callable, then it is required that the order of the operands returned by this function is the same as the order of arguments supplied to the corresponding call() method.

        Overrides:
        operands in class Expression
        Returns:
        an iterator containing the sub-expressions of this expression
      • getItemType

        public ItemType getItemType()
        Get the data type of the items returned
        Specified by:
        getItemType in class Expression
        Returns:
        an integer representing the data type
      • getBaseExpression

        public Expression getBaseExpression()
        Get the underlying expression
        Returns:
        the expression being filtered
      • getUseExpression

        public Expression getUseExpression()
        Get the expression to be indexed
        Returns:
        the "use" expression, the expression that computes the index key for each item in the population
      • getSearchExpression

        public Expression getSearchExpression()
        Get the expression whose value we will be searching for
        Returns:
        the search expression
      • isConvertUntypedToOther

        public boolean isConvertUntypedToOther()
        Ask whether untyped atomic values need to be converted to the type of the other operand
        Returns:
        true if untyped atomic values are converted; false if they are compared as strings
      • getComparer

        public AtomicComparer getComparer()
        Get the comparer used for the comparisons
        Returns:
        the comparer
      • typeCheck

        public Expression typeCheck​(ExpressionVisitor visitor,
                                    ContextItemStaticInfo contextInfo)
                             throws XPathException
        Type-check the expression
        Overrides:
        typeCheck in class Expression
        Parameters:
        visitor - an expression visitor
        contextInfo - information about the static type of the context item
        Returns:
        the expression after type-checking (potentially modified to add run-time checks and/or conversions)
        Throws:
        XPathException - if an error is discovered during this phase (typically a type error)
      • optimize

        public Expression optimize​(ExpressionVisitor visitor,
                                   ContextItemStaticInfo contextItemType)
                            throws XPathException
        Perform optimisation of an expression and its subexpressions.

        This method is called after all references to functions and variables have been resolved to the declaration of the function or variable, and after all type checking has been done.

        Overrides:
        optimize in class Expression
        Parameters:
        visitor - an expression visitor
        contextItemType - the static type of "." at the point where this expression is invoked. The parameter is set to null if it is known statically that the context item will be undefined. If the type of the context item is not known statically, the argument is set to Type.ITEM_TYPE
        Returns:
        the original expression, rewritten if appropriate to optimize execution
        Throws:
        XPathException - if an error is discovered during this phase (typically a type error)
      • 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
      • 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
      • computeCardinality

        public int computeCardinality()
        Get the static cardinality of this expression
        Specified by:
        computeCardinality in class Expression
        Returns:
        the cardinality. The method attempts to determine the case where the filter predicate is guaranteed to select at most one item from the sequence being filtered
      • computeSpecialProperties

        public int computeSpecialProperties()
        Get the static properties of this expression (other than its type). The result is bit-significant. These properties are used for optimizations. In general, if property bit is set, it is true, but if it is unset, the value is unknown.
        Overrides:
        computeSpecialProperties in class Expression
        Returns:
        the static properties of the expression, as a bit-significant value
      • addToPathMap

        public PathMap.PathMapNodeSet addToPathMap​(PathMap pathMap,
                                                   PathMap.PathMapNodeSet pathMapNodeSet)
        Add a representation of this expression to a PathMap. The PathMap captures a map of the nodes visited by an expression in a source tree.
        Overrides:
        addToPathMap in class Expression
        Parameters:
        pathMap - the PathMap to which the expression should be added
        pathMapNodeSet - the PathMapNodeSet to which the paths embodied in this expression should be added
        Returns:
        the pathMapNode representing the focus established by this expression, in the case where this expression is the first operand of a path expression or filter expression
      • equals

        public boolean equals​(java.lang.Object other)
        Is this expression the same as another expression?
        Overrides:
        equals in class Expression
        Parameters:
        other - the expression to be compared with this one
        Returns:
        true if the two expressions are statically equivalent
      • computeHashCode

        public int computeHashCode()
        get HashCode for comparing two expressions
        Overrides:
        computeHashCode in class Expression
        Returns:
        the hash code
      • computeDependencies

        public int computeDependencies()
        Determine which aspects of the context the expression depends on. The result is a bitwise-or'ed value composed from constants such as XPathContext.VARIABLES and XPathContext.CURRENT_NODE
        Overrides:
        computeDependencies in class Expression
        Returns:
        the dependencies
      • getExpressionName

        public java.lang.String getExpressionName()
        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.
      • export

        public void export​(ExpressionPresenter out)
                    throws XPathException
        Diagnostic print of expression structure. The abstract expression tree is written to the supplied output destination.
        Specified by:
        export in interface ExportAgent
        Specified by:
        export in class Expression
        Parameters:
        out - the expression presenter used to display the structure
        Throws:
        XPathException - if the export fails, for example if an expression is found that won't work in the target environment.
      • toShortString

        public java.lang.String toShortString()
        Description copied from class: Expression
        Produce a short string identifying the expression for use in error messages
        Overrides:
        toShortString in class Expression
        Returns:
        a short string, sufficient to identify the expression