Class BooleanExpression

  • Direct Known Subclasses:
    BooleanLiteral, BooleanSubqueryExpression, CaseBooleanExpression, InExpression

    public class BooleanExpression
    extends SQLExpression
    Representation of a Boolean expression in a Query. Can be represented in one of the following ways in the datastore
    • As String-based, so stored as "Y", "N"
    • As numeric-based, so stored as 1, 0
    • As boolean-based, so stored as true, false
    A boolean expression has "closure" if it represents a boolean SQL expression (i.e "fld == val"). If it doesn't have "closure" then it represents a clause like "booleanFld" or "false" or "true".
    • Constructor Detail

      • BooleanExpression

        public BooleanExpression​(SQLStatement stmt,
                                 JavaTypeMapping mapping,
                                 String sql)
        Constructor for a boolean expression for the specified mapping using the specified SQL text.
        Parameters:
        stmt - The statement
        mapping - the mapping associated to this expression
        sql - The SQL text that will return a boolean
      • BooleanExpression

        public BooleanExpression​(SQLStatement stmt,
                                 SQLTable table,
                                 JavaTypeMapping mapping)
        Constructor for a boolean expression for the specified mapping of the table. The boolean expression DOESN'T have closure using this constructor.
        Parameters:
        stmt - The statement
        table - The table this mapping belongs to
        mapping - the mapping associated to this expression
      • BooleanExpression

        public BooleanExpression​(SQLStatement stmt,
                                 JavaTypeMapping mapping)
        Constructor for a boolean expression for the specified mapping of the table. The boolean expression has closure using this constructor.
        Parameters:
        stmt - The statement
        mapping - the mapping associated to this expression
      • BooleanExpression

        public BooleanExpression​(org.datanucleus.query.expression.Expression.MonadicOperator op,
                                 SQLExpression expr1)
        Perform an operation
        op
        on expression
        expr1
        . The boolean expression has closure using this constructor.
        Parameters:
        op - operator
        expr1 - operand
      • BooleanExpression

        public BooleanExpression​(SQLExpression expr1,
                                 org.datanucleus.query.expression.Expression.DyadicOperator op,
                                 SQLExpression expr2)
        Perform an operation
        op
        between
        expr1
        and
        expr2
        . The boolean expression has closure using this constructor.
        Parameters:
        expr1 - the first expression
        op - the operator between operands
        expr2 - the second expression
    • Method Detail

      • hasClosure

        public boolean hasClosure()
      • and

        public BooleanExpression and​(SQLExpression expr)
        Description copied from class: SQLExpression
        Conditional AND. Evaluates its right-hand operand only if the value of its left-hand operand is true.
        Overrides:
        and in class SQLExpression
        Parameters:
        expr - the right-hand operand
        Returns:
        the result value is true if both operand values are true; otherwise, the result is false.
      • ior

        public BooleanExpression ior​(SQLExpression expr)
        Description copied from class: SQLExpression
        Conditional OR. Evaluates its right-hand operand only if the value of its left-hand operand is false.
        Overrides:
        ior in class SQLExpression
        Parameters:
        expr - the right-hand operand
        Returns:
        the result value is false if both operand values are false; otherwise, the result is true.
      • in

        public BooleanExpression in​(SQLExpression expr,
                                    boolean not)
        Description copied from class: SQLExpression
        In expression. Return true if this is contained by expr
        Overrides:
        in in class SQLExpression
        Parameters:
        expr - the right-hand expression
        not - Whether we really want "not in"
        Returns:
        true if the left-hand expression is contained by the right-hand expression. Otherwise the result is false.
      • invoke

        public SQLExpression invoke​(String methodName,
                                    List args)
        Description copied from class: SQLExpression
        Invocation of a method on this expression.
        Overrides:
        invoke in class SQLExpression
        Parameters:
        methodName - name of the method to invoke
        args - Args to this method (if any)
        Returns:
        the converted value
      • neg

        public BooleanExpression neg()
        Description copied from class: SQLExpression
        Unary Minus Operator
        Overrides:
        neg in class SQLExpression
        Returns:
        the type of the unary minus expression is the promoted type of the operand.