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

AClassDeclaration.java

00001 package edu.ksu.cis.bandera.jjjc.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 import ca.mcgill.sable.util.*;
00037 import edu.ksu.cis.bandera.jjjc.analysis.*;
00038 
00039 public final class AClassDeclaration extends PClassDeclaration
00040 {
00041     private final LinkedList _modifier_ = new TypedLinkedList(new Modifier_Cast());
00042     private TClass _tClass_;
00043     private TId _id_;
00044     private PSuper _super_;
00045     private PInterfaces _interfaces_;
00046     private PClassBody _classBody_;
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() != AClassDeclaration.this))
00056             {
00057                 node.parent().removeChild(node);
00058             }
00059 
00060             if((node.parent() == null) ||
00061                 (node.parent() != AClassDeclaration.this))
00062             {
00063                 node.parent(AClassDeclaration.this);
00064             }
00065 
00066             return node;
00067         }
00068     }
00069     public AClassDeclaration()
00070     {
00071     }
00072     public AClassDeclaration(
00073         List _modifier_,
00074         TClass _tClass_,
00075         TId _id_,
00076         PSuper _super_,
00077         PInterfaces _interfaces_,
00078         PClassBody _classBody_)
00079     {
00080         {
00081             Object temp[] = _modifier_.toArray();
00082             for(int i = 0; i < temp.length; i++)
00083             {
00084                 this._modifier_.add(temp[i]);
00085             }
00086         }
00087 
00088         setTClass(_tClass_);
00089 
00090         setId(_id_);
00091 
00092         setSuper(_super_);
00093 
00094         setInterfaces(_interfaces_);
00095 
00096         setClassBody(_classBody_);
00097 
00098     }
00099     public AClassDeclaration(
00100         XPModifier _modifier_,
00101         TClass _tClass_,
00102         TId _id_,
00103         PSuper _super_,
00104         PInterfaces _interfaces_,
00105         PClassBody _classBody_)
00106     {
00107         if(_modifier_ != null)
00108         {
00109             while(_modifier_ instanceof X1PModifier)
00110             {
00111                 this._modifier_.addFirst(((X1PModifier) _modifier_).getPModifier());
00112                 _modifier_ = ((X1PModifier) _modifier_).getXPModifier();
00113             }
00114             this._modifier_.addFirst(((X2PModifier) _modifier_).getPModifier());
00115         }
00116 
00117         setTClass(_tClass_);
00118 
00119         setId(_id_);
00120 
00121         setSuper(_super_);
00122 
00123         setInterfaces(_interfaces_);
00124 
00125         setClassBody(_classBody_);
00126 
00127     }
00128     public void apply(Switch sw)
00129     {
00130         ((Analysis) sw).caseAClassDeclaration(this);
00131     }
00132     public Object clone()
00133     {
00134         return new AClassDeclaration(
00135             cloneList(_modifier_),
00136             (TClass) cloneNode(_tClass_),
00137             (TId) cloneNode(_id_),
00138             (PSuper) cloneNode(_super_),
00139             (PInterfaces) cloneNode(_interfaces_),
00140             (PClassBody) cloneNode(_classBody_));
00141     }
00142     public PClassBody getClassBody()
00143     {
00144         return _classBody_;
00145     }
00146     public TId getId()
00147     {
00148         return _id_;
00149     }
00150     public PInterfaces getInterfaces()
00151     {
00152         return _interfaces_;
00153     }
00154     public LinkedList getModifier()
00155     {
00156         return _modifier_;
00157     }
00158     public PSuper getSuper()
00159     {
00160         return _super_;
00161     }
00162     public TClass getTClass()
00163     {
00164         return _tClass_;
00165     }
00166     void removeChild(Node child)
00167     {
00168         if(_modifier_.remove(child))
00169         {
00170             return;
00171         }
00172 
00173         if(_tClass_ == child)
00174         {
00175             _tClass_ = null;
00176             return;
00177         }
00178 
00179         if(_id_ == child)
00180         {
00181             _id_ = null;
00182             return;
00183         }
00184 
00185         if(_super_ == child)
00186         {
00187             _super_ = null;
00188             return;
00189         }
00190 
00191         if(_interfaces_ == child)
00192         {
00193             _interfaces_ = null;
00194             return;
00195         }
00196 
00197         if(_classBody_ == child)
00198         {
00199             _classBody_ = null;
00200             return;
00201         }
00202 
00203     }
00204     void replaceChild(Node oldChild, Node newChild)
00205     {
00206         for(ListIterator i = _modifier_.listIterator(); i.hasNext();)
00207         {
00208             if(i.next() == oldChild)
00209             {
00210                 if(newChild != null)
00211                 {
00212                     i.set(newChild);
00213                     oldChild.parent(null);
00214                     return;
00215                 }
00216 
00217                 i.remove();
00218                 oldChild.parent(null);
00219                 return;
00220             }
00221         }
00222 
00223         if(_tClass_ == oldChild)
00224         {
00225             setTClass((TClass) newChild);
00226             return;
00227         }
00228 
00229         if(_id_ == oldChild)
00230         {
00231             setId((TId) newChild);
00232             return;
00233         }
00234 
00235         if(_super_ == oldChild)
00236         {
00237             setSuper((PSuper) newChild);
00238             return;
00239         }
00240 
00241         if(_interfaces_ == oldChild)
00242         {
00243             setInterfaces((PInterfaces) newChild);
00244             return;
00245         }
00246 
00247         if(_classBody_ == oldChild)
00248         {
00249             setClassBody((PClassBody) newChild);
00250             return;
00251         }
00252 
00253     }
00254     public void setClassBody(PClassBody node)
00255     {
00256         if(_classBody_ != null)
00257         {
00258             _classBody_.parent(null);
00259         }
00260 
00261         if(node != null)
00262         {
00263             if(node.parent() != null)
00264             {
00265                 node.parent().removeChild(node);
00266             }
00267 
00268             node.parent(this);
00269         }
00270 
00271         _classBody_ = node;
00272     }
00273     public void setId(TId node)
00274     {
00275         if(_id_ != null)
00276         {
00277             _id_.parent(null);
00278         }
00279 
00280         if(node != null)
00281         {
00282             if(node.parent() != null)
00283             {
00284                 node.parent().removeChild(node);
00285             }
00286 
00287             node.parent(this);
00288         }
00289 
00290         _id_ = node;
00291     }
00292     public void setInterfaces(PInterfaces node)
00293     {
00294         if(_interfaces_ != null)
00295         {
00296             _interfaces_.parent(null);
00297         }
00298 
00299         if(node != null)
00300         {
00301             if(node.parent() != null)
00302             {
00303                 node.parent().removeChild(node);
00304             }
00305 
00306             node.parent(this);
00307         }
00308 
00309         _interfaces_ = node;
00310     }
00311     public void setModifier(List list)
00312     {
00313         Object temp[] = list.toArray();
00314         for(int i = 0; i < temp.length; i++)
00315         {
00316             _modifier_.add(temp[i]);
00317         }
00318     }
00319     public void setSuper(PSuper node)
00320     {
00321         if(_super_ != null)
00322         {
00323             _super_.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         _super_ = node;
00337     }
00338     public void setTClass(TClass node)
00339     {
00340         if(_tClass_ != null)
00341         {
00342             _tClass_.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         _tClass_ = node;
00356     }
00357     public String toString()
00358     {
00359         return ""
00360             + toString(_modifier_)
00361             + toString(_tClass_)
00362             + toString(_id_)
00363             + toString(_super_)
00364             + toString(_interfaces_)
00365             + toString(_classBody_);
00366     }
00367 }

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