com.perforce.p4java.messages
Class PerforceMessages

java.lang.Object
  extended by com.perforce.p4java.messages.PerforceMessages

public class PerforceMessages
extends Object

Handles formatting Perforce messages. It provides locale (language & 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
static String MESSAGE_BUNDLE
          Default name of the Perforce message bundle properties file.
 
Constructor Summary
PerforceMessages()
          Instantiates a new perforce messages using the default message bundle properties file package path name .
PerforceMessages(Locale locale)
          Instantiates a new perforce messages.
PerforceMessages(String propertiesFile)
          Instantiates a new perforce messages base on the passed-in message bundle properties file package path name.
 
Method Summary
 String format(String message, Object[] params)
          Format a message with parameters.
 Locale getLocale()
          Gets the locale.
 String getMessage(String key)
          Gets the message.
 String getMessage(String key, Object[] params)
          Gets the message.
 ResourceBundle getMessages()
          Gets the messages.
 void setLocale(Locale locale)
          Sets the locale.
 void setMessages(ResourceBundle messages)
          Sets the messages.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MESSAGE_BUNDLE

public static final String MESSAGE_BUNDLE
Default name of the Perforce message bundle properties file.

Constructor Detail

PerforceMessages

public PerforceMessages()
Instantiates a new perforce messages using the default message bundle properties file package path name .


PerforceMessages

public PerforceMessages(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(Locale locale)
Instantiates a new perforce messages.

Parameters:
locale - the locale
Method Detail

getLocale

public Locale getLocale()
Gets the locale.

Returns:
the locale

setLocale

public void setLocale(Locale locale)
Sets the locale.

Parameters:
locale - the new locale

getMessages

public ResourceBundle getMessages()
Gets the messages.

Returns:
the messages

setMessages

public void setMessages(ResourceBundle messages)
Sets the messages.

Parameters:
messages - the new messages

getMessage

public String getMessage(String key)
Gets the message.

Parameters:
key - the key
Returns:
the message

getMessage

public String getMessage(String key,
                         Object[] params)
Gets the message.

Parameters:
key - the key
params - the params
Returns:
the message

format

public String format(String message,
                     Object[] params)
Format a message with parameters.

Parameters:
message - the message
params - the params
Returns:
the string
See Also:
MessageFormat


Copyright © 2015 Perforce Software. All Rights Reserved.