1 10 11 package com.triactive.jdo.store; 12 13 14 class BooleanLiteral extends BooleanExpression 15 { 16 private final boolean value; 17 18 19 public BooleanLiteral(QueryStatement qs, boolean value) 20 { 21 super(qs); 22 23 this.value = value; 24 st.append(value ? getBooleanTrueValue() : getBooleanFalseValue()); 25 } 26 27 28 34 protected String getBooleanTrueValue() 35 { 36 return "TRUE"; 37 } 38 39 40 46 protected String getBooleanFalseValue() 47 { 48 return "FALSE"; 49 } 50 51 52 public BooleanExpression and(SQLExpression expr) 53 { 54 if (expr instanceof BooleanExpression) 55 return value ? (BooleanExpression)expr : this; 56 else 57 return super.and(expr); 58 } 59 60 public BooleanExpression eor(SQLExpression expr) 61 { 62 if (expr instanceof BooleanExpression) 63 return value ? expr.not() : (BooleanExpression)expr; 64 else 65 return super.eor(expr); 66 } 67 68 public BooleanExpression ior(SQLExpression expr) 69 { 70 if (expr instanceof BooleanExpression) 71 return value ? this : (BooleanExpression)expr; 72 else 73 return super.ior(expr); 74 } 75 76 public BooleanExpression not() 77 { 78 return new BooleanLiteral(qs, !value); 79 } 80 81 public BooleanExpression eq(SQLExpression expr) 82 { 83 if (expr instanceof BooleanExpression) 84 return value ? (BooleanExpression)expr : expr.not(); 85 else 86 return super.eq(expr); 87 } 88 89 public BooleanExpression noteq(SQLExpression expr) 90 { 91 if (expr instanceof BooleanExpression) 92 return value ? expr.not() : (BooleanExpression)expr; 93 else 94 return super.noteq(expr); 95 } 96 } 97 | Popular Tags |