FileDocCategorySizeDatePackage
Msg.javaAPI DocAndroid 1.5 API5123Wed May 06 22:41:04 BST 2009org.apache.harmony.luni.util

Msg

public class Msg extends Object
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.harmony.luni.util.ExternalMessages 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.

Fields Summary
private static final String
sResource
Constructors Summary
Methods Summary
public static java.lang.StringgetString(java.lang.String msg)
Retrieves a message which has no arguments.

param
msg String the key to look up.
return
String the message for that key in the system message bundle.

    // END android-changed

                                                
         
        // BEGIN android-changed
        ResourceBundle bundle = MsgHelp.loadBundle(sResource);
        if (bundle == null) {
            return msg;
        }
        // END android-changed
        try {
            return bundle.getString(msg);
        } catch (MissingResourceException e) {
            return msg;
        }
    
public static java.lang.StringgetString(java.lang.String msg, java.lang.Object arg)
Retrieves a message which takes 1 argument.

param
msg String the key to look up.
param
arg Object the object to insert in the formatted output.
return
String the message for that key in the system message bundle.

        return getString(msg, new Object[] { arg });
    
public static java.lang.StringgetString(java.lang.String msg, int arg)
Retrieves a message which takes 1 integer argument.

param
msg String the key to look up.
param
arg int the integer to insert in the formatted output.
return
String the message for that key in the system message bundle.

        return getString(msg, new Object[] { Integer.toString(arg) });
    
public static java.lang.StringgetString(java.lang.String msg, char arg)
Retrieves a message which takes 1 character argument.

param
msg String the key to look up.
param
arg char the character to insert in the formatted output.
return
String the message for that key in the system message bundle.

        return getString(msg, new Object[] { String.valueOf(arg) });
    
public static java.lang.StringgetString(java.lang.String msg, java.lang.Object arg1, java.lang.Object arg2)
Retrieves a message which takes 2 arguments.

param
msg String the key to look up.
param
arg1 Object an object to insert in the formatted output.
param
arg2 Object another object to insert in the formatted output.
return
String the message for that key in the system message bundle.

        return getString(msg, new Object[] { arg1, arg2 });
    
public static java.lang.StringgetString(java.lang.String msg, java.lang.Object[] args)
Retrieves a message which takes several arguments.

param
msg String the key to look up.
param
args Object[] the objects to insert in the formatted output.
return
String the message for that key in the system message bundle.

        String format = msg;
        // BEGIN android-added
        ResourceBundle bundle = MsgHelp.loadBundle(sResource);
        // END android-added
        if (bundle != null) {
            try {
                format = bundle.getString(msg);
            } catch (MissingResourceException e) {
            }
        }

        return MsgHelp.format(format, args);