Here you can find the source of mergeResourceBundle(final Map map, final String path)
Parameter | Description |
---|---|
map | the map into which the resources should be merged |
path | the path to the resource bundle |
static public void mergeResourceBundle(final Map map, final String path) throws MissingResourceException
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { /**/*from ww w . j a va 2s . co m*/ * Merge the resource bundle at the path into the specified map. * @param map the map into which the resources should be merged * @param path the path to the resource bundle */ static public void mergeResourceBundle(final Map map, final String path) throws MissingResourceException { final ResourceBundle bundle = ResourceBundle.getBundle(path); final Enumeration<String> keyEnum = bundle.getKeys(); while (keyEnum.hasMoreElements()) { final String key = keyEnum.nextElement(); final String assignment = bundle.getString(key); // if the key begins with "+" then prepend the new assignment onto the existing assignment if (key.startsWith("+")) { final String baseKey = key.substring(1); final String initialAssignment = (String) map.get(baseKey); if (initialAssignment != null) { map.put(baseKey, assignment + " - " + initialAssignment); } else { map.put(baseKey, assignment); } } // if the key ends with "+" then append the new assignment onto the existing assignment else if (key.endsWith("+")) { final String baseKey = key.substring(0, key.length() - 1); final String initialAssignment = (String) map.get(baseKey); if (initialAssignment != null) { map.put(baseKey, initialAssignment + " - " + assignment); } else { map.put(baseKey, assignment); } } // if no modifier is found, then simply overwrite the assignment if existing or add a new one else { map.put(key, assignment); } } } }