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