Coverage Report - org.apache.commons.i18n.bundles.MessageBundle
 
Classes in this File Line Coverage Branch Coverage Complexity
MessageBundle
100%
10/10
N/A
1
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements.  See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to You under the Apache License, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License.  You may obtain a copy of the License at
 8  
  *
 9  
  *      http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.apache.commons.i18n.bundles;
 18  
 
 19  
 import java.util.Locale;
 20  
 
 21  
 import org.apache.commons.i18n.MessageNotFoundException;
 22  
 
 23  
 
 24  
 /**
 25  
  * <p>The <code>MessageBundle</code> groups together title and text.</p>
 26  
  *
 27  
  */
 28  
 public class MessageBundle extends TextBundle {
 29  
     public final static String TITLE = "title";
 30  
 
 31  
     /**
 32  
      * @param messageId Unique message id that identifies the message 
 33  
      */
 34  
     public MessageBundle(String messageId) {
 35  10
         super(messageId);
 36  10
     }
 37  
 
 38  
     /**
 39  
      * @param providerId The name of the message provider (i.e. source) to use for the message
 40  
      * @param messageId Unique message id that identifies the message
 41  
      */
 42  
     public MessageBundle(String providerId, String messageId) {
 43  2
         super(providerId, messageId);
 44  2
     }
 45  
 
 46  
     /**
 47  
      * @param messageId Unique message id that identifies the message 
 48  
      * @param arguments An array of objects conaining the values that should be
 49  
      * inserted into the localized message.  
 50  
      */
 51  
     public MessageBundle(String messageId, Object[] arguments) {
 52  2
         super(messageId, arguments);
 53  2
     }
 54  
 
 55  
     /**
 56  
      * @param providerId The name of the message provider (i.e. source) to use for the message
 57  
      * @param messageId Unique message id that identifies the message
 58  
      * @param arguments An array of objects conaining the values that should be
 59  
      * inserted into the localized message.
 60  
      */
 61  
     public MessageBundle(String providerId, String messageId, Object[] arguments) {
 62  2
         super(providerId, messageId, arguments);
 63  2
     }
 64  
 
 65  
     /**
 66  
      * @param locale The locale that is used to find the appropriate localized text 
 67  
      * @return returns the localized message entry with the key <code>title</code>
 68  
      * @throws MessageNotFoundException is thrown if no entry with key <code>title</code> could be found in the message bundle identified by the given message identifier
 69  
      */
 70  
     public String getTitle(Locale locale) throws MessageNotFoundException {
 71  14
         return getEntry(TITLE, locale);
 72  
     }
 73  
 
 74  
     /**
 75  
      * @param locale The locale that is used to find the appropriate localized text 
 76  
      * @param defaultTitle The default text will be returned, if no entry with key <code>title</code> could be found in the message bundle identified by the given message identifier
 77  
      * @return returns the localized message entry with the key <code>title</code>
 78  
      */
 79  
     public String getTitle(Locale locale, String defaultTitle) {
 80  8
         return getEntry(TITLE, locale, defaultTitle);
 81  
     }
 82  
 }