Clover coverage report - Code Coverage for hivemind release 1.1-alpha-2
Coverage timestamp: Wed Feb 23 2005 09:59:04 EST
file stats: LOC: 74   Methods: 6
NCLOC: 43   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
MessageFormatter.java - 80% 100% 87.5%
coverage coverage
 1   
 // Copyright 2004, 2005 The Apache Software Foundation
 2   
 //
 3   
 // Licensed under the Apache License, Version 2.0 (the "License");
 4   
 // you may not use this file except in compliance with the License.
 5   
 // You may obtain a copy of the License at
 6   
 //
 7   
 //     http://www.apache.org/licenses/LICENSE-2.0
 8   
 //
 9   
 // Unless required by applicable law or agreed to in writing, software
 10   
 // distributed under the License is distributed on an "AS IS" BASIS,
 11   
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12   
 // See the License for the specific language governing permissions and
 13   
 // limitations under the License.
 14   
 
 15   
 package org.apache.hivemind.impl;
 16   
 
 17   
 import java.util.Locale;
 18   
 import java.util.MissingResourceException;
 19   
 import java.util.ResourceBundle;
 20   
 
 21   
 import org.apache.commons.logging.Log;
 22   
 import org.apache.commons.logging.LogFactory;
 23   
 
 24   
 /**
 25   
  * A wrapper around {@link java.util.ResourceBundle}that makes it easier to access and format
 26   
  * messages.
 27   
  * 
 28   
  * @author Howard Lewis Ship
 29   
  */
 30   
 public class MessageFormatter extends AbstractMessages
 31   
 {
 32   
     private Log _log;
 33   
 
 34   
     private ResourceBundle _bundle;
 35   
 
 36  12
     public MessageFormatter(Log log, ResourceBundle bundle)
 37   
     {
 38  12
         _log = log;
 39  12
         _bundle = bundle;
 40   
     }
 41   
 
 42  12
     public MessageFormatter(Class referenceClass, String name)
 43   
     {
 44  12
         this(LogFactory.getLog(referenceClass), referenceClass, name);
 45   
     }
 46   
 
 47  12
     public MessageFormatter(Log log, Class referenceClass, String name)
 48   
     {
 49  12
         this(log, referenceClass.getPackage().getName() + "." + name);
 50   
     }
 51   
 
 52  12
     public MessageFormatter(Log log, String bundleName)
 53   
     {
 54  12
         this(log, ResourceBundle.getBundle(bundleName));
 55   
     }
 56   
 
 57  293
     protected String findMessage(String key)
 58   
     {
 59  293
         try
 60   
         {
 61  293
             return _bundle.getString(key);
 62   
         }
 63   
         catch (MissingResourceException ex)
 64   
         {
 65  0
             _log.error("Missing resource key: " + key + ".");
 66  0
             return null;
 67   
         }
 68   
     }
 69   
 
 70  239
     protected Locale getLocale()
 71   
     {
 72  239
         return Locale.getDefault();
 73   
     }
 74   
 }