1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.philemonworks.selfdiagnose;
18
19 import java.util.ArrayList;
20 import java.util.Iterator;
21 import java.util.List;
22
23
24
25
26
27
28 public class CompositeDiagnosticTaskResult extends DiagnosticTaskResult {
29
30 private List results = new ArrayList();
31 public boolean includeCompositeResult = true;
32
33
34
35 public CompositeDiagnosticTaskResult(DiagnosticTask task) {
36 super(task);
37 }
38 public void addResult(DiagnosticTaskResult result){
39 results.add(result);
40 }
41 public List getResults(){
42 return results;
43 }
44 public int howManyErrors(){
45 int sum=0;
46 for (Iterator iter = results.iterator(); iter.hasNext();) {
47 DiagnosticTaskResult element = (DiagnosticTaskResult) iter.next();
48 if (!element.isPassed()) sum++;
49 }
50 return sum;
51 }
52
53
54
55 public void addToResults(List newResults) {
56 if (includeCompositeResult) newResults.add(this);
57
58 newResults.addAll(results);
59 }
60
61 public String toString() {
62 StringBuilder sb = new StringBuilder();
63 sb.append(super.toString());
64 for (int i=0;i<results.size();i++) {
65 sb.append("\n\t");
66 sb.append(results.get(i));
67 }
68 return sb.toString();
69 }
70 }