1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.philemonworks.selfdiagnose;
18
19
20
21
22
23
24
25
26
27 public class CustomDiagnosticTask extends DiagnosticTask {
28 private static final long serialVersionUID = 3770101714847787671L;
29
30 DiagnosticTask task;
31 String errorMessage;
32
33 public String getDescription() {
34 if (task == null)
35 return "No description available because task instance could not be created";
36 else
37 return task.getDescription();
38 }
39 public DiagnosticTaskResult createResult() {
40 if (task == null)
41 return super.createResult();
42 else
43 return task.createResult();
44 }
45 public void run(ExecutionContext ctx, DiagnosticTaskResult result) throws DiagnoseException {
46 if (task == null) {
47 result.setErrorMessage(errorMessage);
48 return;
49 }
50 task.run(ctx,result);
51 }
52 public void setUp(ExecutionContext ctx) throws DiagnoseException {
53 if (task == null)
54 throw new DiagnoseException(this.errorMessage);
55 task.setUp(ctx);
56 }
57 public String getErrorMessage() {
58 return errorMessage;
59 }
60 public void setErrorMessage(String errorMessage) {
61 this.errorMessage = errorMessage;
62 }
63
64 public DiagnosticTask getTask() {
65 return task;
66 }
67
68 public void setTask(DiagnosticTask task) {
69 this.task = task;
70 }
71
72 public String getComment() {
73 return task == null ? super.getComment() : task.getComment();
74 }
75 }