1 | /* This file was generated by SableCC (http://www.sablecc.org/). */ |
2 | |
3 | package uk.co.zonetora.fj.ast.node; |
4 | |
5 | import java.util.*; |
6 | import uk.co.zonetora.fj.ast.analysis.*; |
7 | |
8 | public final class AFieldListFieldList extends PFieldList |
9 | { |
10 | private PFieldName _fieldName_; |
11 | private final LinkedList _commaField_ = new TypedLinkedList(new CommaField_Cast()); |
12 | |
13 | public AFieldListFieldList() |
14 | { |
15 | } |
16 | |
17 | public AFieldListFieldList( |
18 | PFieldName _fieldName_, |
19 | List _commaField_) |
20 | { |
21 | setFieldName(_fieldName_); |
22 | |
23 | { |
24 | this._commaField_.clear(); |
25 | this._commaField_.addAll(_commaField_); |
26 | } |
27 | |
28 | } |
29 | |
30 | public AFieldListFieldList( |
31 | PFieldName _fieldName_, |
32 | XPCommaField _commaField_) |
33 | { |
34 | setFieldName(_fieldName_); |
35 | |
36 | if(_commaField_ != null) |
37 | { |
38 | while(_commaField_ instanceof X1PCommaField) |
39 | { |
40 | this._commaField_.addFirst(((X1PCommaField) _commaField_).getPCommaField()); |
41 | _commaField_ = ((X1PCommaField) _commaField_).getXPCommaField(); |
42 | } |
43 | this._commaField_.addFirst(((X2PCommaField) _commaField_).getPCommaField()); |
44 | } |
45 | |
46 | } |
47 | public Object clone() |
48 | { |
49 | return new AFieldListFieldList( |
50 | (PFieldName) cloneNode(_fieldName_), |
51 | cloneList(_commaField_)); |
52 | } |
53 | |
54 | public void apply(Switch sw) |
55 | { |
56 | ((Analysis) sw).caseAFieldListFieldList(this); |
57 | } |
58 | |
59 | public PFieldName getFieldName() |
60 | { |
61 | return _fieldName_; |
62 | } |
63 | |
64 | public void setFieldName(PFieldName node) |
65 | { |
66 | if(_fieldName_ != null) |
67 | { |
68 | _fieldName_.parent(null); |
69 | } |
70 | |
71 | if(node != null) |
72 | { |
73 | if(node.parent() != null) |
74 | { |
75 | node.parent().removeChild(node); |
76 | } |
77 | |
78 | node.parent(this); |
79 | } |
80 | |
81 | _fieldName_ = node; |
82 | } |
83 | |
84 | public LinkedList getCommaField() |
85 | { |
86 | return _commaField_; |
87 | } |
88 | |
89 | public void setCommaField(List list) |
90 | { |
91 | _commaField_.clear(); |
92 | _commaField_.addAll(list); |
93 | } |
94 | |
95 | public String toString() |
96 | { |
97 | return "" |
98 | + toString(_fieldName_) |
99 | + toString(_commaField_); |
100 | } |
101 | |
102 | void removeChild(Node child) |
103 | { |
104 | if(_fieldName_ == child) |
105 | { |
106 | _fieldName_ = null; |
107 | return; |
108 | } |
109 | |
110 | if(_commaField_.remove(child)) |
111 | { |
112 | return; |
113 | } |
114 | |
115 | } |
116 | |
117 | void replaceChild(Node oldChild, Node newChild) |
118 | { |
119 | if(_fieldName_ == oldChild) |
120 | { |
121 | setFieldName((PFieldName) newChild); |
122 | return; |
123 | } |
124 | |
125 | for(ListIterator i = _commaField_.listIterator(); i.hasNext();) |
126 | { |
127 | if(i.next() == oldChild) |
128 | { |
129 | if(newChild != null) |
130 | { |
131 | i.set(newChild); |
132 | oldChild.parent(null); |
133 | return; |
134 | } |
135 | |
136 | i.remove(); |
137 | oldChild.parent(null); |
138 | return; |
139 | } |
140 | } |
141 | |
142 | } |
143 | |
144 | private class CommaField_Cast implements Cast |
145 | { |
146 | public Object cast(Object o) |
147 | { |
148 | PCommaField node = (PCommaField) o; |
149 | |
150 | if((node.parent() != null) && |
151 | (node.parent() != AFieldListFieldList.this)) |
152 | { |
153 | node.parent().removeChild(node); |
154 | } |
155 | |
156 | if((node.parent() == null) || |
157 | (node.parent() != AFieldListFieldList.this)) |
158 | { |
159 | node.parent(AFieldListFieldList.this); |
160 | } |
161 | |
162 | return node; |
163 | } |
164 | } |
165 | } |