Skip to content

Package: AbstractReport

AbstractReport

nameinstructionbranchcomplexitylinemethod
AbstractReport()
M: 0 C: 9
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
AbstractReport(String)
M: 0 C: 9
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
AbstractReport(String, Object[])
M: 0 C: 11
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
AbstractReport(String, int)
M: 0 C: 9
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
AbstractReport(String, int, Object[])
M: 11 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
AbstractReport(Throwable)
M: 0 C: 9
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
AbstractReport(Throwable, String)
M: 0 C: 12
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
AbstractReport(Throwable, String, Object[])
M: 0 C: 14
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
AbstractReport(Throwable, int)
M: 0 C: 9
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
getException()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getMessage()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getSeverity()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
hasException()
M: 7 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
setException(Throwable)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
setMessage(String)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2014 EclipseSource Muenchen GmbH and others.
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License 2.0
6: * which accompanies this distribution, and is available at
7: * https://www.eclipse.org/legal/epl-2.0/
8: *
9: * SPDX-License-Identifier: EPL-2.0
10: *
11: * Contributors:
12: * Edgar Mueller - initial API and implementation
13: * Mat Hansen - MessageFormat support
14: ******************************************************************************/
15: package org.eclipse.emfforms.spi.common.report;
16:
17: import java.text.MessageFormat;
18:
19: /**
20: * Common base type for reports that may be reported.
21: *
22: * @author emueller
23: * @since 1.5
24: *
25: */
26: public class AbstractReport {
27:
28:         private Throwable exception;
29:         private String message;
30:         private final int severity;
31:
32:         /**
33:          * Default constructor with empty message.
34:          *
35:          * Sets the severity to <code>IStatus.ERROR</code>.
36:          */
37:         public AbstractReport() {
38:                 exception = null;
39:                 severity = 4; // == IStatus.ERROR
40:         }
41:
42:         /**
43:          * Constructor.
44:          *
45:          * Sets the severity to <code>IStatus.ERROR</code>.
46:          *
47:          * @param exception the exception this report is based on
48:          */
49:         public AbstractReport(Throwable exception) {
50:                 this.exception = exception;
51:                 severity = 4; // == IStatus.ERROR
52:         }
53:
54:         /**
55:          * Constructor.
56:          *
57:          * Sets the severity to <code>IStatus.ERROR</code>.
58:          *
59:          * @param message the report message
60:          */
61:         public AbstractReport(String message) {
62:                 this.message = message;
63:                 severity = 4; // == IStatus.ERROR
64:         }
65:
66:         /**
67:          * Constructor with MessageFormat support.
68:          *
69:          * Sets the severity to <code>IStatus.ERROR</code>.
70:          *
71:          * @param message the report message
72:          * @param arguments the arguments for the message
73:          *
74:          * @since 1.14
75:          */
76:         public AbstractReport(String message, Object... arguments) {
77:                 this.message = MessageFormat.format(message, arguments);
78:                 severity = 4; // == IStatus.ERROR
79:         }
80:
81:         /**
82:          * Constructor.
83:          *
84:          * Sets the severity to the given severity.
85:          *
86:          * @param message the report message
87:          * @param severity the severity of the report specified as an <code>IStatus</code> severity code.
88:          */
89:         public AbstractReport(String message, int severity) {
90:                 this.message = message;
91:                 this.severity = severity;
92:         }
93:
94:         /**
95:          * Constructor with MessageFormat support.
96:          *
97:          * @param message the report message
98:          * @param severity the message severity
99:          * @param arguments the arguments for the message
100:          *
101:          * @since 1.14
102:          */
103:         public AbstractReport(String message, int severity, Object... arguments) {
104:                 this.message = MessageFormat.format(message, arguments);
105:                 this.severity = severity;
106:         }
107:
108:         /**
109:          * Constructor.
110:          *
111:          * Sets the severity to <code>IStatus.ERROR</code>.
112:          *
113:          * @param exception the exception this report is based on
114:          * @param message the report message
115:          */
116:         public AbstractReport(Throwable exception, String message) {
117:                 this.exception = exception;
118:                 this.message = message;
119:                 severity = 4; // == IStatus.ERROR
120:         }
121:
122:         /**
123:          * Constructor with MessageFormat support.
124:          *
125:          * @param exception the exception this report is based on
126:          * @param message the report message
127:          * @param arguments the arguments for the message
128:          *
129:          * @since 1.14
130:          */
131:         public AbstractReport(Throwable exception, String message, Object... arguments) {
132:                 this.exception = exception;
133:                 this.message = MessageFormat.format(message, arguments);
134:                 severity = 4; // == IStatus.ERROR
135:         }
136:
137:         /**
138:          * Constructor.
139:          *
140:          * @param exception the exception this report is based on
141:          * @param severity the severity of the report
142:          */
143:         public AbstractReport(Throwable exception, int severity) {
144:                 this.exception = exception;
145:                 this.severity = severity;
146:         }
147:
148:         /**
149:          * Returns the report message.
150:          *
151:          * @return the report message
152:          */
153:         public String getMessage() {
154:                 return message;
155:         }
156:
157:         /**
158:          * Whether this report is based upon an exception.
159:          *
160:          * @return {@code true}, if this report is based upon an exception, {@code false} otherwise
161:          */
162:         public boolean hasException() {
163:•                return getException() != null;
164:         }
165:
166:         /**
167:          * Returns the exception this report is based on, if any.
168:          *
169:          * @return the exception this report is based on, if any, otherwise {@code null}
170:          *
171:          *
172:          * @see #hasException()
173:          */
174:         public Throwable getException() {
175:                 return exception;
176:         }
177:
178:         /**
179:          * Returns the status of this report.
180:          *
181:          * @return the status of this report
182:          *
183:          */
184:         public int getSeverity() {
185:                 return severity;
186:         }
187:
188:         /**
189:          * Sets the exception this report is based on.
190:          *
191:          * @param exception
192:          * the exception this report is based on
193:          *
194:          * @see #hasException()
195:          */
196:         protected void setException(Throwable exception) {
197:                 this.exception = exception;
198:         }
199:
200:         /**
201:          * Sets the report' message.
202:          *
203:          * @param message
204:          * the report message to set
205:          */
206:         protected void setMessage(String message) {
207:                 this.message = message;
208:         }
209: }