Top Description Fields Constructors Methods
org.apache.commons.compress.harmony.archive.internal.nls

public Class Messages

extends Object
Class Inheritance
Imports
java.security.AccessController, .PrivilegedAction, java.util.Arrays, .Locale, .MissingResourceException, .Objects, .ResourceBundle

This class retrieves strings from a resource bundle and returns them, formatting them with MessageFormat when required.

It is used by the system classes to provide national language support, by looking up messages in the org.apache.commons.compress.harmony.archive.internal.nls.messages resource bundle. Note that if this file is not available, or an invalid key is looked up, or resource bundle support is not available, the key itself will be returned as the associated message. This means that the KEY should a reasonable human-readable (english) string.

Field Summary

Modifier and TypeField and Description
private static ResourceBundle

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static String

Returns:

String the formatted message.
format
(final String
String the format to use when printing.
format
,
final Object[]
Object[] the arguments to use.
args
)

Generates a formatted text string given a source string containing "argument markers" of the form "{argNum}" where each argNum must be in the range 0..9.

public static String

Returns:

String the message for that key in the system message bundle.
getString
(final String
String the key to look up.
msg
)

Retrieves a message which has no arguments.

public static String

Returns:

String the message for that key in the system message bundle.
getString
(final String
String the key to look up.
msg
,
final char
char the character to insert in the formatted output.
arg
)

Retrieves a message which takes 1 character argument.

public static String

Returns:

String the message for that key in the system message bundle.
getString
(final String
String the key to look up.
msg
,
final int
int the integer to insert in the formatted output.
arg
)

Retrieves a message which takes 1 integer argument.

public static String

Returns:

String the message for that key in the system message bundle.
getString
(final String
String the key to look up.
msg
,
final Object
Object the object to insert in the formatted output.
arg
)

Retrieves a message which takes 1 argument.

public static String

Returns:

String the message for that key in the system message bundle.
getString
(final String
String the key to look up.
msg
,
final Object
Object an object to insert in the formatted output.
arg1
,
final Object
Object another object to insert in the formatted output.
arg2
)

Retrieves a message which takes 2 arguments.

public static String

Returns:

String the message for that key in the system message bundle.
getString
(final String
String the key to look up.
msg
,
final Object[]
Object[] the objects to insert in the formatted output.
args
)

Retrieves a message which takes several arguments.

public static ResourceBundle

Returns:

The ResourceBundle.
setLocale
(final Locale
Locale the locale to change to.
locale
,
final String
resource name.
resource
)

Changes the locale of the messages.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bundleback to summary
private static ResourceBundle bundle

Constructor Detail

Messagesback to summary
public Messages()

Method Detail

formatback to summary
public static String format(final String format, final Object[] args)

Generates a formatted text string given a source string containing "argument markers" of the form "{argNum}" where each argNum must be in the range 0..9. The result is generated by inserting the toString of each argument into the position indicated in the string.

To insert the "{" character into the output, use a single backslash character to escape it (i.e. "\{"). The "}" character does not need to be escaped.

Parameters
format:String

String the format to use when printing.

args:Object[]

Object[] the arguments to use.

Returns:String

String the formatted message.

getStringback to summary
public static String getString(final String msg)

Retrieves a message which has no arguments.

Parameters
msg:String

String the key to look up.

Returns:String

String the message for that key in the system message bundle.

getStringback to summary
public static String getString(final String msg, final char arg)

Retrieves a message which takes 1 character argument.

Parameters
msg:String

String the key to look up.

arg:char

char the character to insert in the formatted output.

Returns:String

String the message for that key in the system message bundle.

getStringback to summary
public static String getString(final String msg, final int arg)

Retrieves a message which takes 1 integer argument.

Parameters
msg:String

String the key to look up.

arg:int

int the integer to insert in the formatted output.

Returns:String

String the message for that key in the system message bundle.

getStringback to summary
public static String getString(final String msg, final Object arg)

Retrieves a message which takes 1 argument.

Parameters
msg:String

String the key to look up.

arg:Object

Object the object to insert in the formatted output.

Returns:String

String the message for that key in the system message bundle.

getStringback to summary
public static String getString(final String msg, final Object arg1, final Object arg2)

Retrieves a message which takes 2 arguments.

Parameters
msg:String

String the key to look up.

arg1:Object

Object an object to insert in the formatted output.

arg2:Object

Object another object to insert in the formatted output.

Returns:String

String the message for that key in the system message bundle.

getStringback to summary
public static String getString(final String msg, final Object[] args)

Retrieves a message which takes several arguments.

Parameters
msg:String

String the key to look up.

args:Object[]

Object[] the objects to insert in the formatted output.

Returns:String

String the message for that key in the system message bundle.

setLocaleback to summary
public static ResourceBundle setLocale(final Locale locale, final String resource)

Changes the locale of the messages.

Parameters
locale:Locale

Locale the locale to change to.

resource:String

resource name.

Returns:ResourceBundle

The ResourceBundle.