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

ATest.java

00001 package edu.ksu.cis.bandera.abstraction.specification.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.specification.analysis.*;
00040 
00041 public final class ATest extends PTest
00042 {
00043     private TTest _test_;
00044     private PTOp _tOp_;
00045     private TId _id_;
00046     private TBegin _begin_;
00047     private final LinkedList _pattern_ = new TypedLinkedList(new Pattern_Cast());
00048     private TEnd _end_;
00049 
00050     private class Pattern_Cast implements Cast
00051     {
00052         public Object cast(Object o)
00053         {
00054             PPattern node = (PPattern) o;
00055 
00056             if((node.parent() != null) &&
00057                 (node.parent() != ATest.this))
00058             {
00059                 node.parent().removeChild(node);
00060             }
00061 
00062             if((node.parent() == null) ||
00063                 (node.parent() != ATest.this))
00064             {
00065                 node.parent(ATest.this);
00066             }
00067 
00068             return node;
00069         }
00070     }
00071     public ATest()
00072     {
00073     }
00074     public ATest(
00075         TTest _test_,
00076         PTOp _tOp_,
00077         TId _id_,
00078         TBegin _begin_,
00079         XPPattern _pattern_,
00080         TEnd _end_)
00081     {
00082         setTest(_test_);
00083 
00084         setTOp(_tOp_);
00085 
00086         setId(_id_);
00087 
00088         setBegin(_begin_);
00089 
00090         if(_pattern_ != null)
00091         {
00092             while(_pattern_ instanceof X1PPattern)
00093             {
00094                 this._pattern_.addFirst(((X1PPattern) _pattern_).getPPattern());
00095                 _pattern_ = ((X1PPattern) _pattern_).getXPPattern();
00096             }
00097             this._pattern_.addFirst(((X2PPattern) _pattern_).getPPattern());
00098         }
00099 
00100         setEnd(_end_);
00101 
00102     }
00103     public ATest(
00104         TTest _test_,
00105         PTOp _tOp_,
00106         TId _id_,
00107         TBegin _begin_,
00108         List _pattern_,
00109         TEnd _end_)
00110     {
00111         setTest(_test_);
00112 
00113         setTOp(_tOp_);
00114 
00115         setId(_id_);
00116 
00117         setBegin(_begin_);
00118 
00119         {
00120             Object temp[] = _pattern_.toArray();
00121             for(int i = 0; i < temp.length; i++)
00122             {
00123                 this._pattern_.add(temp[i]);
00124             }
00125         }
00126 
00127         setEnd(_end_);
00128 
00129     }
00130     public void apply(Switch sw)
00131     {
00132         ((Analysis) sw).caseATest(this);
00133     }
00134     public Object clone()
00135     {
00136         return new ATest(
00137             (TTest) cloneNode(_test_),
00138             (PTOp) cloneNode(_tOp_),
00139             (TId) cloneNode(_id_),
00140             (TBegin) cloneNode(_begin_),
00141             cloneList(_pattern_),
00142             (TEnd) cloneNode(_end_));
00143     }
00144     public TBegin getBegin()
00145     {
00146         return _begin_;
00147     }
00148     public TEnd getEnd()
00149     {
00150         return _end_;
00151     }
00152     public TId getId()
00153     {
00154         return _id_;
00155     }
00156     public LinkedList getPattern()
00157     {
00158         return _pattern_;
00159     }
00160     public TTest getTest()
00161     {
00162         return _test_;
00163     }
00164     public PTOp getTOp()
00165     {
00166         return _tOp_;
00167     }
00168     void removeChild(Node child)
00169     {
00170         if(_test_ == child)
00171         {
00172             _test_ = null;
00173             return;
00174         }
00175 
00176         if(_tOp_ == child)
00177         {
00178             _tOp_ = null;
00179             return;
00180         }
00181 
00182         if(_id_ == child)
00183         {
00184             _id_ = null;
00185             return;
00186         }
00187 
00188         if(_begin_ == child)
00189         {
00190             _begin_ = null;
00191             return;
00192         }
00193 
00194         if(_pattern_.remove(child))
00195         {
00196             return;
00197         }
00198 
00199         if(_end_ == child)
00200         {
00201             _end_ = null;
00202             return;
00203         }
00204 
00205     }
00206     void replaceChild(Node oldChild, Node newChild)
00207     {
00208         if(_test_ == oldChild)
00209         {
00210             setTest((TTest) newChild);
00211             return;
00212         }
00213 
00214         if(_tOp_ == oldChild)
00215         {
00216             setTOp((PTOp) newChild);
00217             return;
00218         }
00219 
00220         if(_id_ == oldChild)
00221         {
00222             setId((TId) newChild);
00223             return;
00224         }
00225 
00226         if(_begin_ == oldChild)
00227         {
00228             setBegin((TBegin) newChild);
00229             return;
00230         }
00231 
00232         for(ListIterator i = _pattern_.listIterator(); i.hasNext();)
00233         {
00234             if(i.next() == oldChild)
00235             {
00236                 if(newChild != null)
00237                 {
00238                     i.set(newChild);
00239                     oldChild.parent(null);
00240                     return;
00241                 }
00242 
00243                 i.remove();
00244                 oldChild.parent(null);
00245                 return;
00246             }
00247         }
00248 
00249         if(_end_ == oldChild)
00250         {
00251             setEnd((TEnd) newChild);
00252             return;
00253         }
00254 
00255     }
00256     public void setBegin(TBegin node)
00257     {
00258         if(_begin_ != null)
00259         {
00260             _begin_.parent(null);
00261         }
00262 
00263         if(node != null)
00264         {
00265             if(node.parent() != null)
00266             {
00267                 node.parent().removeChild(node);
00268             }
00269 
00270             node.parent(this);
00271         }
00272 
00273         _begin_ = node;
00274     }
00275     public void setEnd(TEnd node)
00276     {
00277         if(_end_ != null)
00278         {
00279             _end_.parent(null);
00280         }
00281 
00282         if(node != null)
00283         {
00284             if(node.parent() != null)
00285             {
00286                 node.parent().removeChild(node);
00287             }
00288 
00289             node.parent(this);
00290         }
00291 
00292         _end_ = node;
00293     }
00294     public void setId(TId node)
00295     {
00296         if(_id_ != null)
00297         {
00298             _id_.parent(null);
00299         }
00300 
00301         if(node != null)
00302         {
00303             if(node.parent() != null)
00304             {
00305                 node.parent().removeChild(node);
00306             }
00307 
00308             node.parent(this);
00309         }
00310 
00311         _id_ = node;
00312     }
00313     public void setPattern(List list)
00314     {
00315         Object temp[] = list.toArray();
00316         for(int i = 0; i < temp.length; i++)
00317         {
00318             _pattern_.add(temp[i]);
00319         }
00320     }
00321     public void setTest(TTest node)
00322     {
00323         if(_test_ != null)
00324         {
00325             _test_.parent(null);
00326         }
00327 
00328         if(node != null)
00329         {
00330             if(node.parent() != null)
00331             {
00332                 node.parent().removeChild(node);
00333             }
00334 
00335             node.parent(this);
00336         }
00337 
00338         _test_ = node;
00339     }
00340     public void setTOp(PTOp node)
00341     {
00342         if(_tOp_ != null)
00343         {
00344             _tOp_.parent(null);
00345         }
00346 
00347         if(node != null)
00348         {
00349             if(node.parent() != null)
00350             {
00351                 node.parent().removeChild(node);
00352             }
00353 
00354             node.parent(this);
00355         }
00356 
00357         _tOp_ = node;
00358     }
00359     public String toString()
00360     {
00361         return ""
00362             + toString(_test_)
00363             + toString(_tOp_)
00364             + toString(_id_)
00365             + toString(_begin_)
00366             + toString(_pattern_)
00367             + toString(_end_);
00368     }
00369 }

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