- Timestamp:
- 10/10/11 22:15:34 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaHelperLib/src/de/ugoe/cs/util/console/Console.java
r210 r250 71 71 * </p> 72 72 */ 73 private static Console theInstance = n ull;73 private static Console theInstance = new Console(); 74 74 75 75 /** … … 82 82 */ 83 83 public static Console getInstance() { 84 if (theInstance == null) {85 theInstance = new Console();86 }87 84 return theInstance; 88 85 } … … 90 87 /** 91 88 * <p> 89 * Resets the Console by creating a new instance that has no registered 90 * observers. 91 * </p> 92 */ 93 public static void reset() { 94 theInstance.init(); 95 } 96 97 /** 98 * <p> 92 99 * Creates a new Console. Private to prevent multiple instances (Singleton). 93 100 * </p> 94 101 */ 95 102 private Console() { 103 init(); 104 } 105 106 /** 107 * <p> 108 * Initializes the console. 109 * </p> 110 */ 111 private void init() { 96 112 outputListener = new LinkedHashSet<IOutputListener>(); 97 113 errorListener = new LinkedHashSet<IErrorListener>(); … … 257 273 /** 258 274 * <p> 275 * Checks if a listener is registered. 276 * </p> 277 * 278 * @param listener 279 * listener that is checked 280 * @return true, is listener is registered; false, otherwise 281 */ 282 public boolean hasOutputListener(IOutputListener listener) { 283 return outputListener.contains(listener); 284 } 285 286 /** 287 * <p> 288 * Checks if a listener is registered. 289 * </p> 290 * 291 * @param listener 292 * listener that is checked 293 * @return true, is listener is registered; false, otherwise 294 */ 295 public boolean hasErrorListener(IErrorListener listener) { 296 return errorListener.contains(listener); 297 } 298 299 /** 300 * <p> 301 * Checks if a listener is registered. 302 * </p> 303 * 304 * @param listener 305 * listener that is checked 306 * @return true, is listener is registered; false, otherwise 307 */ 308 public boolean hasTraceListener(ITraceListener listener) { 309 return traceListener.contains(listener); 310 } 311 312 /** 313 * <p> 314 * Checks if a listener is registered. 315 * </p> 316 * 317 * @param listener 318 * listener that is checked 319 * @return true, is listener is registered; false, otherwise 320 */ 321 public boolean hasCommandListener(ICommandListener listener) { 322 return commandListener.contains(listener); 323 } 324 325 /** 326 * <p> 327 * Checks if a listener is registered. 328 * </p> 329 * 330 * @param listener 331 * listener that is checked 332 * @return true, is listener is registered; false, otherwise 333 */ 334 public boolean hasExceptionListener(IExceptionListener listener) { 335 return exceptionListener.contains(listener); 336 } 337 338 /** 339 * <p> 259 340 * Sends a message to all observers containing the message that was passed 260 341 * to this function. … … 265 346 */ 266 347 public static void print(String msg) { 267 if (theInstance == null) {268 getInstance();269 }270 348 for (IOutputListener observer : theInstance.outputListener) { 271 349 observer.outputMsg(msg); … … 283 361 */ 284 362 public static void println(String msg) { 285 if (theInstance == null) {286 getInstance();287 }288 363 for (IOutputListener observer : theInstance.outputListener) { 289 364 observer.outputMsg(msg + StringTools.ENDLINE); … … 301 376 */ 302 377 public static void printerr(String errMsg) { 303 if (theInstance == null) {304 getInstance();305 }306 378 for (IErrorListener observer : theInstance.errorListener) { 307 379 observer.errorMsg(errMsg); … … 319 391 */ 320 392 public static void printerrln(String errMsg) { 321 if (theInstance == null) {322 getInstance();323 }324 393 for (IErrorListener observer : theInstance.errorListener) { 325 394 observer.errorMsg(errMsg + StringTools.ENDLINE); … … 336 405 */ 337 406 public static void logException(Exception e) { 338 if (theInstance == null) {339 getInstance();340 }341 407 for (IExceptionListener observer : theInstance.exceptionListener) { 342 408 observer.logException(e); … … 354 420 */ 355 421 public static void trace(String traceMsg) { 356 if (theInstance == null) {357 getInstance();358 }359 422 for (ITraceListener observer : theInstance.traceListener) { 360 423 observer.traceMsg(traceMsg); … … 373 436 */ 374 437 public static void traceln(String traceMsg) { 375 if (theInstance == null) {376 getInstance();377 }378 438 for (ITraceListener observer : theInstance.traceListener) { 379 439 observer.traceMsg(traceMsg + StringTools.ENDLINE); … … 390 450 */ 391 451 static void commandNotification(String command) { 392 if (theInstance == null) {393 getInstance();394 }395 452 for (ICommandListener observer : theInstance.commandListener) { 396 453 observer.commandNotification(command);
Note: See TracChangeset
for help on using the changeset viewer.