Clover coverage report - JBind Project
Coverage timestamp: Fr Mai 28 2004 11:17:36 CEST
file stats: LOC: 81   Methods: 7
NCLOC: 47   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
DecoratedMessage.java 50% 85,7% 85,7% 81,2%
 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.util.Collections;
 13   
 import java.util.Iterator;
 14   
 import java.util.Locale;
 15   
 
 16   
 public class DecoratedMessage extends AbstractMessage {
 17   
 
 18   
   private IMessage myMessage = null;
 19   
   private Object[] myParameters = null;
 20   
 
 21   
   /**
 22   
    *
 23   
    * @param aMessageFormats <i>(required)</i>. Contains the message format that
 24   
    * is used for the decoration.
 25   
    * @param aKey <i>(required)</i>. The key of the message format that is used
 26   
    * for decoration.
 27   
    * @param aParams <i>(optional)</i>. Parameters that may be inserted into the
 28   
    * decorating message format.
 29   
    * @param aMessage <i>(required)</i>. The message that is decorated. The
 30   
    * output of the message can be accessed as the 0th parameter in the decorating
 31   
    * message format.
 32   
    */
 33  371
   public DecoratedMessage(IMessageFormats aMessageFormats, String aKey, Object[] aParams, IMessage aMessage) {
 34  371
     super(aMessageFormats, aKey);
 35  371
     myMessage = aMessage;
 36  371
     myParameters = aParams;
 37   
   }
 38   
 
 39  0
   public boolean isEmpty() {
 40  0
     return myMessage.isEmpty();
 41   
   }
 42  29
   public boolean isComposite() {
 43  29
     return myMessage.isComposite();
 44   
   }
 45  29
   public Iterator iterSubMessages() {
 46  29
     return myMessage.iterSubMessages();
 47   
   }
 48  29
   public Iterator iterSimpleMessages() {
 49  29
     Iterator res = null;
 50  29
     Iterator i = iterSubMessages();
 51  29
     if (isComposite()) {
 52  0
       res = myMessage.iterSimpleMessages();
 53   
     } else {
 54  29
       res = Collections.singletonList(this).iterator();
 55   
     }
 56  29
     return res;
 57   
   }
 58   
 
 59  322
   public Object getParameters(Locale aLocale) {
 60  322
     Object[] res = null;
 61  322
     if (null == myParameters) {
 62  0
       res = new Object[1];
 63   
     } else {
 64  322
       res = new Object[myParameters.length + 1];
 65  322
       System.arraycopy(myParameters, 0, res, 1, myParameters.length);
 66   
     }
 67   
     // The decorated message should be a simple messages.
 68   
     // However, if it is a composite message then it is output on a single line
 69   
     // replacing all returns by a vertical bar.
 70  322
     String s = myMessage.output(aLocale, false, true);
 71   
 //              s = s.replace('\n', '|');
 72  322
     res[0] = s;
 73  322
     return res;
 74   
   }
 75   
 
 76  7
   public void addTo(ICompositeMessage aCompositeMessage) {
 77  7
     aCompositeMessage.add(this);
 78   
   }
 79   
 
 80   
 }
 81