1 2 3 package org.sablecc.sablecc.syntax3.node; 4 5 import java.util.*; 6 import org.sablecc.sablecc.syntax3.analysis.*; 7 8 @SuppressWarnings ("nls") 9 public final class AInternalStates extends PInternalStates 10 { 11 private final LinkedList<PInternalState> _internalStates_ = new LinkedList<PInternalState>(); 12 private PTransitions _transitions_; 13 14 public AInternalStates() 15 { 16 } 18 19 public AInternalStates( 20 @SuppressWarnings ("hiding") List<PInternalState> _internalStates_, 21 @SuppressWarnings ("hiding") PTransitions _transitions_) 22 { 23 setInternalStates(_internalStates_); 25 26 setTransitions(_transitions_); 27 28 } 29 30 @Override 31 public Object clone() 32 { 33 return new AInternalStates( 34 cloneList(this._internalStates_), 35 cloneNode(this._transitions_)); 36 } 37 38 public void apply(Switch sw) 39 { 40 ((Analysis) sw).caseAInternalStates(this); 41 } 42 43 public LinkedList<PInternalState> getInternalStates() 44 { 45 return this._internalStates_; 46 } 47 48 public void setInternalStates(List<PInternalState> list) 49 { 50 this._internalStates_.clear(); 51 this._internalStates_.addAll(list); 52 for(PInternalState e : list) 53 { 54 if(e.parent() != null) 55 { 56 e.parent().removeChild(e); 57 } 58 59 e.parent(this); 60 } 61 } 62 63 public PTransitions getTransitions() 64 { 65 return this._transitions_; 66 } 67 68 public void setTransitions(PTransitions node) 69 { 70 if(this._transitions_ != null) 71 { 72 this._transitions_.parent(null); 73 } 74 75 if(node != null) 76 { 77 if(node.parent() != null) 78 { 79 node.parent().removeChild(node); 80 } 81 82 node.parent(this); 83 } 84 85 this._transitions_ = node; 86 } 87 88 @Override 89 public String toString() 90 { 91 return "" 92 + toString(this._internalStates_) 93 + toString(this._transitions_); 94 } 95 96 @Override 97 void removeChild(@SuppressWarnings ("unused") Node child) 98 { 99 if(this._internalStates_.remove(child)) 101 { 102 return; 103 } 104 105 if(this._transitions_ == child) 106 { 107 this._transitions_ = null; 108 return; 109 } 110 111 throw new RuntimeException ("Not a child."); 112 } 113 114 @Override 115 void replaceChild(@SuppressWarnings ("unused") Node oldChild, @SuppressWarnings ("unused") Node newChild) 116 { 117 for(ListIterator<PInternalState> i = this._internalStates_.listIterator(); i.hasNext();) 119 { 120 if(i.next() == oldChild) 121 { 122 if(newChild != null) 123 { 124 i.set((PInternalState) newChild); 125 newChild.parent(this); 126 oldChild.parent(null); 127 return; 128 } 129 130 i.remove(); 131 oldChild.parent(null); 132 return; 133 } 134 } 135 136 if(this._transitions_ == oldChild) 137 { 138 setTransitions((PTransitions) newChild); 139 return; 140 } 141 142 throw new RuntimeException ("Not a child."); 143 } 144 } 145 | Popular Tags |