1 56 package org.objectstyle.cayenne.exp.parser; 57 58 import java.util.Iterator ; 59 60 import org.objectstyle.cayenne.map.Entity; 61 62 68 public abstract class ASTPath extends SimpleNode { 69 protected String path; 70 71 ASTPath(int i) { 72 super(i); 73 } 74 75 public int getOperandCount() { 76 return 1; 77 } 78 79 public Object getOperand(int index) { 80 if (index == 0) { 81 return path; 82 } 83 84 throw new ArrayIndexOutOfBoundsException (index); 85 } 86 87 public void setOperand(int index, Object value) { 88 if (index != 0) { 89 throw new ArrayIndexOutOfBoundsException (index); 90 } 91 92 setPath(value); 93 } 94 95 protected void setPath(Object path) { 96 this.path = (path != null) ? path.toString() : null; 97 } 98 99 protected String getPath() { 100 return path; 101 } 102 103 104 107 protected Object evaluateEntityNode(Entity entity) { 108 Iterator path = entity.resolvePathComponents(this); 109 Object next = null; 110 while (path.hasNext()) { 111 next = path.next(); 112 } 113 114 return next; 115 } 116 117 protected String getExpressionOperator(int index) { 118 throw new UnsupportedOperationException ( 119 "No operator for '" + ExpressionParserTreeConstants.jjtNodeName[id] + "'"); 120 } 121 } 122 | Popular Tags |