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

ASimpleClassInstanceCreationExp.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 ASimpleClassInstanceCreationExp extends PExp
00040 {
00041     private TNew _new_;
00042     private PName _name_;
00043     private TLPar _lPar_;
00044     private final LinkedList _argumentList_ = new TypedLinkedList(new ArgumentList_Cast());
00045     private TRPar _rPar_;
00046     private PClassBody _classBody_;
00047 
00048     private class ArgumentList_Cast implements Cast
00049     {
00050         public Object cast(Object o)
00051         {
00052             PExp node = (PExp) o;
00053 
00054             if((node.parent() != null) &&
00055                 (node.parent() != ASimpleClassInstanceCreationExp.this))
00056             {
00057                 node.parent().removeChild(node);
00058             }
00059 
00060             if((node.parent() == null) ||
00061                 (node.parent() != ASimpleClassInstanceCreationExp.this))
00062             {
00063                 node.parent(ASimpleClassInstanceCreationExp.this);
00064             }
00065 
00066             return node;
00067         }
00068     }
00069     public ASimpleClassInstanceCreationExp()
00070     {
00071     }
00072     public ASimpleClassInstanceCreationExp(
00073         TNew _new_,
00074         PName _name_,
00075         TLPar _lPar_,
00076         List _argumentList_,
00077         TRPar _rPar_,
00078         PClassBody _classBody_)
00079     {
00080         setNew(_new_);
00081 
00082         setName(_name_);
00083 
00084         setLPar(_lPar_);
00085 
00086         {
00087             Object temp[] = _argumentList_.toArray();
00088             for(int i = 0; i < temp.length; i++)
00089             {
00090                 this._argumentList_.add(temp[i]);
00091             }
00092         }
00093 
00094         setRPar(_rPar_);
00095 
00096         setClassBody(_classBody_);
00097 
00098     }
00099     public ASimpleClassInstanceCreationExp(
00100         TNew _new_,
00101         PName _name_,
00102         TLPar _lPar_,
00103         XPExp _argumentList_,
00104         TRPar _rPar_,
00105         PClassBody _classBody_)
00106     {
00107         setNew(_new_);
00108 
00109         setName(_name_);
00110 
00111         setLPar(_lPar_);
00112 
00113         if(_argumentList_ != null)
00114         {
00115             while(_argumentList_ instanceof X1PExp)
00116             {
00117                 this._argumentList_.addFirst(((X1PExp) _argumentList_).getPExp());
00118                 _argumentList_ = ((X1PExp) _argumentList_).getXPExp();
00119             }
00120             this._argumentList_.addFirst(((X2PExp) _argumentList_).getPExp());
00121         }
00122 
00123         setRPar(_rPar_);
00124 
00125         setClassBody(_classBody_);
00126 
00127     }
00128     public void apply(Switch sw)
00129     {
00130         ((Analysis) sw).caseASimpleClassInstanceCreationExp(this);
00131     }
00132     public Object clone()
00133     {
00134         return new ASimpleClassInstanceCreationExp(
00135             (TNew) cloneNode(_new_),
00136             (PName) cloneNode(_name_),
00137             (TLPar) cloneNode(_lPar_),
00138             cloneList(_argumentList_),
00139             (TRPar) cloneNode(_rPar_),
00140             (PClassBody) cloneNode(_classBody_));
00141     }
00142     public LinkedList getArgumentList()
00143     {
00144         return _argumentList_;
00145     }
00146     public PClassBody getClassBody()
00147     {
00148         return _classBody_;
00149     }
00150     public TLPar getLPar()
00151     {
00152         return _lPar_;
00153     }
00154     public PName getName()
00155     {
00156         return _name_;
00157     }
00158     public TNew getNew()
00159     {
00160         return _new_;
00161     }
00162     public TRPar getRPar()
00163     {
00164         return _rPar_;
00165     }
00166     void removeChild(Node child)
00167     {
00168         if(_new_ == child)
00169         {
00170             _new_ = null;
00171             return;
00172         }
00173 
00174         if(_name_ == child)
00175         {
00176             _name_ = null;
00177             return;
00178         }
00179 
00180         if(_lPar_ == child)
00181         {
00182             _lPar_ = null;
00183             return;
00184         }
00185 
00186         if(_argumentList_.remove(child))
00187         {
00188             return;
00189         }
00190 
00191         if(_rPar_ == child)
00192         {
00193             _rPar_ = 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         if(_new_ == oldChild)
00207         {
00208             setNew((TNew) newChild);
00209             return;
00210         }
00211 
00212         if(_name_ == oldChild)
00213         {
00214             setName((PName) newChild);
00215             return;
00216         }
00217 
00218         if(_lPar_ == oldChild)
00219         {
00220             setLPar((TLPar) newChild);
00221             return;
00222         }
00223 
00224         for(ListIterator i = _argumentList_.listIterator(); i.hasNext();)
00225         {
00226             if(i.next() == oldChild)
00227             {
00228                 if(newChild != null)
00229                 {
00230                     i.set(newChild);
00231                     oldChild.parent(null);
00232                     return;
00233                 }
00234 
00235                 i.remove();
00236                 oldChild.parent(null);
00237                 return;
00238             }
00239         }
00240 
00241         if(_rPar_ == oldChild)
00242         {
00243             setRPar((TRPar) newChild);
00244             return;
00245         }
00246 
00247         if(_classBody_ == oldChild)
00248         {
00249             setClassBody((PClassBody) newChild);
00250             return;
00251         }
00252 
00253     }
00254     public void setArgumentList(List list)
00255     {
00256         Object temp[] = list.toArray();
00257         for(int i = 0; i < temp.length; i++)
00258         {
00259             _argumentList_.add(temp[i]);
00260         }
00261     }
00262     public void setClassBody(PClassBody node)
00263     {
00264         if(_classBody_ != null)
00265         {
00266             _classBody_.parent(null);
00267         }
00268 
00269         if(node != null)
00270         {
00271             if(node.parent() != null)
00272             {
00273                 node.parent().removeChild(node);
00274             }
00275 
00276             node.parent(this);
00277         }
00278 
00279         _classBody_ = node;
00280     }
00281     public void setLPar(TLPar node)
00282     {
00283         if(_lPar_ != null)
00284         {
00285             _lPar_.parent(null);
00286         }
00287 
00288         if(node != null)
00289         {
00290             if(node.parent() != null)
00291             {
00292                 node.parent().removeChild(node);
00293             }
00294 
00295             node.parent(this);
00296         }
00297 
00298         _lPar_ = node;
00299     }
00300     public void setName(PName node)
00301     {
00302         if(_name_ != null)
00303         {
00304             _name_.parent(null);
00305         }
00306 
00307         if(node != null)
00308         {
00309             if(node.parent() != null)
00310             {
00311                 node.parent().removeChild(node);
00312             }
00313 
00314             node.parent(this);
00315         }
00316 
00317         _name_ = node;
00318     }
00319     public void setNew(TNew node)
00320     {
00321         if(_new_ != null)
00322         {
00323             _new_.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         _new_ = node;
00337     }
00338     public void setRPar(TRPar node)
00339     {
00340         if(_rPar_ != null)
00341         {
00342             _rPar_.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         _rPar_ = node;
00356     }
00357     public String toString()
00358     {
00359         return ""
00360             + toString(_new_)
00361             + toString(_name_)
00362             + toString(_lPar_)
00363             + toString(_argumentList_)
00364             + toString(_rPar_)
00365             + toString(_classBody_);
00366     }
00367 }

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