00001 package edu.ksu.cis.bandera.specification.predicate.node;
00002
00003
00004
00005 import java.util.*;
00006 import edu.ksu.cis.bandera.specification.predicate.analysis.*;
00007
00008 public final class AParamsParamList extends PParamList
00009 {
00010 private PParamList _paramList_;
00011 private TComma _comma_;
00012 private PName _name_;
00013 private final LinkedList _dim_ = new TypedLinkedList(new Dim_Cast());
00014 private TId _id_;
00015
00016 private class Dim_Cast implements Cast
00017 {
00018 public Object cast(Object o)
00019 {
00020 TDim node = (TDim) o;
00021
00022 if((node.parent() != null) &&
00023 (node.parent() != AParamsParamList.this))
00024 {
00025 node.parent().removeChild(node);
00026 }
00027
00028 if((node.parent() == null) ||
00029 (node.parent() != AParamsParamList.this))
00030 {
00031 node.parent(AParamsParamList.this);
00032 }
00033
00034 return node;
00035 }
00036 }
00037 public AParamsParamList()
00038 {
00039 }
00040 public AParamsParamList(
00041 PParamList _paramList_,
00042 TComma _comma_,
00043 PName _name_,
00044 XTDim _dim_,
00045 TId _id_)
00046 {
00047 setParamList(_paramList_);
00048
00049 setComma(_comma_);
00050
00051 setName(_name_);
00052
00053 if(_dim_ != null)
00054 {
00055 while(_dim_ instanceof X1TDim)
00056 {
00057 this._dim_.addFirst(((X1TDim) _dim_).getTDim());
00058 _dim_ = ((X1TDim) _dim_).getXTDim();
00059 }
00060 this._dim_.addFirst(((X2TDim) _dim_).getTDim());
00061 }
00062
00063 setId(_id_);
00064
00065 }
00066 public AParamsParamList(
00067 PParamList _paramList_,
00068 TComma _comma_,
00069 PName _name_,
00070 List _dim_,
00071 TId _id_)
00072 {
00073 setParamList(_paramList_);
00074
00075 setComma(_comma_);
00076
00077 setName(_name_);
00078
00079 {
00080 Object temp[] = _dim_.toArray();
00081 for(int i = 0; i < temp.length; i++)
00082 {
00083 this._dim_.add(temp[i]);
00084 }
00085 }
00086
00087 setId(_id_);
00088
00089 }
00090 public void apply(Switch sw)
00091 {
00092 ((Analysis) sw).caseAParamsParamList(this);
00093 }
00094 public Object clone()
00095 {
00096 return new AParamsParamList(
00097 (PParamList) cloneNode(_paramList_),
00098 (TComma) cloneNode(_comma_),
00099 (PName) cloneNode(_name_),
00100 cloneList(_dim_),
00101 (TId) cloneNode(_id_));
00102 }
00103 public TComma getComma()
00104 {
00105 return _comma_;
00106 }
00107 public LinkedList getDim()
00108 {
00109 return _dim_;
00110 }
00111 public TId getId()
00112 {
00113 return _id_;
00114 }
00115 public PName getName()
00116 {
00117 return _name_;
00118 }
00119 public PParamList getParamList()
00120 {
00121 return _paramList_;
00122 }
00123 void removeChild(Node child)
00124 {
00125 if(_paramList_ == child)
00126 {
00127 _paramList_ = null;
00128 return;
00129 }
00130
00131 if(_comma_ == child)
00132 {
00133 _comma_ = null;
00134 return;
00135 }
00136
00137 if(_name_ == child)
00138 {
00139 _name_ = null;
00140 return;
00141 }
00142
00143 if(_dim_.remove(child))
00144 {
00145 return;
00146 }
00147
00148 if(_id_ == child)
00149 {
00150 _id_ = null;
00151 return;
00152 }
00153
00154 }
00155 void replaceChild(Node oldChild, Node newChild)
00156 {
00157 if(_paramList_ == oldChild)
00158 {
00159 setParamList((PParamList) newChild);
00160 return;
00161 }
00162
00163 if(_comma_ == oldChild)
00164 {
00165 setComma((TComma) newChild);
00166 return;
00167 }
00168
00169 if(_name_ == oldChild)
00170 {
00171 setName((PName) newChild);
00172 return;
00173 }
00174
00175 for(ListIterator i = _dim_.listIterator(); i.hasNext();)
00176 {
00177 if(i.next() == oldChild)
00178 {
00179 if(newChild != null)
00180 {
00181 i.set(newChild);
00182 oldChild.parent(null);
00183 return;
00184 }
00185
00186 i.remove();
00187 oldChild.parent(null);
00188 return;
00189 }
00190 }
00191
00192 if(_id_ == oldChild)
00193 {
00194 setId((TId) newChild);
00195 return;
00196 }
00197
00198 }
00199 public void setComma(TComma node)
00200 {
00201 if(_comma_ != null)
00202 {
00203 _comma_.parent(null);
00204 }
00205
00206 if(node != null)
00207 {
00208 if(node.parent() != null)
00209 {
00210 node.parent().removeChild(node);
00211 }
00212
00213 node.parent(this);
00214 }
00215
00216 _comma_ = node;
00217 }
00218 public void setDim(List list)
00219 {
00220 Object temp[] = list.toArray();
00221 for(int i = 0; i < temp.length; i++)
00222 {
00223 _dim_.add(temp[i]);
00224 }
00225 }
00226 public void setId(TId node)
00227 {
00228 if(_id_ != null)
00229 {
00230 _id_.parent(null);
00231 }
00232
00233 if(node != null)
00234 {
00235 if(node.parent() != null)
00236 {
00237 node.parent().removeChild(node);
00238 }
00239
00240 node.parent(this);
00241 }
00242
00243 _id_ = node;
00244 }
00245 public void setName(PName node)
00246 {
00247 if(_name_ != null)
00248 {
00249 _name_.parent(null);
00250 }
00251
00252 if(node != null)
00253 {
00254 if(node.parent() != null)
00255 {
00256 node.parent().removeChild(node);
00257 }
00258
00259 node.parent(this);
00260 }
00261
00262 _name_ = node;
00263 }
00264 public void setParamList(PParamList node)
00265 {
00266 if(_paramList_ != null)
00267 {
00268 _paramList_.parent(null);
00269 }
00270
00271 if(node != null)
00272 {
00273 if(node.parent() != null)
00274 {
00275 node.parent().removeChild(node);
00276 }
00277
00278 node.parent(this);
00279 }
00280
00281 _paramList_ = node;
00282 }
00283 public String toString()
00284 {
00285 return ""
00286 + toString(_paramList_)
00287 + toString(_comma_)
00288 + toString(_name_)
00289 + toString(_dim_)
00290 + toString(_id_);
00291 }
00292 }