Class BooleanExpression

java.lang.Object
org.datanucleus.store.rdbms.sql.expression.SQLExpression
org.datanucleus.store.rdbms.sql.expression.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".
  • Field Details

    • hasClosure

      boolean hasClosure
  • Constructor Details

    • 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, JavaTypeMapping mapping, String functionName, List<SQLExpression> args)
      Generates statement as "FUNCTION_NAME(arg [,argN])" such as STARTS_WITH(arg1, arg2).
      Parameters:
      stmt - The statement
      mapping - Mapping to use
      functionName - Name of function
      args - SQLExpression list
    • 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.store.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.store.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 Details

    • 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.
    • eor

      public BooleanExpression eor(SQLExpression expr)
      Description copied from class: SQLExpression
      Exclusive OR
      Overrides:
      eor in class SQLExpression
      Parameters:
      expr - the right-hand operand
      Returns:
      the result value is the bitwise exclusive OR of the operand values.
    • 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.
    • not

      public BooleanExpression not()
      Description copied from class: SQLExpression
      Logical complement
      Overrides:
      not in class SQLExpression
      Returns:
      the result value is false if operand is true; otherwise, the result is true.
    • eq

      public BooleanExpression eq(SQLExpression expr)
      Description copied from class: SQLExpression
      Equality operator (equals to)
      Overrides:
      eq in class SQLExpression
      Parameters:
      expr - the right-hand operand
      Returns:
      The type of an equality expression is a boolean
    • ne

      public BooleanExpression ne(SQLExpression expr)
      Description copied from class: SQLExpression
      Not equality operator (not equals to)
      Overrides:
      ne in class SQLExpression
      Parameters:
      expr - the right-hand operand
      Returns:
      The type of an equality expression is a boolean
    • 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<SQLExpression> 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.