1 28 29 package com.caucho.amber.expr; 30 31 import com.caucho.amber.query.QueryParser; 32 import com.caucho.util.CharBuffer; 33 34 37 public class LiteralExpr extends AbstractAmberExpr { 38 private QueryParser _parser; 39 40 private String _value; 42 43 private Class _javaType; 44 45 51 public LiteralExpr(QueryParser parser, 52 String value, 53 Class javaType) 54 { 55 _parser = parser; 56 _value = value; 57 _javaType = javaType; 58 } 59 60 63 public Class getJavaType() 64 { 65 return _javaType; 66 } 67 68 71 public String getValue() 72 { 73 return _value; 74 } 75 76 79 public AmberExpr bindSelect(QueryParser parser) 80 { 81 return this; 82 } 83 84 87 @Override 88 public boolean exists() 89 { 90 return true; 91 } 92 93 96 public void generateWhere(CharBuffer cb) 97 { 98 if ((_javaType != null) && _javaType.equals(boolean.class)) { 99 if (! _parser.isPostgresDBMS()) { 100 101 103 if (_value.equalsIgnoreCase("false")) 104 cb.append("0"); 105 else 106 cb.append("1"); 107 108 return; 109 } 110 } 111 112 cb.append(_value); 113 } 114 115 118 public void generateUpdateWhere(CharBuffer cb) 119 { 120 generateWhere(cb); 121 } 122 123 126 public void generateHaving(CharBuffer cb) 127 { 128 generateWhere(cb); 129 } 130 131 public String toString() 132 { 133 return _value; 134 } 135 } 136 | Popular Tags |