Class LocalizedMessage
java.lang.Object
com.puppycrawl.tools.checkstyle.api.LocalizedMessage
- All Implemented Interfaces:
Serializable
,Comparable<LocalizedMessage>
public final class LocalizedMessage
extends Object
implements Comparable<LocalizedMessage>, Serializable
Represents a message that can be localised. The translations come from
message.properties files. The underlying implementation uses
java.text.MessageFormat.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Custom ResourceBundle.Control implementation which allows explicitly read the properties files as UTF-8. -
Constructor Summary
ConstructorsConstructorDescriptionLocalizedMessage
(int lineNo, int columnNo, int columnCharIndex, int tokenType, String bundle, String key, Object[] args, SeverityLevel severityLevel, String moduleId, Class<?> sourceClass, String customMessage) Creates a newLocalizedMessage
instance.LocalizedMessage
(int lineNo, int columnNo, int tokenType, String bundle, String key, Object[] args, SeverityLevel severityLevel, String moduleId, Class<?> sourceClass, String customMessage) Creates a newLocalizedMessage
instance.LocalizedMessage
(int lineNo, int columnNo, String bundle, String key, Object[] args, SeverityLevel severityLevel, String moduleId, Class<?> sourceClass, String customMessage) Creates a newLocalizedMessage
instance.LocalizedMessage
(int lineNo, int columnNo, String bundle, String key, Object[] args, String moduleId, Class<?> sourceClass, String customMessage) Creates a newLocalizedMessage
instance.LocalizedMessage
(int lineNo, String bundle, String key, Object[] args, SeverityLevel severityLevel, String moduleId, Class<?> sourceClass, String customMessage) Creates a newLocalizedMessage
instance.LocalizedMessage
(int lineNo, String bundle, String key, Object[] args, String moduleId, Class<?> sourceClass, String customMessage) Creates a newLocalizedMessage
instance. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
Clears the cache.int
compareTo
(LocalizedMessage other) boolean
Indicates whether some other object is "equal to" this one.int
Gets the column char index.int
Gets the column number.getKey()
Returns the message key to locate the translation, can also be used in IDE plugins to map audit event messages to corrective actions.int
Gets the line number.Gets the translated message.Returns id of module.Gets the severity level.Gets the name of the source for this LocalizedMessage.int
Gets the token type.int
hashCode()
static void
Sets a locale to use for localization.
-
Constructor Details
-
LocalizedMessage
public LocalizedMessage(int lineNo, int columnNo, int columnCharIndex, int tokenType, String bundle, String key, Object[] args, SeverityLevel severityLevel, String moduleId, Class<?> sourceClass, String customMessage) Creates a newLocalizedMessage
instance.- Parameters:
lineNo
- line number associated with the messagecolumnNo
- column number associated with the messagecolumnCharIndex
- column char index associated with the messagetokenType
- token type of the event associated with the message. SeeTokenTypes
bundle
- resource bundle namekey
- the key to locate the translationargs
- arguments for the translationseverityLevel
- severity level for the messagemoduleId
- the id of the module the message is associated withsourceClass
- the Class that is the source of the messagecustomMessage
- optional custom message overriding the default
-
LocalizedMessage
public LocalizedMessage(int lineNo, int columnNo, int tokenType, String bundle, String key, Object[] args, SeverityLevel severityLevel, String moduleId, Class<?> sourceClass, String customMessage) Creates a newLocalizedMessage
instance.- Parameters:
lineNo
- line number associated with the messagecolumnNo
- column number associated with the messagetokenType
- token type of the event associated with the message. SeeTokenTypes
bundle
- resource bundle namekey
- the key to locate the translationargs
- arguments for the translationseverityLevel
- severity level for the messagemoduleId
- the id of the module the message is associated withsourceClass
- the Class that is the source of the messagecustomMessage
- optional custom message overriding the default
-
LocalizedMessage
public LocalizedMessage(int lineNo, int columnNo, String bundle, String key, Object[] args, SeverityLevel severityLevel, String moduleId, Class<?> sourceClass, String customMessage) Creates a newLocalizedMessage
instance.- Parameters:
lineNo
- line number associated with the messagecolumnNo
- column number associated with the messagebundle
- resource bundle namekey
- the key to locate the translationargs
- arguments for the translationseverityLevel
- severity level for the messagemoduleId
- the id of the module the message is associated withsourceClass
- the Class that is the source of the messagecustomMessage
- optional custom message overriding the default
-
LocalizedMessage
public LocalizedMessage(int lineNo, int columnNo, String bundle, String key, Object[] args, String moduleId, Class<?> sourceClass, String customMessage) Creates a newLocalizedMessage
instance.- Parameters:
lineNo
- line number associated with the messagecolumnNo
- column number associated with the messagebundle
- resource bundle namekey
- the key to locate the translationargs
- arguments for the translationmoduleId
- the id of the module the message is associated withsourceClass
- the Class that is the source of the messagecustomMessage
- optional custom message overriding the default
-
LocalizedMessage
public LocalizedMessage(int lineNo, String bundle, String key, Object[] args, SeverityLevel severityLevel, String moduleId, Class<?> sourceClass, String customMessage) Creates a newLocalizedMessage
instance.- Parameters:
lineNo
- line number associated with the messagebundle
- resource bundle namekey
- the key to locate the translationargs
- arguments for the translationseverityLevel
- severity level for the messagemoduleId
- the id of the module the message is associated withsourceClass
- the source class for the messagecustomMessage
- optional custom message overriding the default
-
LocalizedMessage
public LocalizedMessage(int lineNo, String bundle, String key, Object[] args, String moduleId, Class<?> sourceClass, String customMessage) Creates a newLocalizedMessage
instance. The column number defaults to 0.- Parameters:
lineNo
- line number associated with the messagebundle
- name of a resource bundle that contains audit event messageskey
- the key to locate the translationargs
- arguments for the translationmoduleId
- the id of the module the message is associated withsourceClass
- the name of the source for the messagecustomMessage
- optional custom message overriding the default
-
-
Method Details
-
getLineNo
public int getLineNo()Gets the line number.- Returns:
- the line number
-
getColumnNo
public int getColumnNo()Gets the column number.- Returns:
- the column number
-
getColumnCharIndex
public int getColumnCharIndex()Gets the column char index.- Returns:
- the column char index
-
getTokenType
public int getTokenType()Gets the token type.- Returns:
- the token type
-
getSeverityLevel
Gets the severity level.- Returns:
- the severity level
-
getModuleId
Returns id of module.- Returns:
- the module identifier.
-
getKey
Returns the message key to locate the translation, can also be used in IDE plugins to map audit event messages to corrective actions.- Returns:
- the message key
-
getSourceName
Gets the name of the source for this LocalizedMessage.- Returns:
- the name of the source for this LocalizedMessage
-
setLocale
Sets a locale to use for localization.- Parameters:
locale
- the locale to use for localization
-
clearCache
public static void clearCache()Clears the cache. -
equals
Indicates whether some other object is "equal to" this one. Suppression on enumeration is needed so code stays consistent. -
hashCode
public int hashCode() -
compareTo
- Specified by:
compareTo
in interfaceComparable<LocalizedMessage>
-
getMessage
Gets the translated message.- Returns:
- the translated message
-