List of usage examples for java.util ResourceBundle keySet
Set keySet
To view the source code for java.util ResourceBundle keySet.
Click Source Link
From source file:Main.java
public static void main(String[] args) { ResourceBundle bundle = ResourceBundle.getBundle("hello", Locale.US); System.out.println(bundle.getString("hello")); System.out.println(bundle.keySet()); }
From source file:RBPropDemo.java
public static void main(String[] args) { ResourceBundle.clearCache();/*from ww w .j a v a 2 s . c o m*/ String bundleName = "myproj.MyResources"; ResourceBundle myResources = ResourceBundle.getBundle(bundleName, Locale.GERMAN); System.out.println("Key's values:"); System.out.println(myResources.getString("okKey")); System.out.println(myResources.getString("cancelKey")); System.out.println(myResources.getString("submitKey")); System.out.println("\nChecking okKey in resource bundle:"); if (myResources.containsKey("okKey")) { System.out.println("okKey exists! " + " Value = " + myResources.getString("okKey")); } else { System.out.println("The key Doesn't Exist"); } System.out.println("\nGet a set of keys:"); Set<String> keySet = myResources.keySet(); Object[] keys = keySet.toArray(); for (int i = 0; i < keys.length; i++) { System.out.println("Key " + (i + 1) + " = " + keys[i]); } }
From source file:fr.mael.microrss.util.Tools.java
/** * Convert ResourceBundle into a Map object. * * @param resource a resource bundle to convert. * @return Map a map version of the resource bundle. * @throws UnsupportedEncodingException *//*from w w w . jav a2 s. c o m*/ public static Map<String, String> convertResourceBundleToMap(ResourceBundle resource) throws UnsupportedEncodingException { Map<String, String> map = new HashMap<String, String>(); for (String key : resource.keySet()) { map.put(key, resource.getString(key)); } return map; }
From source file:com.hypersocket.i18n.I18N.java
public static Set<String> getResourceKeys(Locale locale, String resourceBundle) { if (resourceBundle == null) { throw new IllegalArgumentException("You must specify a resource bundle"); }/*from w w w .ja v a 2 s. co m*/ String bundle = resourceBundle; if (!bundle.startsWith("i18n/")) { bundle = "i18n/" + resourceBundle; } Set<String> keys = new HashSet<String>(); try { ResourceBundle rb = ResourceBundle.getBundle(bundle, locale, I18N.class.getClassLoader()); keys.addAll(rb.keySet()); } catch (MissingResourceException e) { } if (hasOverideBundle(locale, resourceBundle)) { try { ResourceBundle rb = new OverrideResourceBundle(locale, resourceBundle); keys.addAll(rb.keySet()); } catch (IOException e1) { log.error("Failed to load override file for bundle " + resourceBundle); } } return keys; }
From source file:net.sourceforge.pmd.util.database.DBType.java
/** * Convert <code>resourceBundle</code> to usable {@link Properties}. * * @param resourceBundle/*from w w w.jav a 2 s .c om*/ * 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; }
From source file:adalid.commons.properties.PropertiesHandler.java
public static Properties loadProperties(ResourceBundle bundle, boolean sortedKeys) { Properties properties = newProperties(sortedKeys); if (bundle == null) { logger.error("null properties bundle"); } else {/* w ww. j a v a2s . c o m*/ logger.trace("loading bundle " + bundle); Set<String> keySet = bundle.keySet(); String value; for (String key : keySet) { try { value = bundle.getString(key); if (StringUtils.isBlank(value)) { continue; } properties.setProperty(key, value.trim()); } catch (MissingResourceException e) { } } printProperties(properties); } return properties; }
From source file:com.ejisto.modules.vertx.handler.Translations.java
private Map<String, String> dumpMessages(ResourceBundle bundle) { return bundle.keySet().stream().map(k -> Pair.of(k, bundle.getString(k))).collect(HashMap::new, (m, p) -> m.put(p.getKey(), p.getValue()), Map::putAll); }
From source file:de.micromata.genome.util.i18n.ChainedResourceBundleTranslationResolver.java
@Override public I18NTranslationProvider getTranslationFor(Locale locale) { Map<String, Object> entries = new HashMap<>(); for (String resId : resIds) { ResourceBundle resbundle = ResourceBundle.getBundle(resId, locale); for (String key : resbundle.keySet()) { entries.putIfAbsent(key, resbundle.getObject(key)); }//from w w w. j a va 2 s . c o m } return new MapTranslationProvider(StringUtils.join(resIds, "_"), entries); }
From source file:cn.edu.zjnu.acm.judge.config.JudgeConfiguration.java
@PostConstruct public void init() { {/*from w w w. j a v a 2 s . co m*/ ResourceBundle bundle = ResourceBundle.getBundle(WEB_PROPERTIES, Locale.US); bundle.keySet().forEach(key -> servletContext.setAttribute(key, bundle.getObject(key))); } contextPath = fixContextPath(servletContext.getContextPath()); dataFilesPath = Paths.get(getValue("DataFilesPath")); workingPath = Paths.get(getValue("WorkingPath")); uploadDirectory = Paths.get(getValue("UploadPath")); deleteTempFile = Boolean.parseBoolean(getValue("DeleteTempFile")); }
From source file:org.pentaho.common.ui.services.LocalizationService.java
private String getJsonForBundle(ResourceBundle bundle) throws JSONException { JSONObject cat = new JSONObject(); for (String key : bundle.keySet()) { cat.put(key, bundle.getString(key)); }/*from ww w. j a va 2s. c o m*/ return cat.toString(); }