| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||||
| ResourceBundleMessageSource |
|
| 1.0;1 |
| 1 | /* |
|
| 2 | * Created on 25/11/2005 by Eduardo Piva - eduardo@gwe.com.br |
|
| 3 | * |
|
| 4 | */ |
|
| 5 | package org.trails.i18n; |
|
| 6 | ||
| 7 | import java.util.Locale; |
|
| 8 | ||
| 9 | import org.trails.descriptor.IClassDescriptor; |
|
| 10 | import org.trails.descriptor.IDescriptor; |
|
| 11 | ||
| 12 | /** |
|
| 13 | * Interface used to imlement i18n in Trails pages and components. |
|
| 14 | */ |
|
| 15 | public interface ResourceBundleMessageSource |
|
| 16 | { |
|
| 17 | ||
| 18 | /** |
|
| 19 | * Return a internationalized message. |
|
| 20 | * |
|
| 21 | * @param key Key used to locate the message. |
|
| 22 | * @param locale Locale used to locate message. |
|
| 23 | * @return Localized message. Return null if message not found. |
|
| 24 | */ |
|
| 25 | public String getMessage(String key, Locale locale); |
|
| 26 | ||
| 27 | /** |
|
| 28 | * Return a internationalized message specifing arguments to format this message. |
|
| 29 | * |
|
| 30 | * @param key Key used to locate the message. |
|
| 31 | * @param args Arguments to format the message. |
|
| 32 | * @param locale Locale used to locate message. |
|
| 33 | * @return Localized message. Return null of message not found. |
|
| 34 | */ |
|
| 35 | public String getMessage(String key, Object[] args, Locale locale); |
|
| 36 | ||
| 37 | /** |
|
| 38 | * Same as getMessage(String key, Locale locale), but it will return a default |
|
| 39 | * value instead of null if message not found. |
|
| 40 | * |
|
| 41 | * @param defaultMessage Default message to return if message not found. |
|
| 42 | */ |
|
| 43 | public String getMessageWithDefaultValue(String key, Locale locale, String defaultMessage); |
|
| 44 | ||
| 45 | /** |
|
| 46 | * Same as getMessage(String key, Object[] args, Locale locale), but will return a default |
|
| 47 | * value instead of null if message not found. |
|
| 48 | * |
|
| 49 | * @param defaultMessage Default message to return if message not found. |
|
| 50 | */ |
|
| 51 | public String getMessageWithDefaultValue(String key, Object[] args, Locale locale, String defaultMessage); |
|
| 52 | ||
| 53 | /** |
|
| 54 | * Given a IDescriptor and a Locale, this method select an i18n message for the |
|
| 55 | * descriptor. If no i18n message is found, a defaultMessage is used instead. |
|
| 56 | * |
|
| 57 | * @param clazz Class description. |
|
| 58 | * @param locale Locale |
|
| 59 | * @param defaultDisplayName default displayName to return if no i18n message is found. |
|
| 60 | * @return |
|
| 61 | */ |
|
| 62 | public String getDisplayName(IDescriptor clazz, Locale locale, String defaultDisplayName); |
|
| 63 | ||
| 64 | /** |
|
| 65 | * Given a IClassDescriptor and a Locale, this method select an i18n message for |
|
| 66 | * the class in the plural name |
|
| 67 | * |
|
| 68 | * @param clazz Class description |
|
| 69 | * @param locale Locale |
|
| 70 | * @param defaultDisplayName default displayName to return if no i18n message is found. |
|
| 71 | * @return |
|
| 72 | */ |
|
| 73 | public String getPluralDislayName(IClassDescriptor clazz, Locale locale, String defaultDisplayName); |
|
| 74 | ||
| 75 | } |