1 29 30 package com.caucho.amber.expr; 31 32 import com.caucho.amber.entity.EntityItem; 33 import com.caucho.amber.manager.AmberConnection; 34 import com.caucho.amber.query.FromItem; 35 import com.caucho.amber.query.QueryParseException; 36 import com.caucho.amber.query.QueryParser; 37 import com.caucho.amber.type.StringType; 38 import com.caucho.amber.type.Type; 39 import com.caucho.util.CharBuffer; 40 import com.caucho.util.L10N; 41 42 import java.sql.ResultSet ; 43 import java.sql.SQLException ; 44 45 48 abstract public class AbstractAmberExpr implements AmberExpr { 49 private static final L10N L = new L10N(AbstractAmberExpr.class); 50 51 54 public boolean isBoolean() 55 { 56 return false; 57 } 58 59 62 public Type getType() 63 { 64 return StringType.create(); 65 } 66 67 70 public AmberExpr createBoolean() 71 throws QueryParseException 72 { 73 if (isBoolean()) 74 return this; 75 else 76 throw new QueryParseException(L.l("'{0}' can't be used as a boolean", 77 this)); 78 } 79 80 83 abstract public AmberExpr bindSelect(QueryParser parser); 84 85 88 public boolean usesFrom(FromItem from, int type) 89 { 90 return usesFrom(from, type, false); 91 } 92 93 96 public boolean usesFrom(FromItem from, int type, boolean isNot) 97 { 98 return false; 99 } 100 101 104 public boolean exists(FromItem from) 105 { 106 return false; 107 } 108 109 112 public boolean exists() 113 { 114 return false; 115 } 116 117 120 public AmberExpr replaceJoin(JoinExpr join) 121 { 122 return this; 123 } 124 125 128 public int getColumnCount() 129 { 130 return 1; 131 } 132 133 136 public void generateWhere(CharBuffer cb) 137 { 138 throw new UnsupportedOperationException (getClass().getName()); 139 } 140 141 144 public void generateUpdateWhere(CharBuffer cb) 145 { 146 generateWhere(cb); 147 } 148 149 152 public void generateHaving(CharBuffer cb) 153 { 154 generateWhere(cb); 155 } 156 157 160 public void generateJoin(CharBuffer cb) 161 { 162 generateWhere(cb); 163 } 164 165 168 public void generateSelect(CharBuffer cb) 169 { 170 generateWhere(cb); 171 } 172 173 176 public Object getObject(AmberConnection aConn, ResultSet rs, int index) 177 throws SQLException 178 { 179 return getType().getObject(aConn, rs, index); 180 } 181 182 185 public Object getCacheObject(AmberConnection aConn, 186 ResultSet rs, int index) 187 throws SQLException 188 { 189 return getObject(aConn, rs, index); 190 } 191 192 195 public EntityItem findItem(AmberConnection aConn, ResultSet rs, int index) 196 throws SQLException 197 { 198 return getType().findItem(aConn, rs, index); 199 } 200 } 201 | Popular Tags |