KickJava   Java API By Example, From Geeks To Geeks.

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


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 AFieldMember extends PMember
9 {
10     private final LinkedList _modifier_ = new TypedLinkedList(new Modifier_Cast());
11     private PType _type_;
12     private PName _name_;
13     private TSemicolon _semicolon_;
14
15     public AFieldMember()
16     {
17     }
18
19     public AFieldMember(
20         List _modifier_,
21         PType _type_,
22         PName _name_,
23         TSemicolon _semicolon_)
24     {
25         {
26             this._modifier_.clear();
27             this._modifier_.addAll(_modifier_);
28         }
29
30         setType(_type_);
31
32         setName(_name_);
33
34         setSemicolon(_semicolon_);
35
36     }
37
38     public AFieldMember(
39         XPModifier _modifier_,
40         PType _type_,
41         PName _name_,
42         TSemicolon _semicolon_)
43     {
44         if(_modifier_ != null)
45         {
46             while(_modifier_ instanceof X1PModifier)
47             {
48                 this._modifier_.addFirst(((X1PModifier) _modifier_).getPModifier());
49                 _modifier_ = ((X1PModifier) _modifier_).getXPModifier();
50             }
51             this._modifier_.addFirst(((X2PModifier) _modifier_).getPModifier());
52         }
53
54         setType(_type_);
55
56         setName(_name_);
57
58         setSemicolon(_semicolon_);
59
60     }
61     public Object JavaDoc clone()
62     {
63         return new AFieldMember(
64             cloneList(_modifier_),
65             (PType) cloneNode(_type_),
66             (PName) cloneNode(_name_),
67             (TSemicolon) cloneNode(_semicolon_));
68     }
69
70     public void apply(Switch sw)
71     {
72         ((Analysis) sw).caseAFieldMember(this);
73     }
74
75     public LinkedList getModifier()
76     {
77         return _modifier_;
78     }
79
80     public void setModifier(List list)
81     {
82         _modifier_.clear();
83         _modifier_.addAll(list);
84     }
85
86     public PType getType()
87     {
88         return _type_;
89     }
90
91     public void setType(PType node)
92     {
93         if(_type_ != null)
94         {
95             _type_.parent(null);
96         }
97
98         if(node != null)
99         {
100             if(node.parent() != null)
101             {
102                 node.parent().removeChild(node);
103             }
104
105             node.parent(this);
106         }
107
108         _type_ = node;
109     }
110
111     public PName getName()
112     {
113         return _name_;
114     }
115
116     public void setName(PName node)
117     {
118         if(_name_ != null)
119         {
120             _name_.parent(null);
121         }
122
123         if(node != null)
124         {
125             if(node.parent() != null)
126             {
127                 node.parent().removeChild(node);
128             }
129
130             node.parent(this);
131         }
132
133         _name_ = node;
134     }
135
136     public TSemicolon getSemicolon()
137     {
138         return _semicolon_;
139     }
140
141     public void setSemicolon(TSemicolon node)
142     {
143         if(_semicolon_ != null)
144         {
145             _semicolon_.parent(null);
146         }
147
148         if(node != null)
149         {
150             if(node.parent() != null)
151             {
152                 node.parent().removeChild(node);
153             }
154
155             node.parent(this);
156         }
157
158         _semicolon_ = node;
159     }
160
161     public String JavaDoc toString()
162     {
163         return ""
164             + toString(_modifier_)
165             + toString(_type_)
166             + toString(_name_)
167             + toString(_semicolon_);
168     }
169
170     void removeChild(Node child)
171     {
172         if(_modifier_.remove(child))
173         {
174             return;
175         }
176
177         if(_type_ == child)
178         {
179             _type_ = null;
180             return;
181         }
182
183         if(_name_ == child)
184         {
185             _name_ = null;
186             return;
187         }
188
189         if(_semicolon_ == child)
190         {
191             _semicolon_ = null;
192             return;
193         }
194
195     }
196
197     void replaceChild(Node oldChild, Node newChild)
198     {
199         for(ListIterator i = _modifier_.listIterator(); i.hasNext();)
200         {
201             if(i.next() == oldChild)
202             {
203                 if(newChild != null)
204                 {
205                     i.set(newChild);
206                     oldChild.parent(null);
207                     return;
208                 }
209
210                 i.remove();
211                 oldChild.parent(null);
212                 return;
213             }
214         }
215
216         if(_type_ == oldChild)
217         {
218             setType((PType) newChild);
219             return;
220         }
221
222         if(_name_ == oldChild)
223         {
224             setName((PName) newChild);
225             return;
226         }
227
228         if(_semicolon_ == oldChild)
229         {
230             setSemicolon((TSemicolon) newChild);
231             return;
232         }
233
234     }
235
236     private class Modifier_Cast implements Cast
237     {
238         public Object JavaDoc cast(Object JavaDoc o)
239         {
240             PModifier node = (PModifier) o;
241
242             if((node.parent() != null) &&
243                 (node.parent() != AFieldMember.this))
244             {
245                 node.parent().removeChild(node);
246             }
247
248             if((node.parent() == null) ||
249                 (node.parent() != AFieldMember.this))
250             {
251                 node.parent(AFieldMember.this);
252             }
253
254             return node;
255         }
256     }
257 }
258
Popular Tags