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