00001 package edu.ksu.cis.bandera.jjjc.node;
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 import ca.mcgill.sable.util.*;
00037 import edu.ksu.cis.bandera.jjjc.analysis.*;
00038
00039 public final class AInterfaceDeclaration extends PInterfaceDeclaration
00040 {
00041 private final LinkedList _modifier_ = new TypedLinkedList(new Modifier_Cast());
00042 private TInterface _interface_;
00043 private TId _id_;
00044 private TExtends _extends_;
00045 private final LinkedList _name_ = new TypedLinkedList(new Name_Cast());
00046 private PInterfaceBody _interfaceBody_;
00047
00048 private class Modifier_Cast implements Cast
00049 {
00050 public Object cast(Object o)
00051 {
00052 PModifier node = (PModifier) o;
00053
00054 if((node.parent() != null) &&
00055 (node.parent() != AInterfaceDeclaration.this))
00056 {
00057 node.parent().removeChild(node);
00058 }
00059
00060 if((node.parent() == null) ||
00061 (node.parent() != AInterfaceDeclaration.this))
00062 {
00063 node.parent(AInterfaceDeclaration.this);
00064 }
00065
00066 return node;
00067 }
00068 }
00069
00070 private class Name_Cast implements Cast
00071 {
00072 public Object cast(Object o)
00073 {
00074 PName node = (PName) o;
00075
00076 if((node.parent() != null) &&
00077 (node.parent() != AInterfaceDeclaration.this))
00078 {
00079 node.parent().removeChild(node);
00080 }
00081
00082 if((node.parent() == null) ||
00083 (node.parent() != AInterfaceDeclaration.this))
00084 {
00085 node.parent(AInterfaceDeclaration.this);
00086 }
00087
00088 return node;
00089 }
00090 }
00091 public AInterfaceDeclaration()
00092 {
00093 }
00094 public AInterfaceDeclaration(
00095 List _modifier_,
00096 TInterface _interface_,
00097 TId _id_,
00098 TExtends _extends_,
00099 List _name_,
00100 PInterfaceBody _interfaceBody_)
00101 {
00102 {
00103 Object temp[] = _modifier_.toArray();
00104 for(int i = 0; i < temp.length; i++)
00105 {
00106 this._modifier_.add(temp[i]);
00107 }
00108 }
00109
00110 setInterface(_interface_);
00111
00112 setId(_id_);
00113
00114 setExtends(_extends_);
00115
00116 {
00117 Object temp[] = _name_.toArray();
00118 for(int i = 0; i < temp.length; i++)
00119 {
00120 this._name_.add(temp[i]);
00121 }
00122 }
00123
00124 setInterfaceBody(_interfaceBody_);
00125
00126 }
00127 public AInterfaceDeclaration(
00128 XPModifier _modifier_,
00129 TInterface _interface_,
00130 TId _id_,
00131 TExtends _extends_,
00132 XPName _name_,
00133 PInterfaceBody _interfaceBody_)
00134 {
00135 if(_modifier_ != null)
00136 {
00137 while(_modifier_ instanceof X1PModifier)
00138 {
00139 this._modifier_.addFirst(((X1PModifier) _modifier_).getPModifier());
00140 _modifier_ = ((X1PModifier) _modifier_).getXPModifier();
00141 }
00142 this._modifier_.addFirst(((X2PModifier) _modifier_).getPModifier());
00143 }
00144
00145 setInterface(_interface_);
00146
00147 setId(_id_);
00148
00149 setExtends(_extends_);
00150
00151 if(_name_ != null)
00152 {
00153 while(_name_ instanceof X1PName)
00154 {
00155 this._name_.addFirst(((X1PName) _name_).getPName());
00156 _name_ = ((X1PName) _name_).getXPName();
00157 }
00158 this._name_.addFirst(((X2PName) _name_).getPName());
00159 }
00160
00161 setInterfaceBody(_interfaceBody_);
00162
00163 }
00164 public void apply(Switch sw)
00165 {
00166 ((Analysis) sw).caseAInterfaceDeclaration(this);
00167 }
00168 public Object clone()
00169 {
00170 return new AInterfaceDeclaration(
00171 cloneList(_modifier_),
00172 (TInterface) cloneNode(_interface_),
00173 (TId) cloneNode(_id_),
00174 (TExtends) cloneNode(_extends_),
00175 cloneList(_name_),
00176 (PInterfaceBody) cloneNode(_interfaceBody_));
00177 }
00178 public TExtends getExtends()
00179 {
00180 return _extends_;
00181 }
00182 public TId getId()
00183 {
00184 return _id_;
00185 }
00186 public TInterface getInterface()
00187 {
00188 return _interface_;
00189 }
00190 public PInterfaceBody getInterfaceBody()
00191 {
00192 return _interfaceBody_;
00193 }
00194 public LinkedList getModifier()
00195 {
00196 return _modifier_;
00197 }
00198 public LinkedList getName()
00199 {
00200 return _name_;
00201 }
00202 void removeChild(Node child)
00203 {
00204 if(_modifier_.remove(child))
00205 {
00206 return;
00207 }
00208
00209 if(_interface_ == child)
00210 {
00211 _interface_ = null;
00212 return;
00213 }
00214
00215 if(_id_ == child)
00216 {
00217 _id_ = null;
00218 return;
00219 }
00220
00221 if(_extends_ == child)
00222 {
00223 _extends_ = null;
00224 return;
00225 }
00226
00227 if(_name_.remove(child))
00228 {
00229 return;
00230 }
00231
00232 if(_interfaceBody_ == child)
00233 {
00234 _interfaceBody_ = null;
00235 return;
00236 }
00237
00238 }
00239 void replaceChild(Node oldChild, Node newChild)
00240 {
00241 for(ListIterator i = _modifier_.listIterator(); i.hasNext();)
00242 {
00243 if(i.next() == oldChild)
00244 {
00245 if(newChild != null)
00246 {
00247 i.set(newChild);
00248 oldChild.parent(null);
00249 return;
00250 }
00251
00252 i.remove();
00253 oldChild.parent(null);
00254 return;
00255 }
00256 }
00257
00258 if(_interface_ == oldChild)
00259 {
00260 setInterface((TInterface) newChild);
00261 return;
00262 }
00263
00264 if(_id_ == oldChild)
00265 {
00266 setId((TId) newChild);
00267 return;
00268 }
00269
00270 if(_extends_ == oldChild)
00271 {
00272 setExtends((TExtends) newChild);
00273 return;
00274 }
00275
00276 for(ListIterator i = _name_.listIterator(); i.hasNext();)
00277 {
00278 if(i.next() == oldChild)
00279 {
00280 if(newChild != null)
00281 {
00282 i.set(newChild);
00283 oldChild.parent(null);
00284 return;
00285 }
00286
00287 i.remove();
00288 oldChild.parent(null);
00289 return;
00290 }
00291 }
00292
00293 if(_interfaceBody_ == oldChild)
00294 {
00295 setInterfaceBody((PInterfaceBody) newChild);
00296 return;
00297 }
00298
00299 }
00300 public void setExtends(TExtends node)
00301 {
00302 if(_extends_ != null)
00303 {
00304 _extends_.parent(null);
00305 }
00306
00307 if(node != null)
00308 {
00309 if(node.parent() != null)
00310 {
00311 node.parent().removeChild(node);
00312 }
00313
00314 node.parent(this);
00315 }
00316
00317 _extends_ = node;
00318 }
00319 public void setId(TId node)
00320 {
00321 if(_id_ != null)
00322 {
00323 _id_.parent(null);
00324 }
00325
00326 if(node != null)
00327 {
00328 if(node.parent() != null)
00329 {
00330 node.parent().removeChild(node);
00331 }
00332
00333 node.parent(this);
00334 }
00335
00336 _id_ = node;
00337 }
00338 public void setInterface(TInterface node)
00339 {
00340 if(_interface_ != null)
00341 {
00342 _interface_.parent(null);
00343 }
00344
00345 if(node != null)
00346 {
00347 if(node.parent() != null)
00348 {
00349 node.parent().removeChild(node);
00350 }
00351
00352 node.parent(this);
00353 }
00354
00355 _interface_ = node;
00356 }
00357 public void setInterfaceBody(PInterfaceBody node)
00358 {
00359 if(_interfaceBody_ != null)
00360 {
00361 _interfaceBody_.parent(null);
00362 }
00363
00364 if(node != null)
00365 {
00366 if(node.parent() != null)
00367 {
00368 node.parent().removeChild(node);
00369 }
00370
00371 node.parent(this);
00372 }
00373
00374 _interfaceBody_ = node;
00375 }
00376 public void setModifier(List list)
00377 {
00378 Object temp[] = list.toArray();
00379 for(int i = 0; i < temp.length; i++)
00380 {
00381 _modifier_.add(temp[i]);
00382 }
00383 }
00384 public void setName(List list)
00385 {
00386 Object temp[] = list.toArray();
00387 for(int i = 0; i < temp.length; i++)
00388 {
00389 _name_.add(temp[i]);
00390 }
00391 }
00392 public String toString()
00393 {
00394 return ""
00395 + toString(_modifier_)
00396 + toString(_interface_)
00397 + toString(_id_)
00398 + toString(_extends_)
00399 + toString(_name_)
00400 + toString(_interfaceBody_);
00401 }
00402 }