| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| ErrorBundle |
|
| 1.0;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>ErrorBundle</code> bundles together title, text, details and summary.</p> | |
| 26 | * <p>This bundle can be used to describe an error in detail and is used in the provided localized | |
| 27 | * exceptions.</p> | |
| 28 | * | |
| 29 | */ | |
| 30 | public class ErrorBundle extends MessageBundle { | |
| 31 | public final static String SUMMARY = "summary"; | |
| 32 | public final static String DETAILS = "details"; | |
| 33 | ||
| 34 | /** | |
| 35 | * @param messageId Unique message id that identifies the message | |
| 36 | */ | |
| 37 | public ErrorBundle(String messageId) { | |
| 38 | 7 | super(messageId); |
| 39 | 7 | } |
| 40 | ||
| 41 | /** | |
| 42 | * @param providerId The name of the message provider (i.e. source) to use for the message | |
| 43 | * @param messageId Unique message id that identifies the message | |
| 44 | */ | |
| 45 | public ErrorBundle(String providerId, String messageId) { | |
| 46 | 1 | super(providerId, messageId); |
| 47 | 1 | } |
| 48 | ||
| 49 | /** | |
| 50 | * @param messageId Unique message id that identifies the message | |
| 51 | * @param arguments An array of objects conaining the values that should be | |
| 52 | * inserted into the localized message. | |
| 53 | */ | |
| 54 | public ErrorBundle(String messageId, Object[] arguments) { | |
| 55 | 1 | super(messageId, arguments); |
| 56 | 1 | } |
| 57 | ||
| 58 | /** | |
| 59 | * @param providerId The name of the message provider (i.e. source) to use for the message | |
| 60 | * @param messageId Unique message id that identifies the message | |
| 61 | * @param arguments An array of objects conaining the values that should be | |
| 62 | * inserted into the localized message. | |
| 63 | */ | |
| 64 | public ErrorBundle(String providerId, String messageId, Object[] arguments) { | |
| 65 | 1 | super(providerId, messageId, arguments); |
| 66 | 1 | } |
| 67 | ||
| 68 | /** | |
| 69 | * @param locale The locale that is used to find the appropriate localized text | |
| 70 | * @return returns the localized message entry with the key <code>summary</code> | |
| 71 | * @throws MessageNotFoundException is thrown if no entry with key <code>summary</code> could be found in the message bundle identified by the given message identifier | |
| 72 | */ | |
| 73 | public String getSummary(Locale locale) throws MessageNotFoundException { | |
| 74 | 4 | return getEntry(SUMMARY, locale); |
| 75 | } | |
| 76 | ||
| 77 | /** | |
| 78 | * @param locale The locale that is used to find the appropriate localized text | |
| 79 | * @param defaultSummary The default text will be returned, if no entry with key <code>summary</code> could be found in the message bundle identified by the given message identifier | |
| 80 | * @return returns the localized message entry with the key <code>summary</code> | |
| 81 | */ | |
| 82 | public String getSummary(Locale locale, String defaultSummary) { | |
| 83 | 16 | return getEntry(SUMMARY, locale, defaultSummary); |
| 84 | } | |
| 85 | ||
| 86 | ||
| 87 | /** | |
| 88 | * @param locale The locale that is used to find the appropriate localized text | |
| 89 | * @return returns the localized message entry with the key <code>details</code> | |
| 90 | * @throws MessageNotFoundException is thrown if no entry with key <code>details</code> could be found in the message bundle identified by the given message identifier | |
| 91 | */ | |
| 92 | public String getDetails(Locale locale) throws MessageNotFoundException { | |
| 93 | 4 | return getEntry(DETAILS, locale); |
| 94 | } | |
| 95 | ||
| 96 | /** | |
| 97 | * @param locale The locale that is used to find the appropriate localized text | |
| 98 | * @param defaultDetails The default text will be returned, if no entry with key <code>details</code> could be found in the message bundle identified by the given message identifier | |
| 99 | * @return returns the localized message entry with the key <code>details</code> | |
| 100 | */ | |
| 101 | public String getDetails(Locale locale, String defaultDetails) { | |
| 102 | 4 | return getEntry(DETAILS, locale, defaultDetails); |
| 103 | } | |
| 104 | } |