Coverage Report - org.apache.maven.plugin.ide.Messages
 
Classes in this File Line Coverage Branch Coverage Complexity
Messages
0% 
N/A 
2
 
 1  
 package org.apache.maven.plugin.ide;
 2  
 
 3  
 /*
 4  
  * Copyright 2001-2005 The Apache Software Foundation.
 5  
  *
 6  
  * Licensed under the Apache License, Version 2.0 (the "License");
 7  
  * you may not use this file except in compliance with the License.
 8  
  * You may obtain a copy of the License at
 9  
  *
 10  
  *      http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing, software
 13  
  * distributed under the License is distributed on an "AS IS" BASIS,
 14  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15  
  * See the License for the specific language governing permissions and
 16  
  * limitations under the License.
 17  
  */
 18  
 
 19  
 import java.text.MessageFormat;
 20  
 import java.util.MissingResourceException;
 21  
 import java.util.ResourceBundle;
 22  
 
 23  
 /**
 24  
  * @author <a href="mailto:fgiust@users.sourceforge.net">Fabrizio Giustina</a>
 25  
  * @version $Id: Messages.java 390686 2006-04-01 15:39:33Z fgiust $
 26  
  */
 27  
 class Messages
 28  
 {
 29  
 
 30  
     /**
 31  
      * bundle filename.
 32  
      */
 33  
     private static final String BUNDLE_NAME = "org.apache.maven.plugin.ide.messages"; //$NON-NLS-1$
 34  
 
 35  
     /**
 36  
      * Static resource bundle.
 37  
      */
 38  0
     private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME );
 39  
 
 40  
     /**
 41  
      * Don't instantiate.
 42  
      *
 43  
      */
 44  
     private Messages()
 45  0
     {
 46  0
     }
 47  
 
 48  
     /**
 49  
      * Returns a string from the bundle.
 50  
      * @param key message key
 51  
      * @return message value or <code>!key!</code> if key is not found
 52  
      */
 53  
     public static String getString( String key )
 54  
     {
 55  
         try
 56  
         {
 57  0
             return RESOURCE_BUNDLE.getString( key );
 58  
         }
 59  0
         catch ( MissingResourceException e )
 60  
         {
 61  0
             return '!' + key + '!';
 62  
         }
 63  
     }
 64  
 
 65  
     /**
 66  
      * Returns a string from the bundle, formatting it using provided params.
 67  
      * @param key message key
 68  
      * @param params MessageFormat arguments
 69  
      * @return message value or <code>!key!</code> if key is not found
 70  
      */
 71  
     public static String getString( String key, Object[] params )
 72  
     {
 73  
         try
 74  
         {
 75  0
             return MessageFormat.format( RESOURCE_BUNDLE.getString( key ), params );
 76  
         }
 77  0
         catch ( MissingResourceException e )
 78  
         {
 79  0
             return '!' + key + '!';
 80  
         }
 81  
     }
 82  
 
 83  
     /**
 84  
      * Returns a string from the bundle, formatting it using provided param.
 85  
      * @param key message key
 86  
      * @param param MessageFormat arguments
 87  
      * @return message value or <code>!key!</code> if key is not found
 88  
      */
 89  
     public static String getString( String key, Object param )
 90  
     {
 91  0
         return getString( key, new Object[] { param } );
 92  
     }
 93  
 }