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

AClassOption.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 AClassOption extends PClassOption
00042 {
00043     private TCls _cls_;
00044     private PName _name_;
00045     private TLBrace _lBrace_;
00046     private final LinkedList _fieldOption_ = new TypedLinkedList(new FieldOption_Cast());
00047     private final LinkedList _methodOption_ = new TypedLinkedList(new MethodOption_Cast());
00048     private TRBrace _rBrace_;
00049 
00050     private class FieldOption_Cast implements Cast
00051     {
00052         public Object cast(Object o)
00053         {
00054             PFieldOption node = (PFieldOption) o;
00055 
00056             if((node.parent() != null) &&
00057                 (node.parent() != AClassOption.this))
00058             {
00059                 node.parent().removeChild(node);
00060             }
00061 
00062             if((node.parent() == null) ||
00063                 (node.parent() != AClassOption.this))
00064             {
00065                 node.parent(AClassOption.this);
00066             }
00067 
00068             return node;
00069         }
00070     }
00071 
00072     private class MethodOption_Cast implements Cast
00073     {
00074         public Object cast(Object o)
00075         {
00076             PMethodOption node = (PMethodOption) o;
00077 
00078             if((node.parent() != null) &&
00079                 (node.parent() != AClassOption.this))
00080             {
00081                 node.parent().removeChild(node);
00082             }
00083 
00084             if((node.parent() == null) ||
00085                 (node.parent() != AClassOption.this))
00086             {
00087                 node.parent(AClassOption.this);
00088             }
00089 
00090             return node;
00091         }
00092     }
00093     public AClassOption()
00094     {
00095     }
00096     public AClassOption(
00097         TCls _cls_,
00098         PName _name_,
00099         TLBrace _lBrace_,
00100         XPFieldOption _fieldOption_,
00101         XPMethodOption _methodOption_,
00102         TRBrace _rBrace_)
00103     {
00104         setCls(_cls_);
00105 
00106         setName(_name_);
00107 
00108         setLBrace(_lBrace_);
00109 
00110         if(_fieldOption_ != null)
00111         {
00112             while(_fieldOption_ instanceof X1PFieldOption)
00113             {
00114                 this._fieldOption_.addFirst(((X1PFieldOption) _fieldOption_).getPFieldOption());
00115                 _fieldOption_ = ((X1PFieldOption) _fieldOption_).getXPFieldOption();
00116             }
00117             this._fieldOption_.addFirst(((X2PFieldOption) _fieldOption_).getPFieldOption());
00118         }
00119 
00120         if(_methodOption_ != null)
00121         {
00122             while(_methodOption_ instanceof X1PMethodOption)
00123             {
00124                 this._methodOption_.addFirst(((X1PMethodOption) _methodOption_).getPMethodOption());
00125                 _methodOption_ = ((X1PMethodOption) _methodOption_).getXPMethodOption();
00126             }
00127             this._methodOption_.addFirst(((X2PMethodOption) _methodOption_).getPMethodOption());
00128         }
00129 
00130         setRBrace(_rBrace_);
00131 
00132     }
00133     public AClassOption(
00134         TCls _cls_,
00135         PName _name_,
00136         TLBrace _lBrace_,
00137         List _fieldOption_,
00138         List _methodOption_,
00139         TRBrace _rBrace_)
00140     {
00141         setCls(_cls_);
00142 
00143         setName(_name_);
00144 
00145         setLBrace(_lBrace_);
00146 
00147         {
00148             Object temp[] = _fieldOption_.toArray();
00149             for(int i = 0; i < temp.length; i++)
00150             {
00151                 this._fieldOption_.add(temp[i]);
00152             }
00153         }
00154 
00155         {
00156             Object temp[] = _methodOption_.toArray();
00157             for(int i = 0; i < temp.length; i++)
00158             {
00159                 this._methodOption_.add(temp[i]);
00160             }
00161         }
00162 
00163         setRBrace(_rBrace_);
00164 
00165     }
00166     public void apply(Switch sw)
00167     {
00168         ((Analysis) sw).caseAClassOption(this);
00169     }
00170     public Object clone()
00171     {
00172         return new AClassOption(
00173             (TCls) cloneNode(_cls_),
00174             (PName) cloneNode(_name_),
00175             (TLBrace) cloneNode(_lBrace_),
00176             cloneList(_fieldOption_),
00177             cloneList(_methodOption_),
00178             (TRBrace) cloneNode(_rBrace_));
00179     }
00180     public TCls getCls()
00181     {
00182         return _cls_;
00183     }
00184     public LinkedList getFieldOption()
00185     {
00186         return _fieldOption_;
00187     }
00188     public TLBrace getLBrace()
00189     {
00190         return _lBrace_;
00191     }
00192     public LinkedList getMethodOption()
00193     {
00194         return _methodOption_;
00195     }
00196     public PName getName()
00197     {
00198         return _name_;
00199     }
00200     public TRBrace getRBrace()
00201     {
00202         return _rBrace_;
00203     }
00204     void removeChild(Node child)
00205     {
00206         if(_cls_ == child)
00207         {
00208             _cls_ = null;
00209             return;
00210         }
00211 
00212         if(_name_ == child)
00213         {
00214             _name_ = null;
00215             return;
00216         }
00217 
00218         if(_lBrace_ == child)
00219         {
00220             _lBrace_ = null;
00221             return;
00222         }
00223 
00224         if(_fieldOption_.remove(child))
00225         {
00226             return;
00227         }
00228 
00229         if(_methodOption_.remove(child))
00230         {
00231             return;
00232         }
00233 
00234         if(_rBrace_ == child)
00235         {
00236             _rBrace_ = null;
00237             return;
00238         }
00239 
00240     }
00241     void replaceChild(Node oldChild, Node newChild)
00242     {
00243         if(_cls_ == oldChild)
00244         {
00245             setCls((TCls) newChild);
00246             return;
00247         }
00248 
00249         if(_name_ == oldChild)
00250         {
00251             setName((PName) newChild);
00252             return;
00253         }
00254 
00255         if(_lBrace_ == oldChild)
00256         {
00257             setLBrace((TLBrace) newChild);
00258             return;
00259         }
00260 
00261         for(ListIterator i = _fieldOption_.listIterator(); i.hasNext();)
00262         {
00263             if(i.next() == oldChild)
00264             {
00265                 if(newChild != null)
00266                 {
00267                     i.set(newChild);
00268                     oldChild.parent(null);
00269                     return;
00270                 }
00271 
00272                 i.remove();
00273                 oldChild.parent(null);
00274                 return;
00275             }
00276         }
00277 
00278         for(ListIterator i = _methodOption_.listIterator(); i.hasNext();)
00279         {
00280             if(i.next() == oldChild)
00281             {
00282                 if(newChild != null)
00283                 {
00284                     i.set(newChild);
00285                     oldChild.parent(null);
00286                     return;
00287                 }
00288 
00289                 i.remove();
00290                 oldChild.parent(null);
00291                 return;
00292             }
00293         }
00294 
00295         if(_rBrace_ == oldChild)
00296         {
00297             setRBrace((TRBrace) newChild);
00298             return;
00299         }
00300 
00301     }
00302     public void setCls(TCls node)
00303     {
00304         if(_cls_ != null)
00305         {
00306             _cls_.parent(null);
00307         }
00308 
00309         if(node != null)
00310         {
00311             if(node.parent() != null)
00312             {
00313                 node.parent().removeChild(node);
00314             }
00315 
00316             node.parent(this);
00317         }
00318 
00319         _cls_ = node;
00320     }
00321     public void setFieldOption(List list)
00322     {
00323         Object temp[] = list.toArray();
00324         for(int i = 0; i < temp.length; i++)
00325         {
00326             _fieldOption_.add(temp[i]);
00327         }
00328     }
00329     public void setLBrace(TLBrace node)
00330     {
00331         if(_lBrace_ != null)
00332         {
00333             _lBrace_.parent(null);
00334         }
00335 
00336         if(node != null)
00337         {
00338             if(node.parent() != null)
00339             {
00340                 node.parent().removeChild(node);
00341             }
00342 
00343             node.parent(this);
00344         }
00345 
00346         _lBrace_ = node;
00347     }
00348     public void setMethodOption(List list)
00349     {
00350         Object temp[] = list.toArray();
00351         for(int i = 0; i < temp.length; i++)
00352         {
00353             _methodOption_.add(temp[i]);
00354         }
00355     }
00356     public void setName(PName node)
00357     {
00358         if(_name_ != null)
00359         {
00360             _name_.parent(null);
00361         }
00362 
00363         if(node != null)
00364         {
00365             if(node.parent() != null)
00366             {
00367                 node.parent().removeChild(node);
00368             }
00369 
00370             node.parent(this);
00371         }
00372 
00373         _name_ = node;
00374     }
00375     public void setRBrace(TRBrace node)
00376     {
00377         if(_rBrace_ != null)
00378         {
00379             _rBrace_.parent(null);
00380         }
00381 
00382         if(node != null)
00383         {
00384             if(node.parent() != null)
00385             {
00386                 node.parent().removeChild(node);
00387             }
00388 
00389             node.parent(this);
00390         }
00391 
00392         _rBrace_ = node;
00393     }
00394     public String toString()
00395     {
00396         return ""
00397             + toString(_cls_)
00398             + toString(_name_)
00399             + toString(_lBrace_)
00400             + toString(_fieldOption_)
00401             + toString(_methodOption_)
00402             + toString(_rBrace_);
00403     }
00404 }

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