11/*
2- // This software is subject to the terms of the Eclipse Public License v1.0
3- // Agreement, available at the following URL:
4- // http://www.eclipse.org/legal/epl-v10.html.
5- // You must accept the terms of that agreement to use this software.
6- //
7- // Copyright (C) 2005-2005 Julian Hyde
8- // Copyright (C) 2005-2017 Hitachi Vantara and others
9- // All Rights Reserved.
10- */
2+ * This software is subject to the terms of the Eclipse Public License v1.0
3+ * Agreement, available at the following URL:
4+ * http://www.eclipse.org/legal/epl-v10.html.
5+ * You must accept the terms of that agreement to use this software.
6+ *
7+ * Copyright (C) 2005-2005 Julian Hyde
8+ * Copyright (c) 2002-2017 Hitachi Vantara.. All rights reserved.
9+ *
10+ * ---- All changes after Fork in 2023 ------------------------
11+ *
12+ * Project: Eclipse daanse
13+ *
14+ * Copyright (c) 2023 Contributors to the Eclipse Foundation.
15+ *
16+ * This program and the accompanying materials are made
17+ * available under the terms of the Eclipse Public License 2.0
18+ * which is available at https://www.eclipse.org/legal/epl-2.0/
19+ *
20+ * SPDX-License-Identifier: EPL-2.0
21+ *
22+ * Contributors after Fork in 2023:
23+ * SmartCity Jena - initial
24+ */
1125
1226package mondrian .recorder ;
1327
2337 */
2438public abstract class AbstractRecorder implements MessageRecorder {
2539
26- private final static String tooManyMessageRecorderErrors =
27- "Context ''{0}'': Exceeded number of allowed errors ''{1,number}''" ;
28- private final static String forceMessageRecorderError =
29- "Context ''{0}'': Client forcing return with errors ''{1,number}''" ;
40+ private final static String tooManyMessageRecorderErrors = "Context ''{0}'': Exceeded number of allowed errors ''{1,number}''" ;
41+ private final static String forceMessageRecorderError = "Context ''{0}'': Client forcing return with errors ''{1,number}''" ;
3042
3143 /**
3244 * Helper method to format a message and write to logger.
3345 */
34- public static void logMessage (
35- final String context ,
36- final String msg ,
37- final MsgType msgType ,
38- final Logger logger )
39- {
46+ public static void logMessage (final String context , final String msg , final MessageType msgType ,
47+ final Logger logger ) {
4048 StringBuilder buf = new StringBuilder (64 );
4149 buf .append (context );
4250 buf .append (": " );
@@ -53,15 +61,12 @@ public static void logMessage(
5361 logger .error (logMsg );
5462 break ;
5563 default :
56- logger .warn (
57- "Unknown message type enum \" {}\" for message: {}" , msgType , logMsg );
64+ logger .warn ("Unknown message type enum \" {}\" for message: {}" , msgType , logMsg );
5865 }
5966 }
6067
61- enum MsgType {
62- INFO ,
63- WARN ,
64- ERROR
68+ enum MessageType {
69+ INFO , WARN , ERROR
6570 }
6671
6772 public static final int DEFAULT_MSG_LIMIT = 10 ;
@@ -88,7 +93,7 @@ protected AbstractRecorder(final int errorMsgLimit) {
8893 * Resets this MessageRecorder.
8994 */
9095 @ Override
91- public void clear () {
96+ public void clear () {
9297 errorMsgCount = 0 ;
9398 warningMsgCount = 0 ;
9499 infoMsgCount = 0 ;
@@ -98,27 +103,27 @@ public void clear() {
98103 }
99104
100105 @ Override
101- public long getStartTimeMillis () {
106+ public long getStartTimeMillis () {
102107 return this .startTime ;
103108 }
104109
105110 @ Override
106- public long getRunTimeMillis () {
111+ public long getRunTimeMillis () {
107112 return (System .currentTimeMillis () - this .startTime );
108113 }
109114
110115 @ Override
111- public boolean hasInformation () {
116+ public boolean hasInformation () {
112117 return (infoMsgCount > 0 );
113118 }
114119
115120 @ Override
116- public boolean hasWarnings () {
121+ public boolean hasWarnings () {
117122 return (warningMsgCount > 0 );
118123 }
119124
120125 @ Override
121- public boolean hasErrors () {
126+ public boolean hasErrors () {
122127 return (errorMsgCount > 0 );
123128 }
124129
@@ -135,7 +140,7 @@ public int getErrorCount() {
135140 }
136141
137142 @ Override
138- public String getContext () {
143+ public String getContext () {
139144 // heavy weight
140145 if (contextMsgCache == null ) {
141146 final StringBuilder buf = new StringBuilder ();
@@ -152,100 +157,83 @@ public String getContext() {
152157 }
153158
154159 @ Override
155- public void pushContextName (final String name ) {
160+ public void pushContextName (final String name ) {
156161 // light weight
157162 contexts .add (name );
158163 contextMsgCache = null ;
159164 }
160165
161166 @ Override
162- public void popContextName () {
167+ public void popContextName () {
163168 // light weight
164169 contexts .remove (contexts .size () - 1 );
165170 contextMsgCache = null ;
166171 }
167172
168173 @ Override
169- public void throwRTException () throws RecorderException {
174+ public void throwRTException () throws RecorderException {
170175 if (hasErrors ()) {
171- final String errorMsg =
172- MessageFormat .format (forceMessageRecorderError ,
173- getContext (),
174- errorMsgCount );
176+ final String errorMsg = MessageFormat .format (forceMessageRecorderError , getContext (), errorMsgCount );
175177 throw new RecorderException (errorMsg );
176178 }
177179 }
178180
179181 @ Override
180- public void reportError (final Exception ex )
181- throws RecorderException
182- {
182+ public void reportError (final Exception ex ) throws RecorderException {
183183 reportError (ex , null );
184184 }
185185
186186 @ Override
187- public void reportError (final Exception ex , final Object info )
188- throws RecorderException
189- {
187+ public void reportError (final Exception ex , final Object info ) throws RecorderException {
190188 reportError (ex .toString (), info );
191189 }
192190
193191 @ Override
194- public void reportError (final String msg )
195- throws RecorderException
196- {
192+ public void reportError (final String msg ) throws RecorderException {
197193 reportError (msg , null );
198194 }
199195
200196 @ Override
201- public void reportError (final String msg , final Object info )
202- throws RecorderException
203- {
197+ public void reportError (final String msg , final Object info ) throws RecorderException {
204198 errorMsgCount ++;
205- recordMessage (msg , info , MsgType .ERROR );
199+ recordMessage (msg , info , MessageType .ERROR );
206200
207201 if (errorMsgCount >= errorMsgLimit ) {
208- final String errorMsg =
209- MessageFormat .format (tooManyMessageRecorderErrors ,
210- getContext (),
202+ final String errorMsg = MessageFormat .format (tooManyMessageRecorderErrors , getContext (),
211203 String .valueOf (errorMsgCount ));
212204 throw new RecorderException (errorMsg );
213205 }
214206 }
215207
216208 @ Override
217- public void reportWarning (final String msg ) {
209+ public void reportWarning (final String msg ) {
218210 reportWarning (msg , null );
219211 }
220212
221213 @ Override
222- public void reportWarning (final String msg , final Object info ) {
214+ public void reportWarning (final String msg , final Object info ) {
223215 warningMsgCount ++;
224- recordMessage (msg , info , MsgType .WARN );
216+ recordMessage (msg , info , MessageType .WARN );
225217 }
226218
227219 @ Override
228- public void reportInfo (final String msg ) {
220+ public void reportInfo (final String msg ) {
229221 reportInfo (msg , null );
230222 }
231223
232224 @ Override
233- public void reportInfo (final String msg , final Object info ) {
225+ public void reportInfo (final String msg , final Object info ) {
234226 infoMsgCount ++;
235- recordMessage (msg , info , MsgType .INFO );
227+ recordMessage (msg , info , MessageType .INFO );
236228 }
237229
238230 /**
239- * Handles a message.
240- * Classes implementing this abstract class must provide an implemention
241- * of this method; it receives all warning/error messages.
231+ * Handles a message. Classes implementing this abstract class must provide an
232+ * implemention of this method; it receives all warning/error messages.
242233 *
243- * @param msg the error or warning message.
244- * @param info the information Object which might be null.
234+ * @param msg the error or warning message.
235+ * @param info the information Object which might be null.
245236 * @param msgType one of the message type enum values
246237 */
247- protected abstract void recordMessage (
248- String msg ,
249- Object info ,
250- MsgType msgType );
238+ protected abstract void recordMessage (String msg , Object info , MessageType msgType );
251239}
0 commit comments