Coverage Report - org.apache.commons.i18n.bundles.TextBundle
 
Classes in this File Line Coverage Branch Coverage Complexity
TextBundle
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.LocalizedBundle;
 22  
 import org.apache.commons.i18n.MessageNotFoundException;
 23  
 
 24  
 /**
 25  
  * <p>The <code>TextBundle</code> represents the most simple localized bundle with just
 26  
  * one single entry. Use this class if you want to deal with simple localized strings that may
 27  
  * contain dynamic elements.</p>
 28  
  *
 29  
  */
 30  
 public class TextBundle extends LocalizedBundle {
 31  
     public final static String TEXT = "text";
 32  
 
 33  
     /**
 34  
      * @param messageId Unique message id that identifies the message 
 35  
      */
 36  
     public TextBundle(String messageId) {
 37  11
         super(messageId);
 38  11
     }
 39  
 
 40  
     /**
 41  
      * @param providerId The name of the message provider (i.e. source) to use for the message
 42  
      * @param messageId Unique message id that identifies the message
 43  
      */
 44  
     public TextBundle(String providerId, String messageId) {
 45  3
         super(providerId, messageId);
 46  3
     }
 47  
 
 48  
     /**
 49  
      * @param messageId Unique message id that identifies the message 
 50  
      * @param arguments An array of objects conaining the values that should be
 51  
      * inserted into the localized message.  
 52  
      */
 53  
     public TextBundle(String messageId, Object[] arguments) {
 54  3
         super(messageId, arguments);
 55  3
     }
 56  
 
 57  
     /**
 58  
      * @param providerId The name of the message provider (i.e. source) to use for the message
 59  
      * @param messageId Unique message id that identifies the message
 60  
      * @param arguments An array of objects conaining the values that should be
 61  
      * inserted into the localized message.
 62  
      */
 63  
     public TextBundle(String providerId, String messageId, Object[] arguments) {
 64  3
         super(providerId, messageId, arguments);
 65  3
     }
 66  
 
 67  
     /**
 68  
      * @param locale The locale that is used to find the appropriate localized text 
 69  
      * @return returns the localized message entry with the key <code>text</code>
 70  
      * @throws MessageNotFoundException is thrown if no entry with key <code>text</code> could be found in the message bundle identified by the given message identifier
 71  
      */
 72  
     public String getText(Locale locale) throws MessageNotFoundException  {
 73  24
         return getEntry(TEXT, locale);
 74  
     }
 75  
 
 76  
     /**
 77  
      * @param locale The locale that is used to find the appropriate localized text 
 78  
      * @param defaultText The default text will be returned, if no entry with key <code>text</code> could be found in the message bundle identified by the given message identifier
 79  
      * @return returns the localized message entry with the key <code>text</code>
 80  
      */
 81  
     public String getText(Locale locale, String defaultText) {
 82  24
         return getEntry(TEXT, locale, defaultText);
 83  
     }
 84  
 }