KickJava   Java API By Example, From Geeks To Geeks.

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


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 final class ATableswitchStatement extends PStatement
9 {
10     private TTableswitch _tableswitch_;
11     private TLParen _lParen_;
12     private PImmediate _immediate_;
13     private TRParen _rParen_;
14     private TLBrace _lBrace_;
15     private final LinkedList _caseStmt_ = new TypedLinkedList(new CaseStmt_Cast());
16     private TRBrace _rBrace_;
17     private TSemicolon _semicolon_;
18
19     public ATableswitchStatement()
20     {
21     }
22
23     public ATableswitchStatement(
24         TTableswitch _tableswitch_,
25         TLParen _lParen_,
26         PImmediate _immediate_,
27         TRParen _rParen_,
28         TLBrace _lBrace_,
29         List _caseStmt_,
30         TRBrace _rBrace_,
31         TSemicolon _semicolon_)
32     {
33         setTableswitch(_tableswitch_);
34
35         setLParen(_lParen_);
36
37         setImmediate(_immediate_);
38
39         setRParen(_rParen_);
40
41         setLBrace(_lBrace_);
42
43         {
44             this._caseStmt_.clear();
45             this._caseStmt_.addAll(_caseStmt_);
46         }
47
48         setRBrace(_rBrace_);
49
50         setSemicolon(_semicolon_);
51
52     }
53
54     public ATableswitchStatement(
55         TTableswitch _tableswitch_,
56         TLParen _lParen_,
57         PImmediate _immediate_,
58         TRParen _rParen_,
59         TLBrace _lBrace_,
60         XPCaseStmt _caseStmt_,
61         TRBrace _rBrace_,
62         TSemicolon _semicolon_)
63     {
64         setTableswitch(_tableswitch_);
65
66         setLParen(_lParen_);
67
68         setImmediate(_immediate_);
69
70         setRParen(_rParen_);
71
72         setLBrace(_lBrace_);
73
74         if(_caseStmt_ != null)
75         {
76             while(_caseStmt_ instanceof X1PCaseStmt)
77             {
78                 this._caseStmt_.addFirst(((X1PCaseStmt) _caseStmt_).getPCaseStmt());
79                 _caseStmt_ = ((X1PCaseStmt) _caseStmt_).getXPCaseStmt();
80             }
81             this._caseStmt_.addFirst(((X2PCaseStmt) _caseStmt_).getPCaseStmt());
82         }
83
84         setRBrace(_rBrace_);
85
86         setSemicolon(_semicolon_);
87
88     }
89     public Object JavaDoc clone()
90     {
91         return new ATableswitchStatement(
92             (TTableswitch) cloneNode(_tableswitch_),
93             (TLParen) cloneNode(_lParen_),
94             (PImmediate) cloneNode(_immediate_),
95             (TRParen) cloneNode(_rParen_),
96             (TLBrace) cloneNode(_lBrace_),
97             cloneList(_caseStmt_),
98             (TRBrace) cloneNode(_rBrace_),
99             (TSemicolon) cloneNode(_semicolon_));
100     }
101
102     public void apply(Switch sw)
103     {
104         ((Analysis) sw).caseATableswitchStatement(this);
105     }
106
107     public TTableswitch getTableswitch()
108     {
109         return _tableswitch_;
110     }
111
112     public void setTableswitch(TTableswitch node)
113     {
114         if(_tableswitch_ != null)
115         {
116             _tableswitch_.parent(null);
117         }
118
119         if(node != null)
120         {
121             if(node.parent() != null)
122             {
123                 node.parent().removeChild(node);
124             }
125
126             node.parent(this);
127         }
128
129         _tableswitch_ = node;
130     }
131
132     public TLParen getLParen()
133     {
134         return _lParen_;
135     }
136
137     public void setLParen(TLParen node)
138     {
139         if(_lParen_ != null)
140         {
141             _lParen_.parent(null);
142         }
143
144         if(node != null)
145         {
146             if(node.parent() != null)
147             {
148                 node.parent().removeChild(node);
149             }
150
151             node.parent(this);
152         }
153
154         _lParen_ = node;
155     }
156
157     public PImmediate getImmediate()
158     {
159         return _immediate_;
160     }
161
162     public void setImmediate(PImmediate node)
163     {
164         if(_immediate_ != null)
165         {
166             _immediate_.parent(null);
167         }
168
169         if(node != null)
170         {
171             if(node.parent() != null)
172             {
173                 node.parent().removeChild(node);
174             }
175
176             node.parent(this);
177         }
178
179         _immediate_ = node;
180     }
181
182     public TRParen getRParen()
183     {
184         return _rParen_;
185     }
186
187     public void setRParen(TRParen node)
188     {
189         if(_rParen_ != null)
190         {
191             _rParen_.parent(null);
192         }
193
194         if(node != null)
195         {
196             if(node.parent() != null)
197             {
198                 node.parent().removeChild(node);
199             }
200
201             node.parent(this);
202         }
203
204         _rParen_ = node;
205     }
206
207     public TLBrace getLBrace()
208     {
209         return _lBrace_;
210     }
211
212     public void setLBrace(TLBrace node)
213     {
214         if(_lBrace_ != null)
215         {
216             _lBrace_.parent(null);
217         }
218
219         if(node != null)
220         {
221             if(node.parent() != null)
222             {
223                 node.parent().removeChild(node);
224             }
225
226             node.parent(this);
227         }
228
229         _lBrace_ = node;
230     }
231
232     public LinkedList getCaseStmt()
233     {
234         return _caseStmt_;
235     }
236
237     public void setCaseStmt(List list)
238     {
239         _caseStmt_.clear();
240         _caseStmt_.addAll(list);
241     }
242
243     public TRBrace getRBrace()
244     {
245         return _rBrace_;
246     }
247
248     public void setRBrace(TRBrace node)
249     {
250         if(_rBrace_ != null)
251         {
252             _rBrace_.parent(null);
253         }
254
255         if(node != null)
256         {
257             if(node.parent() != null)
258             {
259                 node.parent().removeChild(node);
260             }
261
262             node.parent(this);
263         }
264
265         _rBrace_ = node;
266     }
267
268     public TSemicolon getSemicolon()
269     {
270         return _semicolon_;
271     }
272
273     public void setSemicolon(TSemicolon node)
274     {
275         if(_semicolon_ != null)
276         {
277             _semicolon_.parent(null);
278         }
279
280         if(node != null)
281         {
282             if(node.parent() != null)
283             {
284                 node.parent().removeChild(node);
285             }
286
287             node.parent(this);
288         }
289
290         _semicolon_ = node;
291     }
292
293     public String JavaDoc toString()
294     {
295         return ""
296             + toString(_tableswitch_)
297             + toString(_lParen_)
298             + toString(_immediate_)
299             + toString(_rParen_)
300             + toString(_lBrace_)
301             + toString(_caseStmt_)
302             + toString(_rBrace_)
303             + toString(_semicolon_);
304     }
305
306     void removeChild(Node child)
307     {
308         if(_tableswitch_ == child)
309         {
310             _tableswitch_ = null;
311             return;
312         }
313
314         if(_lParen_ == child)
315         {
316             _lParen_ = null;
317             return;
318         }
319
320         if(_immediate_ == child)
321         {
322             _immediate_ = null;
323             return;
324         }
325
326         if(_rParen_ == child)
327         {
328             _rParen_ = null;
329             return;
330         }
331
332         if(_lBrace_ == child)
333         {
334             _lBrace_ = null;
335             return;
336         }
337
338         if(_caseStmt_.remove(child))
339         {
340             return;
341         }
342
343         if(_rBrace_ == child)
344         {
345             _rBrace_ = null;
346             return;
347         }
348
349         if(_semicolon_ == child)
350         {
351             _semicolon_ = null;
352             return;
353         }
354
355     }
356
357     void replaceChild(Node oldChild, Node newChild)
358     {
359         if(_tableswitch_ == oldChild)
360         {
361             setTableswitch((TTableswitch) newChild);
362             return;
363         }
364
365         if(_lParen_ == oldChild)
366         {
367             setLParen((TLParen) newChild);
368             return;
369         }
370
371         if(_immediate_ == oldChild)
372         {
373             setImmediate((PImmediate) newChild);
374             return;
375         }
376
377         if(_rParen_ == oldChild)
378         {
379             setRParen((TRParen) newChild);
380             return;
381         }
382
383         if(_lBrace_ == oldChild)
384         {
385             setLBrace((TLBrace) newChild);
386             return;
387         }
388
389         for(ListIterator i = _caseStmt_.listIterator(); i.hasNext();)
390         {
391             if(i.next() == oldChild)
392             {
393                 if(newChild != null)
394                 {
395                     i.set(newChild);
396                     oldChild.parent(null);
397                     return;
398                 }
399
400                 i.remove();
401                 oldChild.parent(null);
402                 return;
403             }
404         }
405
406         if(_rBrace_ == oldChild)
407         {
408             setRBrace((TRBrace) newChild);
409             return;
410         }
411
412         if(_semicolon_ == oldChild)
413         {
414             setSemicolon((TSemicolon) newChild);
415             return;
416         }
417
418     }
419
420     private class CaseStmt_Cast implements Cast
421     {
422         public Object JavaDoc cast(Object JavaDoc o)
423         {
424             PCaseStmt node = (PCaseStmt) o;
425
426             if((node.parent() != null) &&
427                 (node.parent() != ATableswitchStatement.this))
428             {
429                 node.parent().removeChild(node);
430             }
431
432             if((node.parent() == null) ||
433                 (node.parent() != ATableswitchStatement.this))
434             {
435                 node.parent(ATableswitchStatement.this);
436             }
437
438             return node;
439         }
440     }
441 }
442
Popular Tags