1 28 29 package com.caucho.amber.query; 30 31 import com.caucho.util.CharBuffer; 32 33 import com.caucho.amber.type.Type; 34 import com.caucho.amber.type.EntityType; 35 36 import com.caucho.amber.field.MapElementField; 37 38 41 public class MapFieldExpr extends AbstractAmberExpr { 42 protected PathExpr _parent; 43 44 private MapElementField _field; 45 private AmberExpr _index; 46 47 private FromItem _fromItem; 48 private FromItem _childFromItem; 49 50 53 public MapFieldExpr(PathExpr parent, 54 MapElementField field, 55 AmberExpr index) 56 { 57 _parent = parent; 58 _field = field; 59 _index = index; 60 } 61 62 65 public AmberExpr bindSelect(QueryParser parser) 66 { 67 _fromItem = _parent.bindSubPath(parser); 68 69 71 73 _index = _index.bindSelect(parser); 74 75 return this; 76 } 77 78 81 public boolean usesFrom(FromItem from, int type, boolean isNot) 82 { 83 return (_childFromItem == from || 84 _parent.usesFrom(from, type) || 85 _index.usesFrom(from, type)); 86 } 87 88 91 public Type getType() 92 { 93 return _field.getTargetType(); 94 } 95 96 99 public EntityType getTableType() 100 { 101 return (EntityType) getType(); 102 } 103 104 107 public void generateSelect(CharBuffer cb) 108 { 109 String table = _childFromItem.getName(); 110 111 117 118 cb.append(_field.generateTargetSelect(table)); 119 } 120 121 124 public void generateWhere(CharBuffer cb) 125 { 126 cb.append(_field.generateTargetSelect(_childFromItem.getName())); 127 134 } 135 136 public String toString() 137 { 138 return _parent + "." + _field; 139 } 140 } 141 | Popular Tags |