Package com.puppycrawl.tools.checkstyle
Class DefaultLogger.LocalizedMessage
java.lang.Object
com.puppycrawl.tools.checkstyle.DefaultLogger.LocalizedMessage
- Enclosing class:
DefaultLogger
Represents a message that can be localised. The translations come from
message.properties files. The underlying implementation uses
java.text.MessageFormat.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionLocalizedMessage
(String key) Creates a newLocalizedMessage
instance.LocalizedMessage
(String key, String... args) Creates a newLocalizedMessage
instance. -
Method Summary
Modifier and TypeMethodDescriptionprivate static ResourceBundle
Find a ResourceBundle for a given bundle name.private String
Gets the translated message.
-
Field Details
-
BUNDLE_CACHE
A cache that maps bundle names to ResourceBundles. Avoids repetitive calls to ResourceBundle.getBundle(). -
LOCALE
The locale to localise messages to. -
key
Key for the message format. -
args
Arguments for MessageFormat.
-
-
Constructor Details
-
LocalizedMessage
LocalizedMessage(String key) Creates a newLocalizedMessage
instance.- Parameters:
key
- the key to locate the translation.
-
LocalizedMessage
Creates a newLocalizedMessage
instance.- Parameters:
key
- the key to locate the translation.args
- arguments for the translation.
-
-
Method Details
-
getMessage
Gets the translated message.- Returns:
- the translated message.
-
getBundle
Find a ResourceBundle for a given bundle name. Uses the classloader of the class emitting this message, to be sure to get the correct bundle.- Parameters:
bundleName
- the bundle name.- Returns:
- a ResourceBundle.
-