Java Resource Message getMessage(ResourceBundle bundle, Object key, Object[] params)

Here you can find the source of getMessage(ResourceBundle bundle, Object key, Object[] params)

Description

get Message

License

Apache License

Declaration

public static String getMessage(ResourceBundle bundle, Object key, Object[] params) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.text.MessageFormat;

import java.util.ResourceBundle;

public class Main {

    public static String getMessage(ResourceBundle bundle, Object key, Object[] params) {
        String pattern = bundle.getString(key.toString());

        if ((params == null) || (params.length == 0)) {
            return pattern;
        }//ww  w.  jav a2s .c  o m

        return MessageFormat.format(pattern, params);
    }

    public static String getMessage(ResourceBundle bundle, Object key, Object param1) {
        return getMessage(bundle, key, new Object[] { param1 });
    }

    public static String getMessage(ResourceBundle bundle, Object key, Object param1, Object param2) {
        return getMessage(bundle, key, new Object[] { param1, param2 });
    }

    public static String getMessage(ResourceBundle bundle, Object key, Object param1, Object param2,
            Object param3) {
        return getMessage(bundle, key, new Object[] { param1, param2, param3 });
    }

    public static String getMessage(ResourceBundle bundle, Object key, Object param1, Object param2, Object param3,
            Object param4) {
        return getMessage(bundle, key, new Object[] { param1, param2, param3, param4 });
    }

    public static String getMessage(ResourceBundle bundle, Object key, Object param1, Object param2, Object param3,
            Object param4, Object param5) {
        return getMessage(bundle, key, new Object[] { param1, param2, param3, param4, param5 });
    }
}

Related

  1. getMessage(final String bundleName, final Locale locale, final String key, final Object... params)
  2. getMessage(Locale locale, String key, Object... args)
  3. getMessage(Locale locale, String key, String... args)
  4. getMessage(Properties prop, String key, Object... args)
  5. getMessage(Properties props, String key, Object param)
  6. getMessage(ResourceBundle bundle, String key, Object... params)
  7. getMessage(ResourceBundle bundle, String key, Object... params)
  8. getMessage(ResourceBundle messages, String messageKey)
  9. getMessage(ResourceBundle messages, String msgKey, Object[] arguments)