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

AUnit.java

00001 package edu.ksu.cis.bandera.specification.predicate.node;
00002 
00003 /* This file was generated by SableCC (http://www.sable.mcgill.ca/sablecc/). */
00004 
00005 import java.util.*;
00006 import edu.ksu.cis.bandera.specification.predicate.analysis.*;
00007 
00008 public final class AUnit extends PUnit
00009 {
00010     private PName _name_;
00011     private final LinkedList _comment_ = new TypedLinkedList(new Comment_Cast());
00012     private final LinkedList _propositionDefinition_ = new TypedLinkedList(new PropositionDefinition_Cast());
00013 
00014     private class Comment_Cast implements Cast
00015     {
00016         public Object cast(Object o)
00017         {
00018             PComment node = (PComment) o;
00019 
00020             if((node.parent() != null) &&
00021                 (node.parent() != AUnit.this))
00022             {
00023                 node.parent().removeChild(node);
00024             }
00025 
00026             if((node.parent() == null) ||
00027                 (node.parent() != AUnit.this))
00028             {
00029                 node.parent(AUnit.this);
00030             }
00031 
00032             return node;
00033         }
00034     }
00035 
00036     private class PropositionDefinition_Cast implements Cast
00037     {
00038         public Object cast(Object o)
00039         {
00040             PPropositionDefinition node = (PPropositionDefinition) o;
00041 
00042             if((node.parent() != null) &&
00043                 (node.parent() != AUnit.this))
00044             {
00045                 node.parent().removeChild(node);
00046             }
00047 
00048             if((node.parent() == null) ||
00049                 (node.parent() != AUnit.this))
00050             {
00051                 node.parent(AUnit.this);
00052             }
00053 
00054             return node;
00055         }
00056     }
00057     public AUnit()
00058     {
00059     }
00060     public AUnit(
00061         PName _name_,
00062         XPComment _comment_,
00063         XPPropositionDefinition _propositionDefinition_)
00064     {
00065         setName(_name_);
00066 
00067         if(_comment_ != null)
00068         {
00069             while(_comment_ instanceof X1PComment)
00070             {
00071                 this._comment_.addFirst(((X1PComment) _comment_).getPComment());
00072                 _comment_ = ((X1PComment) _comment_).getXPComment();
00073             }
00074             this._comment_.addFirst(((X2PComment) _comment_).getPComment());
00075         }
00076 
00077         if(_propositionDefinition_ != null)
00078         {
00079             while(_propositionDefinition_ instanceof X1PPropositionDefinition)
00080             {
00081                 this._propositionDefinition_.addFirst(((X1PPropositionDefinition) _propositionDefinition_).getPPropositionDefinition());
00082                 _propositionDefinition_ = ((X1PPropositionDefinition) _propositionDefinition_).getXPPropositionDefinition();
00083             }
00084             this._propositionDefinition_.addFirst(((X2PPropositionDefinition) _propositionDefinition_).getPPropositionDefinition());
00085         }
00086 
00087     }
00088     public AUnit(
00089         PName _name_,
00090         List _comment_,
00091         List _propositionDefinition_)
00092     {
00093         setName(_name_);
00094 
00095         {
00096             Object temp[] = _comment_.toArray();
00097             for(int i = 0; i < temp.length; i++)
00098             {
00099                 this._comment_.add(temp[i]);
00100             }
00101         }
00102 
00103         {
00104             Object temp[] = _propositionDefinition_.toArray();
00105             for(int i = 0; i < temp.length; i++)
00106             {
00107                 this._propositionDefinition_.add(temp[i]);
00108             }
00109         }
00110 
00111     }
00112     public void apply(Switch sw)
00113     {
00114         ((Analysis) sw).caseAUnit(this);
00115     }
00116     public Object clone()
00117     {
00118         return new AUnit(
00119             (PName) cloneNode(_name_),
00120             cloneList(_comment_),
00121             cloneList(_propositionDefinition_));
00122     }
00123     public LinkedList getComment()
00124     {
00125         return _comment_;
00126     }
00127     public PName getName()
00128     {
00129         return _name_;
00130     }
00131     public LinkedList getPropositionDefinition()
00132     {
00133         return _propositionDefinition_;
00134     }
00135     void removeChild(Node child)
00136     {
00137         if(_name_ == child)
00138         {
00139             _name_ = null;
00140             return;
00141         }
00142 
00143         if(_comment_.remove(child))
00144         {
00145             return;
00146         }
00147 
00148         if(_propositionDefinition_.remove(child))
00149         {
00150             return;
00151         }
00152 
00153     }
00154     void replaceChild(Node oldChild, Node newChild)
00155     {
00156         if(_name_ == oldChild)
00157         {
00158             setName((PName) newChild);
00159             return;
00160         }
00161 
00162         for(ListIterator i = _comment_.listIterator(); i.hasNext();)
00163         {
00164             if(i.next() == oldChild)
00165             {
00166                 if(newChild != null)
00167                 {
00168                     i.set(newChild);
00169                     oldChild.parent(null);
00170                     return;
00171                 }
00172 
00173                 i.remove();
00174                 oldChild.parent(null);
00175                 return;
00176             }
00177         }
00178 
00179         for(ListIterator i = _propositionDefinition_.listIterator(); i.hasNext();)
00180         {
00181             if(i.next() == oldChild)
00182             {
00183                 if(newChild != null)
00184                 {
00185                     i.set(newChild);
00186                     oldChild.parent(null);
00187                     return;
00188                 }
00189 
00190                 i.remove();
00191                 oldChild.parent(null);
00192                 return;
00193             }
00194         }
00195 
00196     }
00197     public void setComment(List list)
00198     {
00199         Object temp[] = list.toArray();
00200         for(int i = 0; i < temp.length; i++)
00201         {
00202             _comment_.add(temp[i]);
00203         }
00204     }
00205     public void setName(PName node)
00206     {
00207         if(_name_ != null)
00208         {
00209             _name_.parent(null);
00210         }
00211 
00212         if(node != null)
00213         {
00214             if(node.parent() != null)
00215             {
00216                 node.parent().removeChild(node);
00217             }
00218 
00219             node.parent(this);
00220         }
00221 
00222         _name_ = node;
00223     }
00224     public void setPropositionDefinition(List list)
00225     {
00226         Object temp[] = list.toArray();
00227         for(int i = 0; i < temp.length; i++)
00228         {
00229             _propositionDefinition_.add(temp[i]);
00230         }
00231     }
00232     public String toString()
00233     {
00234         return ""
00235             + toString(_name_)
00236             + toString(_comment_)
00237             + toString(_propositionDefinition_);
00238     }
00239 }

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