01: /* This file was generated by SableCC (http://www.sablecc.org/). */
02:
03: package org.jmatlab.node;
04:
05: import java.util.*;
06: import org.jmatlab.analysis.*;
07:
08: public abstract class Node implements Switchable, Cloneable {
09: private Node parent;
10:
11: public abstract Object clone();
12:
13: public Node parent() {
14: return parent;
15: }
16:
17: void parent(Node parent) {
18: this .parent = parent;
19: }
20:
21: abstract void removeChild(Node child);
22:
23: abstract void replaceChild(Node oldChild, Node newChild);
24:
25: public void replaceBy(Node node) {
26: if (parent != null) {
27: parent.replaceChild(this , node);
28: }
29: }
30:
31: protected String toString(Node node) {
32: if (node != null) {
33: return node.toString();
34: }
35:
36: return "";
37: }
38:
39: protected String toString(List list) {
40: StringBuffer s = new StringBuffer();
41:
42: for (Iterator i = list.iterator(); i.hasNext();) {
43: s.append(i.next());
44: }
45:
46: return s.toString();
47: }
48:
49: protected Node cloneNode(Node node) {
50: if (node != null) {
51: return (Node) node.clone();
52: }
53:
54: return null;
55: }
56:
57: protected List cloneList(List list) {
58: List clone = new LinkedList();
59:
60: for (Iterator i = list.iterator(); i.hasNext();) {
61: clone.add(((Node) i.next()).clone());
62: }
63:
64: return clone;
65: }
66: }
|