00001 package edu.ksu.cis.bandera.specification.node;
00002
00003
00004
00005 import java.util.*;
00006 import edu.ksu.cis.bandera.specification.analysis.*;
00007
00008 public final class ATl extends PTl
00009 {
00010 private TDocumentationComment _documentationComment_;
00011 private TId _id_;
00012 private TColon _colon_;
00013 private final LinkedList _qtl_ = new TypedLinkedList(new Qtl_Cast());
00014 private final LinkedList _word_ = new TypedLinkedList(new Word_Cast());
00015 private TSemicolon _semicolon_;
00016
00017 private class Qtl_Cast implements Cast
00018 {
00019 public Object cast(Object o)
00020 {
00021 PQtl node = (PQtl) o;
00022
00023 if((node.parent() != null) &&
00024 (node.parent() != ATl.this))
00025 {
00026 node.parent().removeChild(node);
00027 }
00028
00029 if((node.parent() == null) ||
00030 (node.parent() != ATl.this))
00031 {
00032 node.parent(ATl.this);
00033 }
00034
00035 return node;
00036 }
00037 }
00038
00039 private class Word_Cast implements Cast
00040 {
00041 public Object cast(Object o)
00042 {
00043 PWord node = (PWord) o;
00044
00045 if((node.parent() != null) &&
00046 (node.parent() != ATl.this))
00047 {
00048 node.parent().removeChild(node);
00049 }
00050
00051 if((node.parent() == null) ||
00052 (node.parent() != ATl.this))
00053 {
00054 node.parent(ATl.this);
00055 }
00056
00057 return node;
00058 }
00059 }
00060 public ATl()
00061 {
00062 }
00063 public ATl(
00064 TDocumentationComment _documentationComment_,
00065 TId _id_,
00066 TColon _colon_,
00067 XPQtl _qtl_,
00068 XPWord _word_,
00069 TSemicolon _semicolon_)
00070 {
00071 setDocumentationComment(_documentationComment_);
00072
00073 setId(_id_);
00074
00075 setColon(_colon_);
00076
00077 if(_qtl_ != null)
00078 {
00079 while(_qtl_ instanceof X1PQtl)
00080 {
00081 this._qtl_.addFirst(((X1PQtl) _qtl_).getPQtl());
00082 _qtl_ = ((X1PQtl) _qtl_).getXPQtl();
00083 }
00084 this._qtl_.addFirst(((X2PQtl) _qtl_).getPQtl());
00085 }
00086
00087 if(_word_ != null)
00088 {
00089 while(_word_ instanceof X1PWord)
00090 {
00091 this._word_.addFirst(((X1PWord) _word_).getPWord());
00092 _word_ = ((X1PWord) _word_).getXPWord();
00093 }
00094 this._word_.addFirst(((X2PWord) _word_).getPWord());
00095 }
00096
00097 setSemicolon(_semicolon_);
00098
00099 }
00100 public ATl(
00101 TDocumentationComment _documentationComment_,
00102 TId _id_,
00103 TColon _colon_,
00104 List _qtl_,
00105 List _word_,
00106 TSemicolon _semicolon_)
00107 {
00108 setDocumentationComment(_documentationComment_);
00109
00110 setId(_id_);
00111
00112 setColon(_colon_);
00113
00114 {
00115 this._qtl_.clear();
00116 this._qtl_.addAll(_qtl_);
00117 }
00118
00119 {
00120 this._word_.clear();
00121 this._word_.addAll(_word_);
00122 }
00123
00124 setSemicolon(_semicolon_);
00125
00126 }
00127 public void apply(Switch sw)
00128 {
00129 ((Analysis) sw).caseATl(this);
00130 }
00131 public Object clone()
00132 {
00133 return new ATl(
00134 (TDocumentationComment) cloneNode(_documentationComment_),
00135 (TId) cloneNode(_id_),
00136 (TColon) cloneNode(_colon_),
00137 cloneList(_qtl_),
00138 cloneList(_word_),
00139 (TSemicolon) cloneNode(_semicolon_));
00140 }
00141 public TColon getColon()
00142 {
00143 return _colon_;
00144 }
00145 public TDocumentationComment getDocumentationComment()
00146 {
00147 return _documentationComment_;
00148 }
00149 public TId getId()
00150 {
00151 return _id_;
00152 }
00153 public LinkedList getQtl()
00154 {
00155 return _qtl_;
00156 }
00157 public TSemicolon getSemicolon()
00158 {
00159 return _semicolon_;
00160 }
00161 public LinkedList getWord()
00162 {
00163 return _word_;
00164 }
00165 void removeChild(Node child)
00166 {
00167 if(_documentationComment_ == child)
00168 {
00169 _documentationComment_ = null;
00170 return;
00171 }
00172
00173 if(_id_ == child)
00174 {
00175 _id_ = null;
00176 return;
00177 }
00178
00179 if(_colon_ == child)
00180 {
00181 _colon_ = null;
00182 return;
00183 }
00184
00185 if(_qtl_.remove(child))
00186 {
00187 return;
00188 }
00189
00190 if(_word_.remove(child))
00191 {
00192 return;
00193 }
00194
00195 if(_semicolon_ == child)
00196 {
00197 _semicolon_ = null;
00198 return;
00199 }
00200
00201 }
00202 void replaceChild(Node oldChild, Node newChild)
00203 {
00204 if(_documentationComment_ == oldChild)
00205 {
00206 setDocumentationComment((TDocumentationComment) newChild);
00207 return;
00208 }
00209
00210 if(_id_ == oldChild)
00211 {
00212 setId((TId) newChild);
00213 return;
00214 }
00215
00216 if(_colon_ == oldChild)
00217 {
00218 setColon((TColon) newChild);
00219 return;
00220 }
00221
00222 for(ListIterator i = _qtl_.listIterator(); i.hasNext();)
00223 {
00224 if(i.next() == oldChild)
00225 {
00226 if(newChild != null)
00227 {
00228 i.set(newChild);
00229 oldChild.parent(null);
00230 return;
00231 }
00232
00233 i.remove();
00234 oldChild.parent(null);
00235 return;
00236 }
00237 }
00238
00239 for(ListIterator i = _word_.listIterator(); i.hasNext();)
00240 {
00241 if(i.next() == oldChild)
00242 {
00243 if(newChild != null)
00244 {
00245 i.set(newChild);
00246 oldChild.parent(null);
00247 return;
00248 }
00249
00250 i.remove();
00251 oldChild.parent(null);
00252 return;
00253 }
00254 }
00255
00256 if(_semicolon_ == oldChild)
00257 {
00258 setSemicolon((TSemicolon) newChild);
00259 return;
00260 }
00261
00262 }
00263 public void setColon(TColon node)
00264 {
00265 if(_colon_ != null)
00266 {
00267 _colon_.parent(null);
00268 }
00269
00270 if(node != null)
00271 {
00272 if(node.parent() != null)
00273 {
00274 node.parent().removeChild(node);
00275 }
00276
00277 node.parent(this);
00278 }
00279
00280 _colon_ = node;
00281 }
00282 public void setDocumentationComment(TDocumentationComment node)
00283 {
00284 if(_documentationComment_ != null)
00285 {
00286 _documentationComment_.parent(null);
00287 }
00288
00289 if(node != null)
00290 {
00291 if(node.parent() != null)
00292 {
00293 node.parent().removeChild(node);
00294 }
00295
00296 node.parent(this);
00297 }
00298
00299 _documentationComment_ = node;
00300 }
00301 public void setId(TId node)
00302 {
00303 if(_id_ != null)
00304 {
00305 _id_.parent(null);
00306 }
00307
00308 if(node != null)
00309 {
00310 if(node.parent() != null)
00311 {
00312 node.parent().removeChild(node);
00313 }
00314
00315 node.parent(this);
00316 }
00317
00318 _id_ = node;
00319 }
00320 public void setQtl(List list)
00321 {
00322 _qtl_.clear();
00323 _qtl_.addAll(list);
00324 }
00325 public void setSemicolon(TSemicolon node)
00326 {
00327 if(_semicolon_ != null)
00328 {
00329 _semicolon_.parent(null);
00330 }
00331
00332 if(node != null)
00333 {
00334 if(node.parent() != null)
00335 {
00336 node.parent().removeChild(node);
00337 }
00338
00339 node.parent(this);
00340 }
00341
00342 _semicolon_ = node;
00343 }
00344 public void setWord(List list)
00345 {
00346 _word_.clear();
00347 _word_.addAll(list);
00348 }
00349 public String toString()
00350 {
00351 return ""
00352 + toString(_documentationComment_)
00353 + toString(_id_)
00354 + toString(_colon_)
00355 + toString(_qtl_)
00356 + toString(_word_)
00357 + toString(_semicolon_);
00358 }
00359 }