00001 package edu.ksu.cis.bandera.specification.predicate.node;
00002
00003
00004
00005 import java.util.*;
00006 import edu.ksu.cis.bandera.specification.predicate.analysis.*;
00007
00008 public final class ALocationPropositionDefinition extends PPropositionDefinition
00009 {
00010 private TLocation _location_;
00011 private TLBracket _lBracket_;
00012 private TId _label_;
00013 private TRBracket _rBracket_;
00014 private TId _id_;
00015 private TLParen _lParen_;
00016 private PParams _params_;
00017 private TRParen _rParen_;
00018 private PColonExp _colonExp_;
00019 private TSemicolon _semicolon_;
00020 private final LinkedList _comment_ = new TypedLinkedList(new Comment_Cast());
00021
00022 private class Comment_Cast implements Cast
00023 {
00024 public Object cast(Object o)
00025 {
00026 PComment node = (PComment) o;
00027
00028 if((node.parent() != null) &&
00029 (node.parent() != ALocationPropositionDefinition.this))
00030 {
00031 node.parent().removeChild(node);
00032 }
00033
00034 if((node.parent() == null) ||
00035 (node.parent() != ALocationPropositionDefinition.this))
00036 {
00037 node.parent(ALocationPropositionDefinition.this);
00038 }
00039
00040 return node;
00041 }
00042 }
00043 public ALocationPropositionDefinition()
00044 {
00045 }
00046 public ALocationPropositionDefinition(
00047 TLocation _location_,
00048 TLBracket _lBracket_,
00049 TId _label_,
00050 TRBracket _rBracket_,
00051 TId _id_,
00052 TLParen _lParen_,
00053 PParams _params_,
00054 TRParen _rParen_,
00055 PColonExp _colonExp_,
00056 TSemicolon _semicolon_,
00057 XPComment _comment_)
00058 {
00059 setLocation(_location_);
00060
00061 setLBracket(_lBracket_);
00062
00063 setLabel(_label_);
00064
00065 setRBracket(_rBracket_);
00066
00067 setId(_id_);
00068
00069 setLParen(_lParen_);
00070
00071 setParams(_params_);
00072
00073 setRParen(_rParen_);
00074
00075 setColonExp(_colonExp_);
00076
00077 setSemicolon(_semicolon_);
00078
00079 if(_comment_ != null)
00080 {
00081 while(_comment_ instanceof X1PComment)
00082 {
00083 this._comment_.addFirst(((X1PComment) _comment_).getPComment());
00084 _comment_ = ((X1PComment) _comment_).getXPComment();
00085 }
00086 this._comment_.addFirst(((X2PComment) _comment_).getPComment());
00087 }
00088
00089 }
00090 public ALocationPropositionDefinition(
00091 TLocation _location_,
00092 TLBracket _lBracket_,
00093 TId _label_,
00094 TRBracket _rBracket_,
00095 TId _id_,
00096 TLParen _lParen_,
00097 PParams _params_,
00098 TRParen _rParen_,
00099 PColonExp _colonExp_,
00100 TSemicolon _semicolon_,
00101 List _comment_)
00102 {
00103 setLocation(_location_);
00104
00105 setLBracket(_lBracket_);
00106
00107 setLabel(_label_);
00108
00109 setRBracket(_rBracket_);
00110
00111 setId(_id_);
00112
00113 setLParen(_lParen_);
00114
00115 setParams(_params_);
00116
00117 setRParen(_rParen_);
00118
00119 setColonExp(_colonExp_);
00120
00121 setSemicolon(_semicolon_);
00122
00123 {
00124 Object temp[] = _comment_.toArray();
00125 for(int i = 0; i < temp.length; i++)
00126 {
00127 this._comment_.add(temp[i]);
00128 }
00129 }
00130
00131 }
00132 public void apply(Switch sw)
00133 {
00134 ((Analysis) sw).caseALocationPropositionDefinition(this);
00135 }
00136 public Object clone()
00137 {
00138 return new ALocationPropositionDefinition(
00139 (TLocation) cloneNode(_location_),
00140 (TLBracket) cloneNode(_lBracket_),
00141 (TId) cloneNode(_label_),
00142 (TRBracket) cloneNode(_rBracket_),
00143 (TId) cloneNode(_id_),
00144 (TLParen) cloneNode(_lParen_),
00145 (PParams) cloneNode(_params_),
00146 (TRParen) cloneNode(_rParen_),
00147 (PColonExp) cloneNode(_colonExp_),
00148 (TSemicolon) cloneNode(_semicolon_),
00149 cloneList(_comment_));
00150 }
00151 public PColonExp getColonExp()
00152 {
00153 return _colonExp_;
00154 }
00155 public LinkedList getComment()
00156 {
00157 return _comment_;
00158 }
00159 public TId getId()
00160 {
00161 return _id_;
00162 }
00163 public TId getLabel()
00164 {
00165 return _label_;
00166 }
00167 public TLBracket getLBracket()
00168 {
00169 return _lBracket_;
00170 }
00171 public TLocation getLocation()
00172 {
00173 return _location_;
00174 }
00175 public TLParen getLParen()
00176 {
00177 return _lParen_;
00178 }
00179 public PParams getParams()
00180 {
00181 return _params_;
00182 }
00183 public TRBracket getRBracket()
00184 {
00185 return _rBracket_;
00186 }
00187 public TRParen getRParen()
00188 {
00189 return _rParen_;
00190 }
00191 public TSemicolon getSemicolon()
00192 {
00193 return _semicolon_;
00194 }
00195 void removeChild(Node child)
00196 {
00197 if(_location_ == child)
00198 {
00199 _location_ = null;
00200 return;
00201 }
00202
00203 if(_lBracket_ == child)
00204 {
00205 _lBracket_ = null;
00206 return;
00207 }
00208
00209 if(_label_ == child)
00210 {
00211 _label_ = null;
00212 return;
00213 }
00214
00215 if(_rBracket_ == child)
00216 {
00217 _rBracket_ = null;
00218 return;
00219 }
00220
00221 if(_id_ == child)
00222 {
00223 _id_ = null;
00224 return;
00225 }
00226
00227 if(_lParen_ == child)
00228 {
00229 _lParen_ = null;
00230 return;
00231 }
00232
00233 if(_params_ == child)
00234 {
00235 _params_ = null;
00236 return;
00237 }
00238
00239 if(_rParen_ == child)
00240 {
00241 _rParen_ = null;
00242 return;
00243 }
00244
00245 if(_colonExp_ == child)
00246 {
00247 _colonExp_ = null;
00248 return;
00249 }
00250
00251 if(_semicolon_ == child)
00252 {
00253 _semicolon_ = null;
00254 return;
00255 }
00256
00257 if(_comment_.remove(child))
00258 {
00259 return;
00260 }
00261
00262 }
00263 void replaceChild(Node oldChild, Node newChild)
00264 {
00265 if(_location_ == oldChild)
00266 {
00267 setLocation((TLocation) newChild);
00268 return;
00269 }
00270
00271 if(_lBracket_ == oldChild)
00272 {
00273 setLBracket((TLBracket) newChild);
00274 return;
00275 }
00276
00277 if(_label_ == oldChild)
00278 {
00279 setLabel((TId) newChild);
00280 return;
00281 }
00282
00283 if(_rBracket_ == oldChild)
00284 {
00285 setRBracket((TRBracket) newChild);
00286 return;
00287 }
00288
00289 if(_id_ == oldChild)
00290 {
00291 setId((TId) newChild);
00292 return;
00293 }
00294
00295 if(_lParen_ == oldChild)
00296 {
00297 setLParen((TLParen) newChild);
00298 return;
00299 }
00300
00301 if(_params_ == oldChild)
00302 {
00303 setParams((PParams) newChild);
00304 return;
00305 }
00306
00307 if(_rParen_ == oldChild)
00308 {
00309 setRParen((TRParen) newChild);
00310 return;
00311 }
00312
00313 if(_colonExp_ == oldChild)
00314 {
00315 setColonExp((PColonExp) newChild);
00316 return;
00317 }
00318
00319 if(_semicolon_ == oldChild)
00320 {
00321 setSemicolon((TSemicolon) newChild);
00322 return;
00323 }
00324
00325 for(ListIterator i = _comment_.listIterator(); i.hasNext();)
00326 {
00327 if(i.next() == oldChild)
00328 {
00329 if(newChild != null)
00330 {
00331 i.set(newChild);
00332 oldChild.parent(null);
00333 return;
00334 }
00335
00336 i.remove();
00337 oldChild.parent(null);
00338 return;
00339 }
00340 }
00341
00342 }
00343 public void setColonExp(PColonExp node)
00344 {
00345 if(_colonExp_ != null)
00346 {
00347 _colonExp_.parent(null);
00348 }
00349
00350 if(node != null)
00351 {
00352 if(node.parent() != null)
00353 {
00354 node.parent().removeChild(node);
00355 }
00356
00357 node.parent(this);
00358 }
00359
00360 _colonExp_ = node;
00361 }
00362 public void setComment(List list)
00363 {
00364 Object temp[] = list.toArray();
00365 for(int i = 0; i < temp.length; i++)
00366 {
00367 _comment_.add(temp[i]);
00368 }
00369 }
00370 public void setId(TId node)
00371 {
00372 if(_id_ != null)
00373 {
00374 _id_.parent(null);
00375 }
00376
00377 if(node != null)
00378 {
00379 if(node.parent() != null)
00380 {
00381 node.parent().removeChild(node);
00382 }
00383
00384 node.parent(this);
00385 }
00386
00387 _id_ = node;
00388 }
00389 public void setLabel(TId node)
00390 {
00391 if(_label_ != null)
00392 {
00393 _label_.parent(null);
00394 }
00395
00396 if(node != null)
00397 {
00398 if(node.parent() != null)
00399 {
00400 node.parent().removeChild(node);
00401 }
00402
00403 node.parent(this);
00404 }
00405
00406 _label_ = node;
00407 }
00408 public void setLBracket(TLBracket node)
00409 {
00410 if(_lBracket_ != null)
00411 {
00412 _lBracket_.parent(null);
00413 }
00414
00415 if(node != null)
00416 {
00417 if(node.parent() != null)
00418 {
00419 node.parent().removeChild(node);
00420 }
00421
00422 node.parent(this);
00423 }
00424
00425 _lBracket_ = node;
00426 }
00427 public void setLocation(TLocation node)
00428 {
00429 if(_location_ != null)
00430 {
00431 _location_.parent(null);
00432 }
00433
00434 if(node != null)
00435 {
00436 if(node.parent() != null)
00437 {
00438 node.parent().removeChild(node);
00439 }
00440
00441 node.parent(this);
00442 }
00443
00444 _location_ = node;
00445 }
00446 public void setLParen(TLParen node)
00447 {
00448 if(_lParen_ != null)
00449 {
00450 _lParen_.parent(null);
00451 }
00452
00453 if(node != null)
00454 {
00455 if(node.parent() != null)
00456 {
00457 node.parent().removeChild(node);
00458 }
00459
00460 node.parent(this);
00461 }
00462
00463 _lParen_ = node;
00464 }
00465 public void setParams(PParams node)
00466 {
00467 if(_params_ != null)
00468 {
00469 _params_.parent(null);
00470 }
00471
00472 if(node != null)
00473 {
00474 if(node.parent() != null)
00475 {
00476 node.parent().removeChild(node);
00477 }
00478
00479 node.parent(this);
00480 }
00481
00482 _params_ = node;
00483 }
00484 public void setRBracket(TRBracket node)
00485 {
00486 if(_rBracket_ != null)
00487 {
00488 _rBracket_.parent(null);
00489 }
00490
00491 if(node != null)
00492 {
00493 if(node.parent() != null)
00494 {
00495 node.parent().removeChild(node);
00496 }
00497
00498 node.parent(this);
00499 }
00500
00501 _rBracket_ = node;
00502 }
00503 public void setRParen(TRParen node)
00504 {
00505 if(_rParen_ != null)
00506 {
00507 _rParen_.parent(null);
00508 }
00509
00510 if(node != null)
00511 {
00512 if(node.parent() != null)
00513 {
00514 node.parent().removeChild(node);
00515 }
00516
00517 node.parent(this);
00518 }
00519
00520 _rParen_ = node;
00521 }
00522 public void setSemicolon(TSemicolon node)
00523 {
00524 if(_semicolon_ != null)
00525 {
00526 _semicolon_.parent(null);
00527 }
00528
00529 if(node != null)
00530 {
00531 if(node.parent() != null)
00532 {
00533 node.parent().removeChild(node);
00534 }
00535
00536 node.parent(this);
00537 }
00538
00539 _semicolon_ = node;
00540 }
00541 public String toString()
00542 {
00543 return ""
00544 + toString(_location_)
00545 + toString(_lBracket_)
00546 + toString(_label_)
00547 + toString(_rBracket_)
00548 + toString(_id_)
00549 + toString(_lParen_)
00550 + toString(_params_)
00551 + toString(_rParen_)
00552 + toString(_colonExp_)
00553 + toString(_semicolon_)
00554 + toString(_comment_);
00555 }
00556 }