Refine search
private static boolean containsKey(ResourceBundle bundle, String key) { for (Enumeration<String> en = bundle.getKeys(); en.hasMoreElements(); ) { if (en.nextElement().equals(key)) { return true; } } return false; }
/** * Returns true if this bundle contains no objects. */ @Override public boolean isEmpty() { return !((ResourceBundle) object).getKeys().hasMoreElements() && super.isEmpty(); }
private static boolean containsKey(ResourceBundle bundle, String key) { for (Enumeration<String> en = bundle.getKeys(); en.hasMoreElements(); ) { if (en.nextElement().equals(key)) { return true; } } return false; }
private static boolean containsKey(ResourceBundle bundle, String key) { for (Enumeration<String> en = bundle.getKeys(); en.hasMoreElements(); ) { if (en.nextElement().equals(key)) { return true; } } return false; }
/** * Register bean definitions contained in a ResourceBundle. * <p>Similar syntax as for a Map. This method is useful to enable * standard Java internationalization support. * @param rb the ResourceBundle to load from * @param prefix a filter within the keys in the map: e.g. 'beans.' * (can be empty or {@code null}) * @return the number of bean definitions found * @throws BeanDefinitionStoreException in case of loading or parsing errors */ public int registerBeanDefinitions(ResourceBundle rb, @Nullable String prefix) throws BeanDefinitionStoreException { // Simply create a map and call overloaded method. Map<String, Object> map = new HashMap<>(); Enumeration<String> keys = rb.getKeys(); while (keys.hasMoreElements()) { String key = keys.nextElement(); map.put(key, rb.getObject(key)); } return registerBeanDefinitions(map, prefix); }
protected void initPlugin(String pluginKey) { try { String bundleKey = BUNDLE_PACKAGE + pluginKey; ResourceBundle bundle = ResourceBundle.getBundle(bundleKey, Locale.ENGLISH, this.classloader, control); Enumeration<String> keys = bundle.getKeys(); while (keys.hasMoreElements()) { String key = keys.nextElement(); propertyToBundles.put(key, bundleKey); } } catch (MissingResourceException e) { // ignore } }
public Set<String> keySet() { Set<String> ret = new HashSet<String>(); Enumeration<String> keys = getKeys(); while (keys.hasMoreElements()) { ret.add(keys.nextElement()); } return ret; }
/** * Creates a new HashMap using data copied from a ResourceBundle. * * @param resourceBundle the resource bundle to convert, may not be null * @return the hashmap containing the data * @throws NullPointerException if the bundle is null */ public static Map toMap(final ResourceBundle resourceBundle) { Enumeration enumeration = resourceBundle.getKeys(); Map map = new HashMap(); while (enumeration.hasMoreElements()) { String key = (String) enumeration.nextElement(); Object value = resourceBundle.getObject(key); map.put(key, value); } return map; }
private static Set<String> keys(ResourceBundle rb) { if (rb == null) { return Collections.emptySet(); } Set<String> keys = new LinkedHashSet<String>(); for (Enumeration<String> k = rb.getKeys(); k.hasMoreElements(); keys.add(k.nextElement())); return keys; }
private void printResourceBundle(ResourceBundle resourceBundle, PrintWriter pw, String indent) { if (resourceBundle == null) { return; } pw.printf("%sResourceBundle:%n", indent); indent += " "; for (Enumeration<String> keys = resourceBundle.getKeys(); keys.hasMoreElements();) { String key = keys.nextElement(); pw.printf("%s%s: '%s'%n", indent, key, resourceBundle.getString(key)); } }
/** * Creates a new HashMap using data copied from a ResourceBundle. * * @param resourceBundle the resource bundle to convert, may not be null * @return the hashmap containing the data * @throws NullPointerException if the bundle is null */ public static Map toMap(final ResourceBundle resourceBundle) { Enumeration enumeration = resourceBundle.getKeys(); Map map = new HashMap(); while (enumeration.hasMoreElements()) { String key = (String) enumeration.nextElement(); Object value = resourceBundle.getObject(key); map.put(key, value); } return map; }
@Override protected Set keySet() { Set set = super.keySet(); Enumeration e = ((ResourceBundle) object).getKeys(); while (e.hasMoreElements()) { set.add(e.nextElement()); } return set; }
/** * Creates a new HashMap using data copied from a ResourceBundle. * * @param resourceBundle the resource bundle to convert, may not be null * @return the hashmap containing the data * @throws NullPointerException if the bundle is null */ public static Map<String, Object> toMap(final ResourceBundle resourceBundle) { final Enumeration<String> enumeration = resourceBundle.getKeys(); final Map<String, Object> map = new HashMap<>(); while (enumeration.hasMoreElements()) { final String key = enumeration.nextElement(); final Object value = resourceBundle.getObject(key); map.put(key, value); } return map; }
/** * Register bean definitions contained in a ResourceBundle. * <p>Similar syntax as for a Map. This method is useful to enable * standard Java internationalization support. * @param rb the ResourceBundle to load from * @param prefix a filter within the keys in the map: e.g. 'beans.' * (can be empty or {@code null}) * @return the number of bean definitions found * @throws BeanDefinitionStoreException in case of loading or parsing errors */ public int registerBeanDefinitions(ResourceBundle rb, @Nullable String prefix) throws BeanDefinitionStoreException { // Simply create a map and call overloaded method. Map<String, Object> map = new HashMap<>(); Enumeration<String> keys = rb.getKeys(); while (keys.hasMoreElements()) { String key = keys.nextElement(); map.put(key, rb.getObject(key)); } return registerBeanDefinitions(map, prefix); }
<%@page contentType="text/javascript; charset=UTF-8" %> <%@ page import="java.util.ResourceBundle" %> <%@ page import="java.util.Locale" %> <%@ page import="java.util.Enumeration" %> <%@ page import="org.apache.commons.lang.StringEscapeUtils" %> angular.module('translations', []) .factory('translations', function(){ return { <% ResourceBundle labels = ResourceBundle.getBundle("language", request.getLocale()); Enumeration<String> keys = labels.getKeys(); while(keys.hasMoreElements()){ String key = keys.nextElement(); out.write("\""+key+"\":\""+StringEscapeUtils.escapeJavaScript(labels.getString(key))+"\""); if(keys.hasMoreElements()){ out.write(",\n"); } } %> }}) .filter('mpbtranslate', ['translations', function(translations) { return function(input) { var translation = translations[input]; return translation? translation: '???'+input+'???'; }; }]);
/** * ResourceBundle转化为JSONObject * * @param bundle ResourceBundle文件 * @return JSONObject */ public static JSONObject parseFromResourceBundle(ResourceBundle bundle) { JSONObject jsonObject = new JSONObject(); Enumeration<String> keys = bundle.getKeys(); while (keys.hasMoreElements()) { String key = keys.nextElement(); if (key != null) { InternalJSONUtil.propertyPut(jsonObject, key, bundle.getString(key)); } } return jsonObject; } // -------------------------------------------------------------------- Pause end
Enumeration<String> keys = bundle.getKeys(); while (keys.hasMoreElements()) { Object key = keys.nextElement(); if (key != null) {
/** * ResourceBundle转化为JSONObject * * @param bundle ResourceBundle文件 * @return JSONObject */ public static JSONObject parseFromResourceBundle(ResourceBundle bundle) { JSONObject jsonObject = new JSONObject(); Enumeration<String> keys = bundle.getKeys(); while (keys.hasMoreElements()) { String key = keys.nextElement(); if (key != null) { InternalJSONUtil.propertyPut(jsonObject, key, bundle.getString(key)); } } return jsonObject; } // -------------------------------------------------------------------- Pause end
Enumeration<String> keys = bundle.getKeys(); while (keys.hasMoreElements()) { Object key = keys.nextElement(); if (key != null) {
Enumeration<String> keys = bundle.getKeys(); while (keys.hasMoreElements()) { Object key = keys.nextElement(); if (key != null) {