00001 package edu.ksu.cis.bandera.abstraction.predicate.parser;
00002
00003
00004 public class SimpleNode implements Node {
00005 protected Node parent;
00006 protected Node[] children;
00007 protected int id;
00008 protected PredicateParser parser;
00009
00010
00011 protected String tag;
00012
00013
00014 public SimpleNode(int i) {
00015 id = i;
00016 }
00017 public SimpleNode(PredicateParser p, int i) {
00018 this(i);
00019 parser = p;
00020 }
00021
00022 public Object childrenAccept(PredicateParserVisitor visitor, Object data) {
00023 if (children != null) {
00024 for (int i = 0; i < children.length; ++i) {
00025 children[i].jjtAccept(visitor, data);
00026 }
00027 }
00028 return data;
00029 }
00030
00031
00032
00033 public void dump(String prefix) {
00034 System.out.println(toString(prefix));
00035 if (children != null) {
00036 for (int i = 0; i < children.length; ++i) {
00037 SimpleNode n = (SimpleNode)children[i];
00038 if (n != null) {
00039 n.dump(prefix + " ");
00040 }
00041 }
00042 }
00043 }
00044 public String getTag() { return tag; }
00045
00046 public Object jjtAccept(PredicateParserVisitor visitor, Object data) {
00047 return visitor.visit(this, data);
00048 }
00049 public void jjtAddChild(Node n) { jjtAddChild(n, jjtGetNumChildren()); }
00050 public void jjtAddChild(Node n, int i) {
00051 if (children == null) {
00052 children = new Node[i + 1];
00053 } else if (i >= children.length) {
00054 Node c[] = new Node[i + 1];
00055 System.arraycopy(children, 0, c, 0, children.length);
00056 children = c;
00057 }
00058 children[i] = n;
00059 }
00060 public void jjtClose() {
00061 }
00062 public static Node jjtCreate(int id) {
00063 return new SimpleNode(id);
00064 }
00065 public static Node jjtCreate(PredicateParser p, int id) {
00066 return new SimpleNode(p, id);
00067 }
00068 public Node jjtGetChild(int i) {
00069 return children[i];
00070 }
00071 public int jjtGetNumChildren() {
00072 return (children == null) ? 0 : children.length;
00073 }
00074 public Node jjtGetParent() { return parent; }
00075 public void jjtOpen() {
00076 }
00077 public void jjtSetParent(Node n) { parent = n; }
00078
00079
00080
00081 public void setTag(String s) { tag = s; }
00082
00083
00084
00085
00086
00087
00088 public String toString() { return PredicateParserTreeConstants.jjtNodeName[id]; }
00089 public String toString(String prefix) { return prefix + toString(); }
00090 }