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

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

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