1 22 package org.jboss.ejb.plugins.cmp.ejbql; 23 24 30 public class SimpleNode implements Node { 31 protected Node parent; 32 protected Node[] children; 33 protected final int id; 34 35 public SimpleNode(int i) { 36 id = i; 37 } 38 39 public void jjtOpen() { 40 } 41 42 public void jjtClose() { 43 } 44 45 public void jjtSetParent(Node n) { parent = n; } 46 public Node jjtGetParent() { return parent; } 47 48 public void jjtAddChild(Node n, int i) { 49 if (children == null) { 50 children = new Node[i + 1]; 51 } else if (i >= children.length) { 52 Node c[] = new Node[i + 1]; 53 System.arraycopy(children, 0, c, 0, children.length); 54 children = c; 55 } 56 children[i] = n; 57 } 58 59 public Node jjtGetChild(int i) { 60 return children[i]; 61 } 62 63 public int jjtGetNumChildren() { 64 return (children == null) ? 0 : children.length; 65 } 66 67 68 public Object jjtAccept(JBossQLParserVisitor visitor, Object data) { 69 return visitor.visit(this, data); 70 } 71 72 77 78 public String toString() { return EJBQLParserTreeConstants.jjtNodeName[id]; } 79 public String toString(String prefix) { return prefix + toString(); } 80 81 83 84 public void dump(String prefix) { 85 System.out.println(toString(prefix)); 86 if (children != null) { 87 for (int i = 0; i < children.length; ++i) { 88 SimpleNode n = (SimpleNode)children[i]; 89 if (n != null) { 90 n.dump(prefix + ' '); 91 } 92 } 93 } 94 } 95 } 96 97 | Popular Tags |