001: /* Generated By:JJTree: Do not edit this line. SimpleNode.java */
002:
003: package org.codehaus.aspectwerkz.expression.ast;
004:
005: public class SimpleNode implements Node {
006: protected Node parent;
007:
008: protected Node[] children;
009:
010: protected int id;
011:
012: protected ExpressionParser parser;
013:
014: public SimpleNode(int i) {
015: id = i;
016: }
017:
018: public SimpleNode(ExpressionParser p, int i) {
019: this (i);
020: parser = p;
021: }
022:
023: public void jjtOpen() {
024: }
025:
026: public void jjtClose() {
027: }
028:
029: public void jjtSetParent(Node n) {
030: parent = n;
031: }
032:
033: public Node jjtGetParent() {
034: return parent;
035: }
036:
037: public void jjtAddChild(Node n, int i) {
038: if (children == null) {
039: children = new Node[i + 1];
040: } else if (i >= children.length) {
041: Node c[] = new Node[i + 1];
042: System.arraycopy(children, 0, c, 0, children.length);
043: children = c;
044: }
045: children[i] = n;
046: }
047:
048: public Node jjtGetChild(int i) {
049: return children[i];
050: }
051:
052: public int jjtGetNumChildren() {
053: return (children == null) ? 0 : children.length;
054: }
055:
056: /**
057: * Accept the visitor. *
058: */
059: public Object jjtAccept(ExpressionParserVisitor visitor, Object data) {
060: return visitor.visit(this , data);
061: }
062:
063: /**
064: * Accept the visitor. *
065: */
066: public Object childrenAccept(ExpressionParserVisitor visitor,
067: Object data) {
068: if (children != null) {
069: for (int i = 0; i < children.length; ++i) {
070: children[i].jjtAccept(visitor, data);
071: }
072: }
073: return data;
074: }
075:
076: /*
077: * You can override these two methods in subclasses of SimpleNode to customize the way the node appears when the
078: * tree is dumped. If your output uses more than one line you should override toString(String), otherwise overriding
079: * toString() is probably all you need to do.
080: */
081:
082: public String toString() {
083: return ExpressionParserTreeConstants.jjtNodeName[id];
084: }
085:
086: public String toString(String prefix) {
087: return prefix + toString();
088: }
089:
090: /*
091: * Override this method if you want to customize how the node dumps out its children.
092: */
093:
094: public void dump(String prefix) {
095: System.out.println(toString(prefix));
096: if (children != null) {
097: for (int i = 0; i < children.length; ++i) {
098: SimpleNode n = (SimpleNode) children[i];
099: if (n != null) {
100: n.dump(prefix + " ");
101: }
102: }
103: }
104: }
105: }
|