Clover coverage report - JBind Project
Coverage timestamp: Fr Mai 28 2004 11:17:36 CEST
file stats: LOC: 61   Methods: 5
NCLOC: 41   Classes: 1
This license of Clover is provided to support the development of JBind only. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover.
 
 Source file Conditionals Statements Methods TOTAL
AbstractMessage.java 25% 52,9% 80% 53,8%
 1   
 /*
 2   
  * JBind
 3   
  *
 4   
  * Copyright (c) by Stefan Wachter. All rights reserved.
 5   
  *
 6   
  * Usage, modification, and redistribution is subject to license terms that are
 7   
  * available at 'http://www.jbind.org'. The JBind license is like the
 8   
  * 'Apache Software License V 1.1'.
 9   
  */
 10   
 package org.jbind.message;
 11   
 
 12   
 import java.io.PrintWriter;
 13   
 import java.io.StringWriter;
 14   
 import java.text.MessageFormat;
 15   
 import java.util.Locale;
 16   
 
 17   
 public abstract class AbstractMessage implements IMessage {
 18   
 
 19   
   private static boolean DEBUG = false;
 20   
   private IMessageFormats myMessageFormats = null;
 21   
   private String myKey = null;
 22   
 
 23   
   private Throwable myThrowable = null;
 24   
 
 25  17475
   public AbstractMessage(IMessageFormats aMessageFormats, String aKey) {
 26  17475
     myMessageFormats = aMessageFormats;
 27  17475
     myKey = aKey;
 28  17475
     if (DEBUG) {
 29  0
       myThrowable = new Throwable();
 30   
     }
 31   
   }
 32   
 
 33  333
   public final String output(Locale aLocale) {
 34  333
     return output(aLocale, true, true);
 35   
   }
 36   
 
 37  948
   public String output(Locale aLocale, boolean anIndent, boolean anOutputContainerLines) {
 38  948
     MessageFormat mf = myMessageFormats.getMessageFormat(aLocale, myKey);
 39  948
     Object o = getParameters(aLocale);
 40  948
     String s = mf.format(o);
 41  948
     return DEBUG ? s + "\n" + getOrigin() : s;
 42   
   }
 43   
 
 44   
   protected abstract Object getParameters(Locale aLocale);
 45   
 
 46  0
   public String getOrigin() {
 47  0
     String res = null;
 48  0
     if (DEBUG) {
 49  0
       StringWriter writer = new StringWriter();
 50  0
       PrintWriter printWriter = new PrintWriter(writer);
 51  0
       myThrowable.printStackTrace(printWriter);
 52  0
       res = "message was created at:\n" + writer.toString();
 53   
     }
 54  0
     return res;
 55   
   }
 56   
 
 57  290
   public String toString() {
 58  290
     return output(null);
 59   
   }
 60   
 }
 61