1 29 30 package com.caucho.db.sql; 31 32 import com.caucho.log.Log; 33 34 import java.sql.SQLException ; 35 import java.util.ArrayList ; 36 import java.util.logging.Logger ; 37 38 class BooleanLiteralExpr extends Expr { 39 private static final Logger log = Log.open(NullExpr.class); 40 41 private static BooleanLiteralExpr TRUE_EXPR = new BooleanLiteralExpr(true); 42 private static BooleanLiteralExpr FALSE_EXPR = new BooleanLiteralExpr(false); 43 44 private final boolean _value; 45 46 private BooleanLiteralExpr(boolean value) 47 { 48 _value = value; 49 } 50 51 static BooleanLiteralExpr create(boolean value) 52 { 53 return value ? TRUE_EXPR : FALSE_EXPR; 54 } 55 56 59 public boolean isNull(QueryContext context) 60 throws SQLException 61 { 62 return false; 63 } 64 65 68 public Class getType() 69 { 70 return boolean.class; 71 } 72 73 76 public boolean isBoolean() 77 { 78 return true; 79 } 80 81 84 public long subCost(ArrayList <FromItem> fromList) 85 { 86 return 0; 87 } 88 89 92 public String evalString(QueryContext context) 93 throws SQLException 94 { 95 return _value ? "1" : "0"; 96 } 97 98 101 public int evalBoolean(QueryContext context) 102 throws SQLException 103 { 104 return _value ? TRUE : FALSE; 105 } 106 107 public String toString() 108 { 109 return _value ? "TRUE" : "FALSE"; 110 } 111 } 112 | Popular Tags |