Class SubqueryCompareCriteria

  • All Implemented Interfaces:
    Cloneable, PredicateCriteria.Negatable, SubqueryContainer<QueryCommand>, LanguageObject, ContextReference, Expression

    public class SubqueryCompareCriteria
    extends AbstractCompareCriteria
    implements SubqueryContainer<QueryCommand>, ContextReference

    This class implements a quantified comparison predicate. This is a criteria which represents a simple operator relationship between an expression and either a scalar subquery or a table subquery preceded by one of the possible quantifiers.

    The quantifiers are:

    • SOME and ANY, which are synonymous - the criteria is true if there is at least one comparison between the left expression and the values of the subquery. The criteria is false if the subquery returns no rows.
    • ALL - the criteria is true only if all of the comparisons between the left expression and each value of the subquery is true. The criteria is also true if the subquery returns no rows.

    Some examples are:

    • ticker = ANY (Select ... FROM ... WHERE ... )
    • price >= ALL (Select ... FROM ... WHERE ... )
    • revenue < (Select ... FROM ... WHERE ... )
    This can also represent a quantified comparison against array. In which case the arrayExpression member will be set and command will not.
    • Field Detail

      • SOME

        public static final int SOME
        "Some" predicate quantifier (equivalent to "Any")
        See Also:
        Constant Field Values
      • ANY

        public static final int ANY
        "Any" predicate quantifier (equivalent to "Some")
        See Also:
        Constant Field Values
    • Constructor Detail

      • SubqueryCompareCriteria

        public SubqueryCompareCriteria()
      • SubqueryCompareCriteria

        public SubqueryCompareCriteria​(Expression leftExpression,
                                       QueryCommand subCommand,
                                       int operator,
                                       int predicateQuantifier)
    • Method Detail

      • getPredicateQuantifier

        public int getPredicateQuantifier()
        Get the predicate quantifier - returns one of the following:
        Returns:
        the predicate quantifier
      • setPredicateQuantifier

        public void setPredicateQuantifier​(int predicateQuantifier)
        Set the predicate quantifier - use one of the following:
        Parameters:
        predicateQuantifier - the predicate quantifier
      • setCommand

        public void setCommand​(QueryCommand command)
        Set the subquery command (either a SELECT or a procedure execution).
        Specified by:
        setCommand in interface SubqueryContainer<QueryCommand>
        Parameters:
        command - Command to execute to get the values for the criteria
      • getPredicateQuantifierAsString

        public String getPredicateQuantifierAsString()
        Returns the predicate quantifier as a string.
        Returns:
        String version of predicate quantifier
      • acceptVisitor

        public void acceptVisitor​(LanguageVisitor visitor)
        Description copied from interface: LanguageObject
        Method for accepting a visitor. It is the responsibility of the language object to call back on the visitor.
        Specified by:
        acceptVisitor in interface LanguageObject
        Parameters:
        visitor - Visitor being used
      • hashCode

        public int hashCode()
        Get hash code. WARNING: The hash code is based on data in the criteria. If data values are changed, the hash code will change - don't hash this object and change values.
        Overrides:
        hashCode in class Object
        Returns:
        Hash code
      • equals

        public boolean equals​(Object obj)
        Override equals() method.
        Overrides:
        equals in class Object
        Parameters:
        obj - Other object
        Returns:
        true if objects are equivalent
      • clone

        public Object clone()
        Deep copy of object. The values Iterator of this object will not be cloned - it will be null in the new object (see #setValueIterator setValueIterator}).
        Specified by:
        clone in interface LanguageObject
        Specified by:
        clone in class PredicateCriteria
        Returns:
        Deep copy of object
        See Also:
        Object.clone()
      • getArrayExpression

        public Expression getArrayExpression()
      • setArrayExpression

        public void setArrayExpression​(Expression expression)