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