1 28 29 package com.caucho.amber.query; 30 31 import com.caucho.amber.type.Type; 32 import com.caucho.amber.type.EntityType; 33 34 import com.caucho.amber.field.KeyPropertyField; 35 36 import com.caucho.amber.table.Column; 37 38 41 public class KeyPropertyExpr extends AbstractAmberExpr implements IdFieldExpr { 42 protected PathExpr _parent; 43 private KeyPropertyField _field; 44 45 48 public KeyPropertyExpr(PathExpr parent, KeyPropertyField field) 49 { 50 _parent = parent; 51 _field = field; 52 53 if (_field.getType() instanceof EntityType) 55 throw new IllegalStateException(); 56 } 57 58 61 public AmberExpr bindSelect(QueryParser parser) 62 { 63 _parent = (PathExpr) _parent.bindSelect(parser); 64 65 return this; 66 } 67 68 71 public PathExpr getParent() 72 { 73 return _parent; 74 } 75 76 79 public KeyPropertyField getField() 80 { 81 return _field; 82 } 83 84 87 public Type getType() 88 { 89 return getField().getType(); 90 } 91 92 95 public Column getColumn() 96 { 97 return getField().getColumn(); 98 } 99 100 103 126 127 130 public boolean usesFrom(FromItem from, int type, boolean isNot) 131 { 132 if (_parent instanceof IdExpr) { 133 136 return type == IS_INNER_JOIN && _parent.usesFrom(from, type); 137 } 138 else 139 return _parent.usesFrom(from, type); 140 } 141 142 145 156 157 162 public FromItem getChildFromItem() 163 { 164 return _parent.getChildFromItem(); 165 } 166 167 170 public String toString() 171 { 172 return "KeyPropertyExpr[" + _parent + "," + _field + "]"; 173 } 174 } 175 | Popular Tags |