1 10 11 package com.triactive.jdo.store; 12 13 14 class BooleanCharColumnExpression extends BooleanExpression 15 { 16 private final QueryStatement.QueryColumn qsc; 17 private boolean truthTest; 18 19 public BooleanCharColumnExpression(QueryStatement qs, QueryStatement.QueryColumn qsc) 20 { 21 this(qs, qsc, true); 22 } 23 24 public BooleanCharColumnExpression(QueryStatement qs, QueryStatement.QueryColumn qsc, boolean truthTest) 25 { 26 super(qs, qsc); 27 28 this.qsc = qsc; 29 this.truthTest = truthTest; 30 st.append(" = ").append(new BooleanCharColumnLiteral(qs, truthTest)); 31 32 lowestOperator = OP_EQ; 33 } 34 35 public BooleanExpression not() 36 { 37 return new BooleanCharColumnExpression(qs, qsc, !truthTest); 38 } 39 40 public BooleanExpression eq(SQLExpression expr) 41 { 42 if (expr instanceof NullLiteral) 43 return expr.eq(new CharacterExpression(qs, qsc)); 44 else if (expr instanceof BooleanCharColumnExpression) 45 return new BooleanExpression(new CharacterExpression(qs, qsc), 46 OP_EQ, 47 new CharacterExpression(qs, ((BooleanCharColumnExpression)expr).qsc)); 48 else 49 return super.eq(expr); 50 } 51 52 public BooleanExpression noteq(SQLExpression expr) 53 { 54 if (expr instanceof NullLiteral) 55 return expr.noteq(new CharacterExpression(qs, qsc)); 56 else if (expr instanceof BooleanCharColumnExpression) 57 return new BooleanExpression(new CharacterExpression(qs, qsc), 58 OP_NOTEQ, 59 new CharacterExpression(qs, ((BooleanCharColumnExpression)expr).qsc)); 60 else 61 return super.noteq(expr); 62 } 63 64 public BooleanExpression in(SQLExpression expr) 65 { 66 return new BooleanExpression(new CharacterExpression(qs, qsc), OP_IN, expr); 67 } 68 } 69 | Popular Tags |