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

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

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