1 28 29 package com.caucho.amber.query; 30 31 import com.caucho.util.CharBuffer; 32 33 import com.caucho.amber.type.EntityType; 34 35 import com.caucho.amber.table.Table; 36 37 40 class IdExpr extends AbstractPathExpr { 41 private FromItem _fromItem; 42 43 46 IdExpr(FromItem fromItem) 47 { 48 _fromItem = fromItem; 49 50 } 53 54 57 String getId() 58 { 59 return _fromItem.getName(); 60 } 61 62 65 FromItem getFromItem() 66 { 67 return _fromItem; 68 } 69 70 73 Table getTable() 74 { 75 return _fromItem.getTable(); 76 } 77 78 81 public FromItem getChildFromItem() 82 { 83 return getFromItem(); 84 } 85 86 89 public EntityType getTargetType() 90 { 91 return _fromItem.getEntityType(); 92 } 93 94 97 public AmberExpr bindSelect(QueryParser parser) 98 { 99 return this; 100 } 101 102 105 public FromItem bindSubPath(QueryParser parser) 106 { 107 return _fromItem; 108 } 109 110 113 public boolean usesFrom(FromItem from, int type, boolean isNot) 114 { 115 return (type == IS_INNER_JOIN && _fromItem == from); 116 } 117 118 121 public AmberExpr replaceJoin(JoinExpr join) 122 { 123 return join.replace(this); 124 } 125 126 129 public void generateWhere(CharBuffer cb) 130 { 131 cb.append(_fromItem.getName()); 132 cb.append('.'); 133 cb.append(getTargetType().getId().getColumns().get(0).getName()); 134 } 135 136 public String toString() 137 { 138 return getId(); 139 } 140 141 public int hashCode() 142 { 143 return _fromItem.hashCode(); 144 } 145 146 public boolean equals(Object o) 147 { 148 if (o == null || ! getClass().equals(o.getClass())) 149 return false; 150 151 IdExpr id = (IdExpr) o; 152 153 return _fromItem.equals(id._fromItem); 154 } 155 } 156 | Popular Tags |