Class SingletonIntersectExpression

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

    public class SingletonIntersectExpression
    extends VennExpression
    This expression is equivalent to (A intersect B) in the case where A has cardinality zero-or-one. This is handled as a special case because the standard sort-merge algorithm involves an unnecessary sort on B.
    • Constructor Detail

      • SingletonIntersectExpression

        public SingletonIntersectExpression​(Expression p1,
                                            int op,
                                            Expression p2)
        Special case of an intersect expression where the first argument is a singleton
        Parameters:
        p1 - the first argument, always a singleton
        op - the operator, always Token.INTERSECT
        p2 - the second argument
    • Method Detail

      • simplify

        public Expression simplify()
                            throws XPathException
        Simplify the expression
        Overrides:
        simplify in class VennExpression
        Returns:
        the simplified expression (or the original if unchanged, or if modified in-situ)
        Throws:
        XPathException - if an error is discovered during expression rewriting
      • 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 VennExpression
        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)
      • copy

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

        public SequenceIterator iterate​(XPathContext c)
                                 throws XPathException
        Iterate over the value of the expression. The result will always be sorted in document order, with duplicates eliminated
        Overrides:
        iterate in class VennExpression
        Parameters:
        c - The context for evaluation
        Returns:
        a SequenceIterator representing the union of the two operands
        Throws:
        XPathException - if any dynamic error occurs evaluating the expression
      • effectiveBooleanValue

        public boolean effectiveBooleanValue​(XPathContext c)
                                      throws XPathException
        Get the effective boolean value. In the case of a union expression, this is reduced to an OR expression, for efficiency
        Overrides:
        effectiveBooleanValue in class VennExpression
        Parameters:
        c - The context in which the expression is to be evaluated
        Returns:
        the effective boolean value
        Throws:
        XPathException - if any dynamic error occurs evaluating the expression
      • containsNode

        public static boolean containsNode​(SequenceIterator iter,
                                           NodeInfo m)
                                    throws XPathException
        Ask whether the sequence supplied in the first argument contains the node supplied in the second
        Parameters:
        iter - an iterator over nodes. The iterator will be closed if the node is found.
        m - the node to be tested
        Returns:
        true if (and only if) the sequence contains the node
        Throws:
        XPathException - if evaluating the iterator fails
      • getExpressionName

        public java.lang.String getExpressionName()
        Description copied from class: VennExpression
        Get a name identifying the kind of expression, in terms meaningful to a user.
        Overrides:
        getExpressionName in class VennExpression
        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 explain() output displaying the expression.
      • displayOperator

        protected java.lang.String displayOperator()
        Display the operator used by this binary expression
        Overrides:
        displayOperator in class BinaryExpression
        Returns:
        String representation of the operator (for diagnostic display only)
      • tag

        protected java.lang.String tag()
        Get the element name used to identify this expression in exported expression format
        Overrides:
        tag in class VennExpression
        Returns:
        the element name used to identify this expression