1 19 20 package org.apache.cayenne.exp.parser; 21 22 import java.util.Iterator ; 23 24 import org.apache.cayenne.map.Entity; 25 26 32 public abstract class ASTPath extends SimpleNode { 33 protected String path; 34 35 ASTPath(int i) { 36 super(i); 37 } 38 39 public int getOperandCount() { 40 return 1; 41 } 42 43 public Object getOperand(int index) { 44 if (index == 0) { 45 return path; 46 } 47 48 throw new ArrayIndexOutOfBoundsException (index); 49 } 50 51 public void setOperand(int index, Object value) { 52 if (index != 0) { 53 throw new ArrayIndexOutOfBoundsException (index); 54 } 55 56 setPath(value); 57 } 58 59 protected void setPath(Object path) { 60 this.path = (path != null) ? path.toString() : null; 61 } 62 63 protected String getPath() { 64 return path; 65 } 66 67 68 71 protected Object evaluateEntityNode(Entity entity) { 72 Iterator path = entity.resolvePathComponents(this); 73 Object next = null; 74 while (path.hasNext()) { 75 next = path.next(); 76 } 77 78 return next; 79 } 80 81 protected String getExpressionOperator(int index) { 82 throw new UnsupportedOperationException ( 83 "No operator for '" + ExpressionParserTreeConstants.jjtNodeName[id] + "'"); 84 } 85 } 86 | Popular Tags |