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

ASession.java

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

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