KickJava   Java API By Example, From Geeks To Geeks.

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


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 import org.sablecc.sablecc.syntax3.analysis.*;
7
8 @SuppressWarnings JavaDoc("nls")
9 public final class AStates extends PStates
10 {
11     private final LinkedList<PNormalState> _normalStates_ = new LinkedList<PNormalState>();
12     private PInternalStates _internalStates_;
13
14     public AStates()
15     {
16         // Constructor
17
}
18
19     public AStates(
20         @SuppressWarnings JavaDoc("hiding") List<PNormalState> _normalStates_,
21         @SuppressWarnings JavaDoc("hiding") PInternalStates _internalStates_)
22     {
23         // Constructor
24
setNormalStates(_normalStates_);
25
26         setInternalStates(_internalStates_);
27
28     }
29
30     @Override JavaDoc
31     public Object JavaDoc clone()
32     {
33         return new AStates(
34             cloneList(this._normalStates_),
35             cloneNode(this._internalStates_));
36     }
37
38     public void apply(Switch sw)
39     {
40         ((Analysis) sw).caseAStates(this);
41     }
42
43     public LinkedList<PNormalState> getNormalStates()
44     {
45         return this._normalStates_;
46     }
47
48     public void setNormalStates(List<PNormalState> list)
49     {
50         this._normalStates_.clear();
51         this._normalStates_.addAll(list);
52         for(PNormalState e : list)
53         {
54             if(e.parent() != null)
55             {
56                 e.parent().removeChild(e);
57             }
58
59             e.parent(this);
60         }
61     }
62
63     public PInternalStates getInternalStates()
64     {
65         return this._internalStates_;
66     }
67
68     public void setInternalStates(PInternalStates node)
69     {
70         if(this._internalStates_ != null)
71         {
72             this._internalStates_.parent(null);
73         }
74
75         if(node != null)
76         {
77             if(node.parent() != null)
78             {
79                 node.parent().removeChild(node);
80             }
81
82             node.parent(this);
83         }
84
85         this._internalStates_ = node;
86     }
87
88     @Override JavaDoc
89     public String JavaDoc toString()
90     {
91         return ""
92             + toString(this._normalStates_)
93             + toString(this._internalStates_);
94     }
95
96     @Override JavaDoc
97     void removeChild(@SuppressWarnings JavaDoc("unused") Node child)
98     {
99         // Remove child
100
if(this._normalStates_.remove(child))
101         {
102             return;
103         }
104
105         if(this._internalStates_ == child)
106         {
107             this._internalStates_ = null;
108             return;
109         }
110
111         throw new RuntimeException JavaDoc("Not a child.");
112     }
113
114     @Override JavaDoc
115     void replaceChild(@SuppressWarnings JavaDoc("unused") Node oldChild, @SuppressWarnings JavaDoc("unused") Node newChild)
116     {
117         // Replace child
118
for(ListIterator<PNormalState> i = this._normalStates_.listIterator(); i.hasNext();)
119         {
120             if(i.next() == oldChild)
121             {
122                 if(newChild != null)
123                 {
124                     i.set((PNormalState) newChild);
125                     newChild.parent(this);
126                     oldChild.parent(null);
127                     return;
128                 }
129
130                 i.remove();
131                 oldChild.parent(null);
132                 return;
133             }
134         }
135
136         if(this._internalStates_ == oldChild)
137         {
138             setInternalStates((PInternalStates) newChild);
139             return;
140         }
141
142         throw new RuntimeException JavaDoc("Not a child.");
143     }
144 }
145
Popular Tags