Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 UTC
../../../../../../img/srcFileCovDistChart5.png 87% of files have more coverage
30   138   11   3
2   66   0.37   10
10     1.1  
1    
 
  ServiceResultImpl       Line # 27 30 11 50% 0.5
 
  (24)
 
1    /* This file is part of the project "Hilbert II" - http://www.qedeq.org
2    *
3    * Copyright 2000-2013, Michael Meyling <mime@qedeq.org>.
4    *
5    * "Hilbert II" is free software; you can redistribute
6    * it and/or modify it under the terms of the GNU General Public
7    * License as published by the Free Software Foundation; either
8    * version 2 of the License, or (at your option) any later version.
9    *
10    * This program is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13    * GNU General Public License for more details.
14    */
15   
16    package org.qedeq.kernel.bo.service.control;
17   
18    import org.apache.commons.lang.StringUtils;
19    import org.qedeq.kernel.bo.common.ServiceResult;
20   
21   
22    /**
23    * Execution result of a {@link ServiceCall}.
24    *
25    * @author Michael Meyling
26    */
 
27    public class ServiceResultImpl implements ServiceResult {
28   
29    /** A simple service result that has a user interrupt. */
30    public static final ServiceResult INTERRUPTED = new ServiceResultImpl(true);
31   
32    /** A simple successful (=ok) service result. */
33    public static final ServiceResult SUCCESSFUL = new ServiceResultImpl(false);
34   
35    /** Did a user interrupt occur and ended the service call? */
36    private final boolean interrupted;
37   
38    /** Was the call fully successful (finished ok without errors and warnings)? */
39    private final boolean ok;
40   
41    /** Did warnings occur? */
42    private final boolean hasWarnings;
43   
44    /** Did errors occur? */
45    private final boolean hasErrors;
46   
47    /** Error message. Might be empty. */
48    private final String message;
49   
50    /** Result of service call. Might be null even for a successful call. */
51    private Object result;
52   
53    /**
54    * Constructor.
55    *
56    * @param interrupted Did a user interrupt occur and ended the service call?
57    * @param ok Was the call fully successful (finished ok without errors and warnings)?
58    * @param hasWarnings Did warnings occur?
59    * @param hasErrors Did errors occur?
60    * @param message Error message. Might be empty.
61    * @param result Result of service call. Might be null even for a successful call.
62    */
 
63  0 toggle public ServiceResultImpl(final boolean interrupted, final boolean ok, final boolean hasWarnings,
64    final boolean hasErrors, final String message, final Object result) {
65  0 this.interrupted = interrupted;
66  0 this.ok = ok;
67  0 this.hasWarnings = hasWarnings;
68  0 this.hasErrors = hasErrors;
69  0 this.message = message;
70  0 this.result = result;
71    }
72   
73    /**
74    * Constructor for a failure call.
75    *
76    * @param errorMessage Error message. Should not be empty.
77    */
 
78  23 toggle public ServiceResultImpl(final String errorMessage) {
79  23 this.interrupted = false;
80  23 this.ok = false;
81  23 this.hasErrors = true;
82  23 this.hasWarnings = false;
83  23 this.message = errorMessage;
84  23 this.result = null;
85    }
86   
87    /**
88    * Constructor for simple successful or user interrupted call.
89    *
90    * @param interrupted Did a user interrupt occur and ended the service call?
91    */
 
92  44 toggle private ServiceResultImpl(final boolean interrupted) {
93  44 if (interrupted) {
94  22 this.interrupted = true;
95  22 this.ok = false;
96  22 this.hasErrors = true;
97  22 this.message = "User interrupted service call.";
98    } else {
99  22 this.interrupted = false;
100  22 this.ok = true;
101  22 this.hasErrors = true;
102  22 this.message = StringUtils.EMPTY;
103    }
104  44 this.hasWarnings = false;
105  44 this.result = null;
106    }
107   
 
108  0 toggle public boolean wasInterrupted() {
109  0 return interrupted;
110    }
111   
 
112  0 toggle public boolean isOk() {
113  0 return ok;
114    }
115   
 
116  0 toggle public boolean hasWarnings() {
117  0 return hasWarnings;
118    }
119   
 
120  0 toggle public boolean hasErrors() {
121  0 return hasErrors;
122    }
123   
 
124  0 toggle public String getErrorMessage() {
125  0 return message;
126    }
127   
 
128  0 toggle public Object getExecutionResult() {
129  0 return result;
130    }
131   
132    /**
133    * Remove execution result. This might be necessary because it is really big.
134    */
 
135  0 toggle public void deleteExecutionResult() {
136  0 result = null;
137    }
138    }