1 28 29 package com.caucho.ejb.ql; 30 31 import com.caucho.config.ConfigException; 32 import com.caucho.ejb.cfg.CmpField; 33 import com.caucho.ejb.cfg.CmpRelation; 34 import com.caucho.ejb.cfg.EjbEntityBean; 35 import com.caucho.util.CharBuffer; 36 37 40 class FieldExpr extends Expr { 41 private PathExpr _base; 43 private String _name; 45 46 private EjbEntityBean _bean; 48 private CmpField _field; 50 private CmpRelation _relation; 52 53 private String _tableId; 55 private String _baseId; 57 private String _sqlField; 59 60 private int _primaryKeyFieldIndex; 61 62 private int _useCount; 64 private boolean _hasRelation; 65 66 72 FieldExpr(Query query, PathExpr base, 73 String fieldName, CmpField field) 74 throws ConfigException 75 { 76 _query = query; 77 _base = base; 78 _name = fieldName; 79 80 _field = field; 81 82 88 89 setJavaType(field.getJavaType()); 90 } 91 92 boolean hasRelation() 93 { 94 return _hasRelation; 95 } 96 97 void setRelation() 98 { 99 _hasRelation = true; 100 } 101 102 105 Expr getBase() 106 { 107 return _base; 108 } 109 110 113 String getField() 114 { 115 return _name; 116 } 117 118 121 EjbEntityBean getBean() 122 { 123 return _bean; 124 } 125 126 129 CmpRelation getRelation() 130 { 131 return _relation; 132 } 133 134 137 String getTableId() 138 { 139 return _tableId; 140 } 141 142 145 void setTableId(String tableId) 146 { 147 _tableId = tableId; 148 } 149 150 153 String getBaseId() 154 { 155 return _base.getTable(); 156 } 157 158 161 String getSQLField() 162 { 163 173 throw new UnsupportedOperationException (); 174 } 175 176 void decrementUse() 177 { 178 _useCount--; 179 } 180 181 int getUseCount() 182 { 183 return _useCount; 184 } 185 186 189 EjbEntityBean getItemBean() 190 { 191 return _bean; 192 } 193 194 203 204 209 229 230 235 String getSelectTable(CharBuffer cb) 236 throws ConfigException 237 { 238 246 return _base.getTable(); 247 } 248 249 254 void generateWhere(CharBuffer cb) 255 { 256 262 263 274 275 _base.generateWhere(cb); 276 cb.append("."); 277 cb.append(_name); 278 } 279 280 291 292 295 public boolean equals(Object bObj) 296 { 297 if (! (bObj instanceof FieldExpr)) 298 return false; 299 300 FieldExpr b = (FieldExpr) bObj; 301 302 return _field.equals(b._field) && _base.equals(b._base); 303 } 304 305 308 public int hashCode() 309 { 310 return _name.hashCode() * 65521 + _base.hashCode(); 311 } 312 313 public String toString() 314 { 315 return _base.toString() + "." + _name; 316 } 317 } 318 | Popular Tags |