Search in sources :

Example 46 with ResourceBundle

use of java.util.ResourceBundle in project OpenAM by OpenRock.

the class SMSException method getString.

private String getString(String msgID) {
    errorCode = msgID;
    ResourceBundle bundle = null;
    if (bundleName != null) {
        bundle = amCache.getResBundle(bundleName, java.util.Locale.ENGLISH);
    }
    return (Locale.getString(bundle, msgID, debug));
}
Also used : ResourceBundle(java.util.ResourceBundle)

Example 47 with ResourceBundle

use of java.util.ResourceBundle in project OpenAM by OpenRock.

the class ValidateResourceResult method getLocalizedMessage.

/**
     * Returns localized message.
     *
     * @param locale Locale.
     * @return localized message.
     */
public String getLocalizedMessage(Locale locale) {
    ResourceBundle rb = ResourceBundle.getBundle("EntitlementException", locale);
    String str = rb.getString(message);
    return ((args != null) && (args.length > 0)) ? MessageFormat.format(str, args) : str;
}
Also used : ResourceBundle(java.util.ResourceBundle)

Example 48 with ResourceBundle

use of java.util.ResourceBundle in project OpenAM by OpenRock.

the class ResourceNameSplitTest method parseResource.

private Map<String, Set<String>> parseResource(String rbName) {
    Map<String, Set<String>> results = new HashMap<String, Set<String>>();
    ResourceBundle rb = ResourceBundle.getBundle(rbName);
    for (Enumeration e = rb.getKeys(); e.hasMoreElements(); ) {
        String k = (String) e.nextElement();
        String val = rb.getString(k);
        Set<String> set = new HashSet<String>();
        for (StringTokenizer st = new StringTokenizer(val, ","); st.hasMoreElements(); ) {
            set.add(st.nextToken().trim());
        }
        results.put(k, set);
    }
    return results;
}
Also used : StringTokenizer(java.util.StringTokenizer) HashSet(java.util.HashSet) Set(java.util.Set) Enumeration(java.util.Enumeration) HashMap(java.util.HashMap) ResourceBundle(java.util.ResourceBundle) HashSet(java.util.HashSet)

Example 49 with ResourceBundle

use of java.util.ResourceBundle in project OpenAM by OpenRock.

the class ResourceNameIndexTest method parseResource.

private Map<String, String> parseResource(String rbName) {
    Map<String, String> results = new HashMap<String, String>();
    ResourceBundle rb = ResourceBundle.getBundle(rbName);
    for (Enumeration e = rb.getKeys(); e.hasMoreElements(); ) {
        String k = (String) e.nextElement();
        String val = rb.getString(k).trim();
        results.put(k, val);
    }
    return results;
}
Also used : Enumeration(java.util.Enumeration) HashMap(java.util.HashMap) ResourceBundle(java.util.ResourceBundle)

Example 50 with ResourceBundle

use of java.util.ResourceBundle in project OpenAM by OpenRock.

the class RestException method getLocalizedMessage.

/**
     * Returns localized exception message.
     *
     * @param locale Locale of the message.
     * @return localized exception message.
     */
public String getLocalizedMessage(Locale locale) {
    ResourceBundle rb = ResourceBundle.getBundle(RES_BUNDLE_NAME, locale);
    String msg = rb.getString(Integer.toString(errorCode));
    return (params != null) ? MessageFormat.format(msg, params) : msg;
}
Also used : ResourceBundle(java.util.ResourceBundle)

Aggregations

ResourceBundle (java.util.ResourceBundle)1189 Locale (java.util.Locale)180 MissingResourceException (java.util.MissingResourceException)150 Test (org.junit.Test)100 ArrayList (java.util.ArrayList)71 HashMap (java.util.HashMap)70 IOException (java.io.IOException)67 PropertyResourceBundle (java.util.PropertyResourceBundle)56 URL (java.net.URL)48 File (java.io.File)47 Map (java.util.Map)45 InputStream (java.io.InputStream)43 Enumeration (java.util.Enumeration)34 HashSet (java.util.HashSet)30 Test (org.junit.jupiter.api.Test)30 ActionMessage (org.apache.struts.action.ActionMessage)29 MessageFormat (java.text.MessageFormat)28 ListResourceBundle (java.util.ListResourceBundle)28 Set (java.util.Set)26 Preferences (java.util.prefs.Preferences)21