1 19 package org.apache.cayenne.ejbql.parser; 20 21 import org.apache.cayenne.ejbql.EJBQLExpressionVisitor; 22 23 27 public class EJBQLPath extends SimpleNode { 28 29 public EJBQLPath(int id) { 30 super(id); 31 } 32 33 public String getId() { 34 return (getChildrenCount() > 0) ? jjtGetChild(0).getText() : null; 35 } 36 37 public String getRelativePath() { 38 int len = getChildrenCount(); 39 if (len < 2) { 40 return null; 41 } 42 43 StringBuffer buffer = new StringBuffer (jjtGetChild(1).getText()); 44 for (int i = 2; i < len; i++) { 45 buffer.append('.').append(jjtGetChild(i).getText()); 46 } 47 48 return buffer.toString(); 49 } 50 51 public String getAbsolutePath() { 52 int len = getChildrenCount(); 53 if (len < 1) { 54 return null; 55 } 56 57 StringBuffer buffer = new StringBuffer (jjtGetChild(0).getText()); 58 for (int i = 1; i < len; i++) { 59 buffer.append('.').append(jjtGetChild(i).getText()); 60 } 61 62 return buffer.toString(); 63 } 64 65 protected boolean visitNode(EJBQLExpressionVisitor visitor) { 66 return visitor.visitPath(this, -1); 67 } 68 69 protected boolean visitChild(EJBQLExpressionVisitor visitor, int childIndex) { 70 return super.visitChild(visitor, childIndex) 71 && visitor.visitPath(this, childIndex); 72 } 73 } 74 | Popular Tags |