KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sablecc > sablecc > syntax3 > node > Node


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