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

APropertiesUnit.java

00001 package edu.ksu.cis.bandera.specification.node;
00002 
00003 /* This file was generated by SableCC (http://www.sablecc.org/). */
00004 
00005 import java.util.*;
00006 import edu.ksu.cis.bandera.specification.analysis.*;
00007 
00008 public final class APropertiesUnit extends PUnit
00009 {
00010     private final LinkedList _import_ = new TypedLinkedList(new Import_Cast());
00011     private final LinkedList _def_ = new TypedLinkedList(new Def_Cast());
00012 
00013     private class Import_Cast implements Cast
00014     {
00015         public Object cast(Object o)
00016         {
00017             PImport node = (PImport) o;
00018 
00019             if((node.parent() != null) &&
00020                 (node.parent() != APropertiesUnit.this))
00021             {
00022                 node.parent().removeChild(node);
00023             }
00024 
00025             if((node.parent() == null) ||
00026                 (node.parent() != APropertiesUnit.this))
00027             {
00028                 node.parent(APropertiesUnit.this);
00029             }
00030 
00031             return node;
00032         }
00033     }
00034 
00035     private class Def_Cast implements Cast
00036     {
00037         public Object cast(Object o)
00038         {
00039             PDef node = (PDef) o;
00040 
00041             if((node.parent() != null) &&
00042                 (node.parent() != APropertiesUnit.this))
00043             {
00044                 node.parent().removeChild(node);
00045             }
00046 
00047             if((node.parent() == null) ||
00048                 (node.parent() != APropertiesUnit.this))
00049             {
00050                 node.parent(APropertiesUnit.this);
00051             }
00052 
00053             return node;
00054         }
00055     }
00056     public APropertiesUnit()
00057     {
00058     }
00059     public APropertiesUnit(
00060         XPImport _import_,
00061         XPDef _def_)
00062     {
00063         if(_import_ != null)
00064         {
00065             while(_import_ instanceof X1PImport)
00066             {
00067                 this._import_.addFirst(((X1PImport) _import_).getPImport());
00068                 _import_ = ((X1PImport) _import_).getXPImport();
00069             }
00070             this._import_.addFirst(((X2PImport) _import_).getPImport());
00071         }
00072 
00073         if(_def_ != null)
00074         {
00075             while(_def_ instanceof X1PDef)
00076             {
00077                 this._def_.addFirst(((X1PDef) _def_).getPDef());
00078                 _def_ = ((X1PDef) _def_).getXPDef();
00079             }
00080             this._def_.addFirst(((X2PDef) _def_).getPDef());
00081         }
00082 
00083     }
00084     public APropertiesUnit(
00085         List _import_,
00086         List _def_)
00087     {
00088         {
00089             this._import_.clear();
00090             this._import_.addAll(_import_);
00091         }
00092 
00093         {
00094             this._def_.clear();
00095             this._def_.addAll(_def_);
00096         }
00097 
00098     }
00099     public void apply(Switch sw)
00100     {
00101         ((Analysis) sw).caseAPropertiesUnit(this);
00102     }
00103     public Object clone()
00104     {
00105         return new APropertiesUnit(
00106             cloneList(_import_),
00107             cloneList(_def_));
00108     }
00109     public LinkedList getDef()
00110     {
00111         return _def_;
00112     }
00113     public LinkedList getImport()
00114     {
00115         return _import_;
00116     }
00117     void removeChild(Node child)
00118     {
00119         if(_import_.remove(child))
00120         {
00121             return;
00122         }
00123 
00124         if(_def_.remove(child))
00125         {
00126             return;
00127         }
00128 
00129     }
00130     void replaceChild(Node oldChild, Node newChild)
00131     {
00132         for(ListIterator i = _import_.listIterator(); i.hasNext();)
00133         {
00134             if(i.next() == oldChild)
00135             {
00136                 if(newChild != null)
00137                 {
00138                     i.set(newChild);
00139                     oldChild.parent(null);
00140                     return;
00141                 }
00142 
00143                 i.remove();
00144                 oldChild.parent(null);
00145                 return;
00146             }
00147         }
00148 
00149         for(ListIterator i = _def_.listIterator(); i.hasNext();)
00150         {
00151             if(i.next() == oldChild)
00152             {
00153                 if(newChild != null)
00154                 {
00155                     i.set(newChild);
00156                     oldChild.parent(null);
00157                     return;
00158                 }
00159 
00160                 i.remove();
00161                 oldChild.parent(null);
00162                 return;
00163             }
00164         }
00165 
00166     }
00167     public void setDef(List list)
00168     {
00169         _def_.clear();
00170         _def_.addAll(list);
00171     }
00172     public void setImport(List list)
00173     {
00174         _import_.clear();
00175         _import_.addAll(list);
00176     }
00177     public String toString()
00178     {
00179         return ""
00180             + toString(_import_)
00181             + toString(_def_);
00182     }
00183 }

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