Package com.puppycrawl.tools.checkstyle
Class LocalizedMessage
java.lang.Object
com.puppycrawl.tools.checkstyle.LocalizedMessage
Represents a message that can be localised. The translations come from
 message.properties files. The underlying implementation uses
 java.text.MessageFormat.
- 
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classCustom ResourceBundle.Control implementation which allows explicitly read the properties files as UTF-8. - 
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Object[]Arguments for java.text.MessageFormat, that is why type is Object[].private final StringName of the resource bundle to get messages from.private final StringKey for the message format.private static LocaleThe locale to localise messages to.private final Class<?>Class of the source for this message. - 
Constructor Summary
ConstructorsConstructorDescriptionLocalizedMessage(String bundle, Class<?> sourceClass, String key, Object... args) Creates a newLocalizedMessageinstance. - 
Method Summary
Modifier and TypeMethodDescriptionprivate ResourceBundleObtain the ResourceBundle.Gets the translated message.static voidSets a locale to use for localization. 
- 
Field Details
- 
sLocale
The locale to localise messages to. - 
bundle
Name of the resource bundle to get messages from. - 
sourceClass
Class of the source for this message. - 
key
Key for the message format. - 
args
Arguments for java.text.MessageFormat, that is why type is Object[].Note: Changing types from Object[] will be huge breaking compatibility, as Module messages use some type formatting already, so better to keep it as Object[].
 
 - 
 - 
Constructor Details
- 
LocalizedMessage
Creates a newLocalizedMessageinstance.- Parameters:
 bundle- resource bundle namesourceClass- the Class that is the source of the messagekey- the key to locate the translation.args- arguments for the translation.
 
 - 
 - 
Method Details
- 
setLocale
Sets a locale to use for localization.- Parameters:
 locale- the locale to use for localization
 - 
getMessage
Gets the translated message.- Returns:
 - the translated message.
 
 - 
getBundle
Obtain the ResourceBundle. Uses the classloader of the class emitting this message, to be sure to get the correct bundle.- Returns:
 - a ResourceBundle.
 
 
 -