|
||||||||||
| PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES | |||||||||
See:
Description
| Interface Summary | |
|---|---|
| ParameterConverter<I> | A converter for a specific parameter type. |
| Class Summary | |
|---|---|
| Messages | A factory class to produce message bundle implementations. |
| Enum Summary | |
|---|---|
| Message.Format | The possible format types. |
| Annotation Types Summary | |
|---|---|
| Cause | Mark a parameter as being the "exception cause" parameter rather than a positional format parameter. |
| Field | Indicate that a method parameter value should be applied to a field on the resultant exception object. |
| Formatter | Indicate that the given parameter should be wrapped with a formatting object of the given class. |
| Locale | Specifies a Locale for a typed logger. |
| Message | Assigns a message string to a resource method. |
| MessageBundle | Signify that an interface is a message bundle interface. |
| Param | Identifies a parameter is to be used for constructing an exception and excluded from the formatting of the message. |
| Property | Indicate that a method parameter value should be applied to a property (with a setter method) on the resultant exception object. |
Solder provides injectable typed message bundles (suitable for internationalization and localization)
Often times you need to access a localized message. For example, you need to localize an exception message. Solder let's you retrieve this message from a typed message logger to avoid having to use hard-coded string messages.
First, declare the message bundle as an annotated interface with methods configured as message accessors. You can configured the messages to use printf-style interpolations of parameters (%s).
@MessageBundle
public interface TrainMessages {
@Message("No trains spotted due to %s")
String noTrainsSpotted(String cause);
}
Now inject the interface:
@Inject @MessageBundle TrainMessages messages;
And use it:
throw new BadDayException(messages.noTrainsSpotted("leaves on the line"));
Message,
MessageBundle,
Locale
|
||||||||||
| PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES | |||||||||