1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.philemonworks.selfdiagnose.output;
18
19 import java.util.ArrayList;
20 import java.util.Iterator;
21 import java.util.List;
22
23 import com.philemonworks.selfdiagnose.DiagnosticTaskResult;
24 import com.philemonworks.selfdiagnose.SelfDiagnose;
25
26 public class DiagnoseRun {
27 public List<DiagnosticTaskResult> results = new ArrayList<DiagnosticTaskResult>();
28 public long timeMs = System.currentTimeMillis();
29
30
31
32
33 public void finished() {
34 timeMs = System.currentTimeMillis() - timeMs;
35 }
36
37 public int howManyTasks() {
38 return results.size();
39 }
40
41 public long totalTime() {
42 return timeMs;
43 }
44
45 public int howManyNotPassed() {
46 int noTasksFailed = 0;
47 for (Iterator<DiagnosticTaskResult> iterator = results.iterator(); iterator.hasNext();) {
48 DiagnosticTaskResult result = (DiagnosticTaskResult) iterator.next();
49 boolean failed = result.isError() || result.isFailed();
50 if (failed)
51 noTasksFailed++;
52 }
53 return noTasksFailed;
54 }
55
56 public String getProductStamp() {
57 return "SelfDiagnose " + SelfDiagnose.VERSION + " " + SelfDiagnose.COPYRIGHT;
58 }
59
60 public String getTotalsLine() {
61 return "Checks: " + howManyTasks() + " , Failures: " + howManyNotPassed() + " , Time: " + totalTime() + " ms";
62 }
63
64 public boolean isOK() {
65 return this.howManyNotPassed() == 0;
66 }
67 }