KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > soot > jimple > parser > node > Node


1 /* This file was generated by SableCC (http://www.sablecc.org/). */
2
3 package soot.jimple.parser.node;
4
5 import java.util.*;
6 import soot.jimple.parser.analysis.*;
7
8 public abstract class Node implements Switchable, Cloneable JavaDoc
9 {
10     private Node parent;
11
12     public abstract Object JavaDoc clone();
13
14     public Node parent()
15     {
16         return parent;
17     }
18
19     void parent(Node parent)
20     {
21         this.parent = parent;
22     }
23
24     abstract void removeChild(Node child);
25     abstract void replaceChild(Node oldChild, Node newChild);
26
27     public void replaceBy(Node node)
28     {
29         if(parent != null)
30         {
31             parent.replaceChild(this, node);
32         }
33     }
34
35     protected String JavaDoc toString(Node node)
36     {
37         if(node != null)
38         {
39             return node.toString();
40         }
41
42         return "";
43     }
44
45     protected String JavaDoc toString(List list)
46     {
47         StringBuffer JavaDoc s = new StringBuffer JavaDoc();
48
49         for(Iterator i = list.iterator(); i.hasNext();)
50         {
51             s.append(i.next());
52         }
53
54         return s.toString();
55     }
56
57     protected Node cloneNode(Node node)
58     {
59         if(node != null)
60         {
61             return (Node) node.clone();
62         }
63
64         return null;
65     }
66
67     protected List cloneList(List list)
68     {
69         List clone = new LinkedList();
70
71         for(Iterator i = list.iterator(); i.hasNext();)
72         {
73             clone.add(((Node) i.next()).clone());
74         }
75
76         return clone;
77     }
78 }
79
Popular Tags