1 28 29 package com.caucho.amber.expr; 30 31 import com.caucho.amber.AmberRuntimeException; 32 import com.caucho.amber.field.AmberField; 33 import com.caucho.amber.query.FromItem; 34 import com.caucho.amber.query.QueryParser; 35 import com.caucho.amber.type.AbstractStatefulType; 36 import com.caucho.amber.type.RelatedType; 37 import com.caucho.util.L10N; 38 39 42 abstract public class AbstractPathExpr extends AbstractAmberExpr 43 implements PathExpr { 44 private static final L10N L = new L10N(AbstractPathExpr.class); 45 46 49 public AmberExpr createField(QueryParser parser, String fieldName) 50 { 51 AmberField field = null; 52 53 AbstractStatefulType type = getTargetType(); 54 55 do { 56 field = type.getField(fieldName); 57 58 if (type instanceof RelatedType) 59 type = ((RelatedType) type).getParentType(); 60 } 61 while ((type != null) && (field == null)); 62 63 if (field == null) 64 throw new AmberRuntimeException(L.l("'{0}' is an unknown field of '{1}'.", 65 fieldName, getTargetType().getName())); 66 67 return field.createExpr(parser, this); 68 } 69 70 73 public AmberExpr createArray(AmberExpr field) 74 { 75 throw new UnsupportedOperationException (getClass().getName()); 76 } 77 78 81 public PathExpr bindSelect(QueryParser parser, String tableName) 82 { 83 return this; 84 } 85 86 89 public FromItem bindSubPath(QueryParser parser) 90 { 91 return null; 92 } 93 94 97 public FromItem getChildFromItem() 98 { 99 throw new UnsupportedOperationException (getClass().getName()); 100 } 101 } 102 | Popular Tags |