public final class LocalizedMessage extends java.lang.Object implements java.lang.Comparable<LocalizedMessage>, java.io.Serializable
Modifier and Type | Class and Description |
---|---|
static class |
LocalizedMessage.Utf8Control
Custom ResourceBundle.Control implementation which allows explicitly read
the properties files as UTF-8.
|
Modifier and Type | Field and Description |
---|---|
private java.lang.Object[] |
args
Arguments for MessageFormat.
|
private java.lang.String |
bundle
Name of the resource bundle to get messages from.
|
private static java.util.Map<java.lang.String,java.util.ResourceBundle> |
BUNDLE_CACHE
A cache that maps bundle names to ResourceBundles.
|
private int |
columnNo
The column number.
|
private java.lang.String |
customMessage
A custom message overriding the default message from the bundle.
|
private static SeverityLevel |
DEFAULT_SEVERITY
The default severity level if one is not specified.
|
private java.lang.String |
key
Key for the message format.
|
private int |
lineNo
The line number.
|
private java.lang.String |
moduleId
The id of the module generating the message.
|
private static long |
serialVersionUID |
private SeverityLevel |
severityLevel
The severity level.
|
private static java.util.Locale |
sLocale
The locale to localise messages to.
|
private java.lang.Class<?> |
sourceClass
Class of the source for this LocalizedMessage.
|
Constructor and Description |
---|
LocalizedMessage(int lineNo,
int columnNo,
java.lang.String bundle,
java.lang.String key,
java.lang.Object[] args,
SeverityLevel severityLevel,
java.lang.String moduleId,
java.lang.Class<?> sourceClass,
java.lang.String customMessage)
Creates a new
LocalizedMessage instance. |
LocalizedMessage(int lineNo,
int columnNo,
java.lang.String bundle,
java.lang.String key,
java.lang.Object[] args,
java.lang.String moduleId,
java.lang.Class<?> sourceClass,
java.lang.String customMessage)
Creates a new
LocalizedMessage instance. |
LocalizedMessage(int lineNo,
java.lang.String bundle,
java.lang.String key,
java.lang.Object[] args,
SeverityLevel severityLevel,
java.lang.String moduleId,
java.lang.Class<?> sourceClass,
java.lang.String customMessage)
Creates a new
LocalizedMessage instance. |
LocalizedMessage(int lineNo,
java.lang.String bundle,
java.lang.String key,
java.lang.Object[] args,
java.lang.String moduleId,
java.lang.Class<?> sourceClass,
java.lang.String customMessage)
Creates a new
LocalizedMessage instance. |
Modifier and Type | Method and Description |
---|---|
static void |
clearCache()
Clears the cache.
|
int |
compareTo(LocalizedMessage other) |
boolean |
equals(java.lang.Object object) |
private java.util.ResourceBundle |
getBundle(java.lang.String bundleName)
Find a ResourceBundle for a given bundle name.
|
int |
getColumnNo()
Gets the column number.
|
private java.lang.String |
getCustomMessage()
Returns the formatted custom message if one is configured.
|
java.lang.String |
getKey()
Returns the message key to locate the translation, can also be used
in IDE plugins to map error messages to corrective actions.
|
int |
getLineNo()
Gets the line number.
|
java.lang.String |
getMessage()
Gets the translated message.
|
java.lang.String |
getModuleId()
Returns id of module.
|
SeverityLevel |
getSeverityLevel()
Gets the severity level.
|
java.lang.String |
getSourceName()
Gets the name of the source for this LocalizedMessage.
|
int |
hashCode() |
static void |
setLocale(java.util.Locale locale)
Sets a locale to use for localization.
|
private static final long serialVersionUID
private static final java.util.Map<java.lang.String,java.util.ResourceBundle> BUNDLE_CACHE
private static final SeverityLevel DEFAULT_SEVERITY
private static java.util.Locale sLocale
private final int lineNo
private final int columnNo
private final SeverityLevel severityLevel
private final java.lang.String moduleId
private final java.lang.String key
private final java.lang.Object[] args
private final java.lang.String bundle
private final java.lang.Class<?> sourceClass
private final java.lang.String customMessage
public LocalizedMessage(int lineNo, int columnNo, java.lang.String bundle, java.lang.String key, java.lang.Object[] args, SeverityLevel severityLevel, java.lang.String moduleId, java.lang.Class<?> sourceClass, java.lang.String customMessage)
LocalizedMessage
instance.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 defaultpublic LocalizedMessage(int lineNo, int columnNo, java.lang.String bundle, java.lang.String key, java.lang.Object[] args, java.lang.String moduleId, java.lang.Class<?> sourceClass, java.lang.String customMessage)
LocalizedMessage
instance.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 defaultpublic LocalizedMessage(int lineNo, java.lang.String bundle, java.lang.String key, java.lang.Object[] args, SeverityLevel severityLevel, java.lang.String moduleId, java.lang.Class<?> sourceClass, java.lang.String customMessage)
LocalizedMessage
instance.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 defaultpublic LocalizedMessage(int lineNo, java.lang.String bundle, java.lang.String key, java.lang.Object[] args, java.lang.String moduleId, java.lang.Class<?> sourceClass, java.lang.String customMessage)
LocalizedMessage
instance. The column number
defaults to 0.lineNo
- line number associated with the messagebundle
- name of a resource bundle that contains error 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 defaultpublic boolean equals(java.lang.Object object)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public static void clearCache()
public java.lang.String getMessage()
private java.lang.String getCustomMessage()
null
if there is no custom messageprivate java.util.ResourceBundle getBundle(java.lang.String bundleName)
bundleName
- the bundle namepublic int getLineNo()
public int getColumnNo()
public SeverityLevel getSeverityLevel()
public java.lang.String getModuleId()
public java.lang.String getKey()
public java.lang.String getSourceName()
public static void setLocale(java.util.Locale locale)
locale
- the locale to use for localizationpublic int compareTo(LocalizedMessage other)
compareTo
in interface java.lang.Comparable<LocalizedMessage>