| 1 | |
package org.webslinger.rules; |
| 2 | |
|
| 3 | |
import java.io.PrintStream; |
| 4 | |
import java.util.ArrayList; |
| 5 | |
import java.util.ListIterator; |
| 6 | |
|
| 7 | 0 | public abstract class SimpleNode implements Node { |
| 8 | |
protected Node parent; |
| 9 | 777 | protected ArrayList<Node> children = new ArrayList<Node>(); |
| 10 | |
protected int id; |
| 11 | |
protected Rules parser; |
| 12 | |
|
| 13 | 777 | public SimpleNode(int i) { |
| 14 | 777 | id = i; |
| 15 | 777 | } |
| 16 | |
|
| 17 | |
public SimpleNode(Rules p, int i) { |
| 18 | 777 | this(i); |
| 19 | 777 | parser = p; |
| 20 | 777 | } |
| 21 | |
|
| 22 | |
public void jjtOpen() { |
| 23 | 777 | } |
| 24 | |
|
| 25 | |
public void jjtClose() { |
| 26 | 777 | } |
| 27 | |
|
| 28 | 755 | public void jjtSetParent(Node n) { parent = n; } |
| 29 | 0 | public Node jjtGetParent() { return parent; } |
| 30 | |
|
| 31 | |
public void jjtAddChild(Node n, int i) { |
| 32 | 1510 | while (children.size() < i + 1) children.add(null); |
| 33 | 755 | children.set(i, n); |
| 34 | 755 | } |
| 35 | |
|
| 36 | |
public void jjtRemoveChild(int i) { |
| 37 | 0 | children.remove(i); |
| 38 | 0 | } |
| 39 | |
|
| 40 | |
public Node jjtGetChild(int i) { |
| 41 | 348 | return children.get(i); |
| 42 | |
} |
| 43 | |
|
| 44 | |
public int jjtGetNumChildren() { |
| 45 | 248 | return children.size(); |
| 46 | |
} |
| 47 | |
|
| 48 | |
public Object jjtAccept(RulesVisitor visitor, Object data) { |
| 49 | 0 | return visitor.visit(this, data); |
| 50 | |
} |
| 51 | |
|
| 52 | |
public Object childrenAccept(RulesVisitor visitor, Object data) { |
| 53 | 0 | ListIterator it = getChildrenIterator(); |
| 54 | 0 | while (it.hasNext()) { |
| 55 | 0 | Node child = (Node) it.next(); |
| 56 | 0 | child.jjtAccept(visitor, data); |
| 57 | 0 | } |
| 58 | 0 | return data; |
| 59 | |
} |
| 60 | |
|
| 61 | |
public ListIterator<Node> getChildrenIterator() { |
| 62 | 264 | return children.listIterator(); |
| 63 | |
} |
| 64 | |
|
| 65 | |
public ListIterator<Node> iterator() { |
| 66 | 0 | return getChildrenIterator(); |
| 67 | |
} |
| 68 | |
|
| 69 | |
|
| 70 | |
|
| 71 | |
|
| 72 | |
|
| 73 | |
|
| 74 | |
|
| 75 | 0 | public String toString() { return RulesTreeConstants.jjtNodeName[id]; } |
| 76 | 0 | public String toString(StringBuffer prefix) { return prefix + toString(); } |
| 77 | 0 | public String toString(String prefix) { return toString(new StringBuffer(prefix)); } |
| 78 | |
|
| 79 | |
|
| 80 | |
|
| 81 | |
|
| 82 | |
public void dump(String prefix) { |
| 83 | 0 | dump(System.err, prefix); |
| 84 | 0 | } |
| 85 | |
|
| 86 | |
public void dump(StringBuffer prefix) { |
| 87 | 0 | dump(System.err, prefix); |
| 88 | 0 | } |
| 89 | |
|
| 90 | |
public void dump(PrintStream out, String prefix) { |
| 91 | 0 | dump(out, new StringBuffer(prefix)); |
| 92 | 0 | } |
| 93 | |
|
| 94 | |
public void dump(PrintStream out, StringBuffer prefix) { |
| 95 | 0 | out.println(toString(prefix)); |
| 96 | 0 | ListIterator<Node> it = getChildrenIterator(); |
| 97 | 0 | prefix.append(' '); |
| 98 | 0 | while (it.hasNext()) { |
| 99 | 0 | SimpleNode child = (SimpleNode) it.next(); |
| 100 | 0 | child.dump(out, prefix); |
| 101 | 0 | } |
| 102 | 0 | prefix.setLength(prefix.length() - 1); |
| 103 | 0 | } |
| 104 | |
|
| 105 | |
|
| 106 | |
|
| 107 | |
|
| 108 | |
|
| 109 | |
|
| 110 | |
|
| 111 | |
|
| 112 | |
|
| 113 | |
|
| 114 | |
|
| 115 | |
|
| 116 | |
|
| 117 | |
|
| 118 | |
|
| 119 | |
|
| 120 | |
|
| 121 | |
|
| 122 | |
|
| 123 | |
|
| 124 | |
|
| 125 | |
} |