23 |
|
|
24 |
import java.net.URI; |
import java.net.URI; |
25 |
import java.net.URISyntaxException; |
import java.net.URISyntaxException; |
26 |
|
import java.util.ArrayList; |
27 |
import java.util.List; |
import java.util.List; |
28 |
|
|
29 |
|
import nongnu.cashews.xml.CustomXmlizable; |
30 |
|
|
31 |
/** |
/** |
32 |
* Represents an <em>instance</em> of an <strong>atomic</strong> or |
* Represents an <em>instance</em> of an <strong>atomic</strong> or |
33 |
* <strong>composite</strong> process. Each performance has a name |
* <strong>composite</strong> process. Each performance has a name |
42 |
* @see ValueCollector |
* @see ValueCollector |
43 |
*/ |
*/ |
44 |
public class Performance |
public class Performance |
45 |
implements MultiPerformElement |
implements MultiPerformElement, CustomXmlizable |
46 |
{ |
{ |
47 |
|
|
48 |
/** |
/** |
77 |
private List<ValueCollector> valueCollectors; |
private List<ValueCollector> valueCollectors; |
78 |
|
|
79 |
/** |
/** |
80 |
|
* Constructs a new <code>Performance</code>. |
81 |
|
*/ |
82 |
|
private Performance() |
83 |
|
{ |
84 |
|
valueDatas = new ArrayList<ValueData>(); |
85 |
|
valueCollectors = new ArrayList<ValueCollector>(); |
86 |
|
} |
87 |
|
|
88 |
|
/** |
89 |
* Constructs a new <code>Performance</code> with the |
* Constructs a new <code>Performance</code> with the |
90 |
* specified name. |
* specified name. |
91 |
* |
* |
92 |
* @param name the performance name. |
* @param name the performance name. |
93 |
|
* @throws URISyntaxException if the supplied name is not a valid URI. |
94 |
*/ |
*/ |
95 |
public Performance(String name) |
public Performance(String name) |
96 |
|
throws URISyntaxException |
97 |
{ |
{ |
98 |
|
this(); |
99 |
|
setName(name); |
100 |
} |
} |
101 |
|
|
102 |
/** |
/** |
132 |
} |
} |
133 |
|
|
134 |
/** |
/** |
135 |
|
* Sets the process associated with this performance. |
136 |
|
* |
137 |
|
* @param process the new process. |
138 |
|
*/ |
139 |
|
public void setProcess(Process process) |
140 |
|
{ |
141 |
|
this.process = process; |
142 |
|
} |
143 |
|
|
144 |
|
/** |
145 |
|
* Adds a new <code>ValueData</code> to this performance. |
146 |
|
* |
147 |
|
* @param valueData the value data to add. |
148 |
|
* @return <code>true</code> if the value data was added. |
149 |
|
*/ |
150 |
|
public boolean addValueData(ValueData valueData) |
151 |
|
{ |
152 |
|
if (valueData == null) |
153 |
|
return false; |
154 |
|
valueDatas.add(valueData); |
155 |
|
return true; |
156 |
|
} |
157 |
|
|
158 |
|
/** |
159 |
|
* Adds a new <code>ValueCollector</code> to this performance. |
160 |
|
* |
161 |
|
* @param valueCollector the value collector to add. |
162 |
|
* @return <code>true</code> if the value collector was added. |
163 |
|
*/ |
164 |
|
public boolean addValueCollector(ValueCollector valueCollector) |
165 |
|
{ |
166 |
|
if (valueCollector == null) |
167 |
|
return false; |
168 |
|
valueCollectors.add(valueCollector); |
169 |
|
return true; |
170 |
|
} |
171 |
|
|
172 |
|
/** |
173 |
* Retrieves the name of this performance. |
* Retrieves the name of this performance. |
174 |
* |
* |
175 |
* @return the name of the performance. |
* @return the name of the performance. |
178 |
{ |
{ |
179 |
return name; |
return name; |
180 |
} |
} |
181 |
|
|
182 |
/** |
/** |
183 |
* Retrieves the value datas of this performance |
* Retrieves a clone of this performance's process. |
184 |
|
* |
185 |
|
* @return the performance's process. |
186 |
|
*/ |
187 |
|
public Process getProcess() |
188 |
|
{ |
189 |
|
return process.clone(); |
190 |
|
} |
191 |
|
|
192 |
|
/** |
193 |
|
* Retrieves a shallow clone of the value datas for this performance. |
194 |
|
* |
195 |
|
* @return a shallow clone of the value data list. |
196 |
*/ |
*/ |
197 |
public List<ValueData> getValueData() |
public List<ValueData> getValueData() |
198 |
{ |
{ |
199 |
return valueDatas; |
return new ArrayList<ValueData>(valueDatas); |
200 |
} |
} |
201 |
|
|
202 |
/** |
/** |
203 |
* Retrieves the value collectors of this performance |
* Retrieves a shallow clone of the value collectors for this performance. |
204 |
|
* |
205 |
|
* @return a shallow clone of the value collector list. |
206 |
*/ |
*/ |
207 |
public List<ValueCollector> getValueCollectors() |
public List<ValueCollector> getValueCollectors() |
208 |
{ |
{ |
209 |
return valueCollectors; |
return new ArrayList<ValueCollector>(valueCollectors); |
210 |
} |
} |
211 |
|
|
212 |
|
/** |
213 |
|
* Returns a <code>String</code> representation of this performance. |
214 |
|
* |
215 |
|
* @return a textual representation. |
216 |
|
*/ |
217 |
|
public String toString() |
218 |
|
{ |
219 |
|
return getClass().getName() + |
220 |
|
"[name=" + |
221 |
|
name + |
222 |
|
",process=" + |
223 |
|
process + |
224 |
|
",valueDatas=" + |
225 |
|
valueDatas + |
226 |
|
",valueCollectors=" + |
227 |
|
valueCollectors + |
228 |
|
"]"; |
229 |
|
} |
230 |
|
|
231 |
|
/** |
232 |
|
* Returns "perform" as the element name. |
233 |
|
* |
234 |
|
* @return <code>perform</code> |
235 |
|
*/ |
236 |
|
public String getElementName() |
237 |
|
{ |
238 |
|
return "perform"; |
239 |
|
} |
240 |
|
|
241 |
} |
} |