1 10 11 package com.triactive.jdo.store; 12 13 import java.util.List ; 14 15 16 class BooleanExpression extends SQLExpression 17 { 18 public BooleanExpression(QueryStatement qs) 19 { 20 super(qs); 21 } 22 23 public BooleanExpression(QueryStatement qs, QueryStatement.QueryColumn qsc) 24 { 25 super(qs, qsc); 26 } 27 28 public BooleanExpression(String functionName, List args) 29 { 30 super(functionName, args); 31 } 32 33 public BooleanExpression(MonadicOperator op, SQLExpression operand) 34 { 35 super(op, operand); 36 } 37 38 public BooleanExpression(SQLExpression operand1, DyadicOperator op, SQLExpression operand2) 39 { 40 super(operand1, op, operand2); 41 } 42 43 public BooleanExpression and(SQLExpression expr) 44 { 45 if (expr instanceof BooleanLiteral) 46 return expr.and(this); 47 else if (expr instanceof BooleanExpression) 48 return new BooleanExpression(this, OP_AND, expr); 49 else 50 return super.and(expr); 51 } 52 53 public BooleanExpression eor(SQLExpression expr) 54 { 55 if (expr instanceof BooleanLiteral) 56 return expr.eor(this); 57 else if (expr instanceof BooleanExpression) 58 { 59 if (qs.getStoreManager().getDatabaseAdapter().supportsBooleanComparison()) 60 return new BooleanExpression(this, OP_NOTEQ, expr); 61 else 62 return and(expr.not()).ior(not().and(expr)); 63 } 64 else 65 return super.eor(expr); 66 } 67 68 public BooleanExpression ior(SQLExpression expr) 69 { 70 if (expr instanceof BooleanLiteral) 71 return expr.ior(this); 72 else if (expr instanceof BooleanExpression) 73 return new BooleanExpression(this, OP_OR, expr); 74 else 75 return super.ior(expr); 76 } 77 78 public BooleanExpression not() 79 { 80 return new BooleanExpression(OP_NOT, this); 81 } 82 83 public BooleanExpression eq(SQLExpression expr) 84 { 85 if (expr instanceof BooleanLiteral || expr instanceof NullLiteral) 86 return expr.eq(this); 87 else if (expr instanceof BooleanExpression) 88 { 89 if (qs.getStoreManager().getDatabaseAdapter().supportsBooleanComparison()) 90 return new BooleanExpression(this, OP_EQ, expr); 91 else 92 return and(expr).ior(not().and(expr.not())); 93 } 94 else 95 return super.eq(expr); 96 } 97 98 public BooleanExpression noteq(SQLExpression expr) 99 { 100 if (expr instanceof BooleanLiteral || expr instanceof NullLiteral) 101 return expr.noteq(this); 102 else if (expr instanceof BooleanExpression) 103 { 104 if (qs.getStoreManager().getDatabaseAdapter().supportsBooleanComparison()) 105 return new BooleanExpression(this, OP_NOTEQ, expr); 106 else 107 return and(expr.not()).ior(not().and(expr)); 108 } 109 else 110 return super.noteq(expr); 111 } 112 113 public BooleanExpression in(SQLExpression expr) 114 { 115 return new BooleanExpression(this, OP_IN, expr); 116 } 117 } 118 | Popular Tags |