Main Page   Packages   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

AMethodOption.java

00001 package edu.ksu.cis.bandera.abstraction.options.node;
00002 
00003 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00004  * Bandera, a Java(TM) analysis and transformation toolkit           *
00005  * Copyright (C) 1998-2001 SAnToS Laboratories (santos@cis.ksu.edu)  *
00006 
00007  * All rights reserved.                                              *
00008  *                                                                   *
00009  * This work was done as a project in the SAnToS Laboratory,         *
00010  * Department of Computing and Information Sciences, Kansas State    *
00011  * University, USA (http://www.cis.ksu.edu/santos).                  *
00012  * It is understood that any modification not identified as such is  *
00013  * not covered by the preceding statement.                           *
00014  *                                                                   *
00015  * This work is free software; you can redistribute it and/or        *
00016  * modify it under the terms of the GNU Library General Public       *
00017  * License as published by the Free Software Foundation; either      *
00018  * version 2 of the License, or (at your option) any later version.  *
00019  *                                                                   *
00020  * This work is distributed in the hope that it will be useful,      *
00021  * but WITHOUT ANY WARRANTY; without even the implied warranty of    *
00022  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU *
00023  * Library General Public License for more details.                  *
00024  *                                                                   *
00025  * You should have received a copy of the GNU Library General Public *
00026  * License along with this toolkit; if not, write to the             *
00027  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,      *
00028  * Boston, MA  02111-1307, USA.                                      *
00029  *                                                                   *
00030  * Java is a trademark of Sun Microsystems, Inc.                     *
00031  *                                                                   *
00032  * To submit a bug report, send a comment, or get the latest news on *
00033  * this project and other SAnToS projects, please visit the web-site *
00034  *                http://www.cis.ksu.edu/santos                      *
00035  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00036 /* This file was generated by SableCC (http://www.sable.mcgill.ca/sablecc/). */
00037 
00038 import java.util.*;
00039 import edu.ksu.cis.bandera.abstraction.options.analysis.*;
00040 
00041 public final class AMethodOption extends PMethodOption
00042 {
00043     private TId _id_;
00044     private TLParen _lParen_;
00045     private PParams _params_;
00046     private TRParen _rParen_;
00047     private TLBrace _lBrace_;
00048     private final LinkedList _localOption_ = new TypedLinkedList(new LocalOption_Cast());
00049     private TRBrace _rBrace_;
00050 
00051     private class LocalOption_Cast implements Cast
00052     {
00053         public Object cast(Object o)
00054         {
00055             PLocalOption node = (PLocalOption) o;
00056 
00057             if((node.parent() != null) &&
00058                 (node.parent() != AMethodOption.this))
00059             {
00060                 node.parent().removeChild(node);
00061             }
00062 
00063             if((node.parent() == null) ||
00064                 (node.parent() != AMethodOption.this))
00065             {
00066                 node.parent(AMethodOption.this);
00067             }
00068 
00069             return node;
00070         }
00071     }
00072     public AMethodOption()
00073     {
00074     }
00075     public AMethodOption(
00076         TId _id_,
00077         TLParen _lParen_,
00078         PParams _params_,
00079         TRParen _rParen_,
00080         TLBrace _lBrace_,
00081         XPLocalOption _localOption_,
00082         TRBrace _rBrace_)
00083     {
00084         setId(_id_);
00085 
00086         setLParen(_lParen_);
00087 
00088         setParams(_params_);
00089 
00090         setRParen(_rParen_);
00091 
00092         setLBrace(_lBrace_);
00093 
00094         if(_localOption_ != null)
00095         {
00096             while(_localOption_ instanceof X1PLocalOption)
00097             {
00098                 this._localOption_.addFirst(((X1PLocalOption) _localOption_).getPLocalOption());
00099                 _localOption_ = ((X1PLocalOption) _localOption_).getXPLocalOption();
00100             }
00101             this._localOption_.addFirst(((X2PLocalOption) _localOption_).getPLocalOption());
00102         }
00103 
00104         setRBrace(_rBrace_);
00105 
00106     }
00107     public AMethodOption(
00108         TId _id_,
00109         TLParen _lParen_,
00110         PParams _params_,
00111         TRParen _rParen_,
00112         TLBrace _lBrace_,
00113         List _localOption_,
00114         TRBrace _rBrace_)
00115     {
00116         setId(_id_);
00117 
00118         setLParen(_lParen_);
00119 
00120         setParams(_params_);
00121 
00122         setRParen(_rParen_);
00123 
00124         setLBrace(_lBrace_);
00125 
00126         {
00127             Object temp[] = _localOption_.toArray();
00128             for(int i = 0; i < temp.length; i++)
00129             {
00130                 this._localOption_.add(temp[i]);
00131             }
00132         }
00133 
00134         setRBrace(_rBrace_);
00135 
00136     }
00137     public void apply(Switch sw)
00138     {
00139         ((Analysis) sw).caseAMethodOption(this);
00140     }
00141     public Object clone()
00142     {
00143         return new AMethodOption(
00144             (TId) cloneNode(_id_),
00145             (TLParen) cloneNode(_lParen_),
00146             (PParams) cloneNode(_params_),
00147             (TRParen) cloneNode(_rParen_),
00148             (TLBrace) cloneNode(_lBrace_),
00149             cloneList(_localOption_),
00150             (TRBrace) cloneNode(_rBrace_));
00151     }
00152     public TId getId()
00153     {
00154         return _id_;
00155     }
00156     public TLBrace getLBrace()
00157     {
00158         return _lBrace_;
00159     }
00160     public LinkedList getLocalOption()
00161     {
00162         return _localOption_;
00163     }
00164     public TLParen getLParen()
00165     {
00166         return _lParen_;
00167     }
00168     public PParams getParams()
00169     {
00170         return _params_;
00171     }
00172     public TRBrace getRBrace()
00173     {
00174         return _rBrace_;
00175     }
00176     public TRParen getRParen()
00177     {
00178         return _rParen_;
00179     }
00180     void removeChild(Node child)
00181     {
00182         if(_id_ == child)
00183         {
00184             _id_ = null;
00185             return;
00186         }
00187 
00188         if(_lParen_ == child)
00189         {
00190             _lParen_ = null;
00191             return;
00192         }
00193 
00194         if(_params_ == child)
00195         {
00196             _params_ = null;
00197             return;
00198         }
00199 
00200         if(_rParen_ == child)
00201         {
00202             _rParen_ = null;
00203             return;
00204         }
00205 
00206         if(_lBrace_ == child)
00207         {
00208             _lBrace_ = null;
00209             return;
00210         }
00211 
00212         if(_localOption_.remove(child))
00213         {
00214             return;
00215         }
00216 
00217         if(_rBrace_ == child)
00218         {
00219             _rBrace_ = null;
00220             return;
00221         }
00222 
00223     }
00224     void replaceChild(Node oldChild, Node newChild)
00225     {
00226         if(_id_ == oldChild)
00227         {
00228             setId((TId) newChild);
00229             return;
00230         }
00231 
00232         if(_lParen_ == oldChild)
00233         {
00234             setLParen((TLParen) newChild);
00235             return;
00236         }
00237 
00238         if(_params_ == oldChild)
00239         {
00240             setParams((PParams) newChild);
00241             return;
00242         }
00243 
00244         if(_rParen_ == oldChild)
00245         {
00246             setRParen((TRParen) newChild);
00247             return;
00248         }
00249 
00250         if(_lBrace_ == oldChild)
00251         {
00252             setLBrace((TLBrace) newChild);
00253             return;
00254         }
00255 
00256         for(ListIterator i = _localOption_.listIterator(); i.hasNext();)
00257         {
00258             if(i.next() == oldChild)
00259             {
00260                 if(newChild != null)
00261                 {
00262                     i.set(newChild);
00263                     oldChild.parent(null);
00264                     return;
00265                 }
00266 
00267                 i.remove();
00268                 oldChild.parent(null);
00269                 return;
00270             }
00271         }
00272 
00273         if(_rBrace_ == oldChild)
00274         {
00275             setRBrace((TRBrace) newChild);
00276             return;
00277         }
00278 
00279     }
00280     public void setId(TId node)
00281     {
00282         if(_id_ != null)
00283         {
00284             _id_.parent(null);
00285         }
00286 
00287         if(node != null)
00288         {
00289             if(node.parent() != null)
00290             {
00291                 node.parent().removeChild(node);
00292             }
00293 
00294             node.parent(this);
00295         }
00296 
00297         _id_ = node;
00298     }
00299     public void setLBrace(TLBrace node)
00300     {
00301         if(_lBrace_ != null)
00302         {
00303             _lBrace_.parent(null);
00304         }
00305 
00306         if(node != null)
00307         {
00308             if(node.parent() != null)
00309             {
00310                 node.parent().removeChild(node);
00311             }
00312 
00313             node.parent(this);
00314         }
00315 
00316         _lBrace_ = node;
00317     }
00318     public void setLocalOption(List list)
00319     {
00320         Object temp[] = list.toArray();
00321         for(int i = 0; i < temp.length; i++)
00322         {
00323             _localOption_.add(temp[i]);
00324         }
00325     }
00326     public void setLParen(TLParen node)
00327     {
00328         if(_lParen_ != null)
00329         {
00330             _lParen_.parent(null);
00331         }
00332 
00333         if(node != null)
00334         {
00335             if(node.parent() != null)
00336             {
00337                 node.parent().removeChild(node);
00338             }
00339 
00340             node.parent(this);
00341         }
00342 
00343         _lParen_ = node;
00344     }
00345     public void setParams(PParams node)
00346     {
00347         if(_params_ != null)
00348         {
00349             _params_.parent(null);
00350         }
00351 
00352         if(node != null)
00353         {
00354             if(node.parent() != null)
00355             {
00356                 node.parent().removeChild(node);
00357             }
00358 
00359             node.parent(this);
00360         }
00361 
00362         _params_ = node;
00363     }
00364     public void setRBrace(TRBrace node)
00365     {
00366         if(_rBrace_ != null)
00367         {
00368             _rBrace_.parent(null);
00369         }
00370 
00371         if(node != null)
00372         {
00373             if(node.parent() != null)
00374             {
00375                 node.parent().removeChild(node);
00376             }
00377 
00378             node.parent(this);
00379         }
00380 
00381         _rBrace_ = node;
00382     }
00383     public void setRParen(TRParen node)
00384     {
00385         if(_rParen_ != null)
00386         {
00387             _rParen_.parent(null);
00388         }
00389 
00390         if(node != null)
00391         {
00392             if(node.parent() != null)
00393             {
00394                 node.parent().removeChild(node);
00395             }
00396 
00397             node.parent(this);
00398         }
00399 
00400         _rParen_ = node;
00401     }
00402     public String toString()
00403     {
00404         return ""
00405             + toString(_id_)
00406             + toString(_lParen_)
00407             + toString(_params_)
00408             + toString(_rParen_)
00409             + toString(_lBrace_)
00410             + toString(_localOption_)
00411             + toString(_rBrace_);
00412     }
00413 }

Generated at Thu Feb 7 06:37:52 2002 for Bandera by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001