001: /* Generated By:JJTree: Do not edit this line. SimpleNode.java */
002:
003: package org.onemind.jxp.parser;
004:
005: public class SimpleNode implements Node {
006: protected Node parent;
007: protected Node[] children;
008: protected int id;
009: protected JxpParser parser;
010:
011: //customized code
012: int _dim;
013: int _line, _col;
014: protected Object _data;
015:
016: public SimpleNode(int i) {
017: id = i;
018: }
019:
020: public SimpleNode(JxpParser p, int i) {
021: this (i);
022: parser = p;
023: }
024:
025: public void jjtOpen() {
026: }
027:
028: public void jjtClose() {
029: }
030:
031: public void jjtSetParent(Node n) {
032: parent = n;
033: }
034:
035: public Node jjtGetParent() {
036: return parent;
037: }
038:
039: public void jjtAddChild(Node n, int i) {
040: if (children == null) {
041: children = new Node[i + 1];
042: } else if (i >= children.length) {
043: Node c[] = new Node[i + 1];
044: System.arraycopy(children, 0, c, 0, children.length);
045: children = c;
046: }
047: children[i] = n;
048: }
049:
050: public Node jjtGetChild(int i) {
051: return children[i];
052: }
053:
054: public int jjtGetNumChildren() {
055: return (children == null) ? 0 : children.length;
056: }
057:
058: /** Accept the visitor. **/
059: public Object jjtAccept(JxpParserVisitor visitor, Object data)
060: throws Exception {
061: return visitor.visit(this , data);
062: }
063:
064: /** Accept the visitor. **/
065: public Object childrenAccept(JxpParserVisitor visitor, Object data)
066: throws Exception {
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: /* You can override these two methods in subclasses of SimpleNode to
076: customize the way the node appears when the tree is dumped. If
077: your output uses more than one line you should override
078: toString(String), otherwise overriding toString() is probably all
079: you need to do. */
080:
081: public String toString() {
082: StringBuffer sb = new StringBuffer(
083: JxpParserTreeConstants.jjtNodeName[id]);
084: if (_data != null) {
085: sb.append(": " + _data);
086: }
087: return sb.toString();
088: }
089:
090: public String toString(String prefix) {
091: return prefix + toString();
092: }
093:
094: /* Override this method if you want to customize how the node dumps
095: out its children. */
096:
097: public void dump(String prefix) {
098: System.out.println(toString(prefix) + " - (" + _line + ", "
099: + _col + ")");
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:
110: /**
111: * @return
112: */
113: public int getCol() {
114: return _col;
115: }
116:
117: /**
118: * @return
119: */
120: public Object getData() {
121: return _data;
122: }
123:
124: /**
125: * @return
126: */
127: public int getLine() {
128: return _line;
129: }
130:
131: /**
132: * @param i
133: */
134: public void setCol(int i) {
135: _col = i;
136: }
137:
138: /**
139: * @param object
140: */
141: public void setData(Object object) {
142: _data = object;
143: }
144:
145: /**
146: * @param i
147: */
148: public void setLine(int i) {
149: _line = i;
150: }
151:
152: }
|