public class MessageBundle extends Object
Modifier and Type | Method and Description |
---|---|
String |
getDefaultMessage()
Return the default message to use when the key does not exist.
|
String |
getMessage(String key)
Return a message without variables.
|
String |
getMessage(String key,
Object... vars)
Return a message with variables.
|
String |
getNamedMessage(String key,
Object... vars)
Return a message with named variables.
|
protected void |
initialize(URL url)
Initialize the bundle with a specified URL.
|
void |
setDefaultMessage(String message)
Set the default message to use when the key does not exist.
|
public void setDefaultMessage(String message)
message
- the default messagepublic String getDefaultMessage()
protected void initialize(URL url)
url
- the URL used for the bundle creationpublic String getMessage(String key)
getMessage("grammar")
returns "Wrong File grammar"key
- the message keypublic String getMessage(String key, Object... vars)
getMessage("type.undef", "myValue")
returns "No type of name myValue"getMessage("type.undef", "myValue", 3)
returns "No type of name myValue or 3"getMessage("type.undef", "myValue", 3)
returns "No type of name myValue"getMessage("type.undef", "myValue")
returns "No type of name myValue or"key
- the message keyvars
- the varargs variables array. The String representation of each variable will be usedpublic String getNamedMessage(String key, Object... vars)
getMessage("type.undef", "name", "myValue")
returns "No type of name myValue"getMessage("type.undef", "name1", "myValue", "name2", 3)
returns "No type of name myValue or 3"getMessage("type.undef", "name" "myValue", "other", 3)
returns "No type of name myValue"key
- the message keyvars
- the varargs variables array. The String representation of each variable will be used