public Object getObject(String key) { return resourceBundle.getObject(key); } public boolean containsKey(String key) {
public Object getObject(String key) { return resourceBundle.getObject(key); } public boolean containsKey(String key) {
/** * Returns the named resource from this {@code ResourceBundle}. * * @param key * the name of the resource. * @return the resource string array. * @throws MissingResourceException * if the resource is not found. * @throws ClassCastException * if the resource found is not an array of strings. * @see #getObject(String) */ public final String[] getStringArray(String key) { return (String[]) getObject(key); }
/** * Returns the named string resource from this {@code ResourceBundle}. * * @param key * the name of the resource. * @return the resource string. * @throws MissingResourceException * if the resource is not found. * @throws ClassCastException * if the resource found is not a string. * @see #getObject(String) */ public final String getString(String key) { return (String) getObject(key); }
@Override protected Object handleGetObject(String key) { for (ResourceBundle b : bundles) { try { return b.getObject(key); } catch (MissingResourceException mre) { // iterate } } throw new MissingResourceException(null, null, key); }
/** * 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); }
/** * 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; }
/** * 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; }
/** * Convert <code>resourceBundle</code> to usable {@link Properties}. * * @param resourceBundle * ResourceBundle * @return Properties */ public static Properties getResourceBundleAsProperties(ResourceBundle resourceBundle) { Properties properties = new Properties(); for (String key : resourceBundle.keySet()) { properties.put(key, resourceBundle.getObject(key)); } return properties; }
/** * 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); }
if (property != null) { try { return ((ResourceBundle) base).getObject(property .toString()); } catch (MissingResourceException e) {
return parent.getObject(key);
try { if (!it.hasNext()) { return wrap(((ResourceBundle) object).getObject(key));
return NbBundle.getBundle(arr[0]).getObject(arr[1]);
/** * Overridden to invoke the getObject method of the resource bundle. */ @Override protected TemplateModel invokeGenericGet(Map keyMap, Class clazz, String key) throws TemplateModelException { try { return wrap(((ResourceBundle) object).getObject(key)); } catch (MissingResourceException e) { throw new _TemplateModelException(e, "No ", new _DelayedJQuote(key), " key in the ResourceBundle. " + "Note that conforming to the ResourceBundle Java API, this is an error and not just " + "a missing sub-variable (a null)."); } }
/** * Return the text corresponding to a i18n key in the properties. * @param key a i18n key in the properties * @return text corresponding to the key */ public static String valueByKey(String key) { return (String) I18n.localeDefault.getObject(key); }
@Override protected Object handleGetObject(String key) { if (contextBundle != null) { return contextBundle.getObject(key); } return null; }
@Override protected Object handleGetObject(String key) { if (key == null) { throw new NullPointerException(); } for (ResourceBundle resourceBundle : _resourceBundles) { if (!resourceBundle.containsKey(key)) { continue; } try { return resourceBundle.getObject(key); } catch (MissingResourceException mre) { } } return null; }