Package com.perforce.p4java.messages
Class PerforceMessages
- java.lang.Object
-
- com.perforce.p4java.messages.PerforceMessages
-
public class PerforceMessages extends java.lang.Object
Handles formatting Perforce messages. It provides locale (language and country) specific messages. The default locale is set during startup of the JVM based on the host environment.Additionally, this class provides a convenient way to format messages with parameters.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
MESSAGE_BUNDLE
Default name of the Perforce message bundle properties file.
-
Constructor Summary
Constructors Constructor Description PerforceMessages()
Instantiates a new perforce messages using the default message bundle properties file package path name .PerforceMessages(java.lang.String propertiesFile)
Instantiates a new perforce messages base on the passed-in message bundle properties file package path name.PerforceMessages(java.util.Locale locale)
Instantiates a new perforce messages.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
format(java.lang.String message, java.lang.Object[] params)
Format a message with parameters.java.util.Locale
getLocale()
Gets the locale.java.lang.String
getMessage(java.lang.String key)
Gets the message.java.lang.String
getMessage(java.lang.String key, java.lang.Object[] params)
Gets the message.java.util.ResourceBundle
getMessages()
Gets the messages.void
setLocale(java.util.Locale locale)
Sets the locale.void
setMessages(java.util.ResourceBundle messages)
Sets the messages.
-
-
-
Constructor Detail
-
PerforceMessages
public PerforceMessages()
Instantiates a new perforce messages using the default message bundle properties file package path name .
-
PerforceMessages
public PerforceMessages(java.lang.String propertiesFile)
Instantiates a new perforce messages base on the passed-in message bundle properties file package path name.- Parameters:
propertiesFile
- the name (without the extension) of the properties file including the full package path name (i.e. com.perforce.p4java.messages.PerforceMessages)
-
PerforceMessages
public PerforceMessages(java.util.Locale locale)
Instantiates a new perforce messages.- Parameters:
locale
- the locale
-
-
Method Detail
-
getLocale
public java.util.Locale getLocale()
Gets the locale.- Returns:
- the locale
-
setLocale
public void setLocale(java.util.Locale locale)
Sets the locale.- Parameters:
locale
- the new locale
-
getMessages
public java.util.ResourceBundle getMessages()
Gets the messages.- Returns:
- the messages
-
setMessages
public void setMessages(java.util.ResourceBundle messages)
Sets the messages.- Parameters:
messages
- the new messages
-
getMessage
public java.lang.String getMessage(java.lang.String key)
Gets the message.- Parameters:
key
- the key- Returns:
- the message
-
getMessage
public java.lang.String getMessage(java.lang.String key, java.lang.Object[] params)
Gets the message.- Parameters:
key
- the keyparams
- the params- Returns:
- the message
-
format
public java.lang.String format(java.lang.String message, java.lang.Object[] params)
Format a message with parameters.- Parameters:
message
- the messageparams
- the params- Returns:
- the string
- See Also:
MessageFormat
-
-