List of usage examples for java.util ResourceBundle getKeys
public abstract Enumeration<String> getKeys();
From source file:mx.com.pixup.portal.db.DBConecta.java
/** * Lee los parmetros de conexion del archivo JDBC.properties y los guarda en en dbProp *//*from w w w . j ava 2s .c o m*/ public DBConecta() { try { ResourceBundle rsb = ResourceBundle.getBundle("setup"); Enumeration enum1 = rsb.getKeys(); Properties dbProp = new Properties(); while (enum1.hasMoreElements()) { String sTmp = (String) enum1.nextElement(); dbProp.setProperty(sTmp, rsb.getString(sTmp)); //System.out.println("+" + sTmp ); } this.dbProp = dbProp; System.out.println(dbProp); } catch (Exception e) { System.out.println("+" + e.getMessage()); } }
From source file:org.hx.rainbow.common.util.PropertiesUtil.java
/** * ?.properties?Map/*from ww w .ja v a 2 s . c o m*/ * @param propertiesFile * @return */ public Map<String, Object> read(String propertiesFile) { @SuppressWarnings("unchecked") Map<String, Object> maps = (Map<String, Object>) map.get(propertiesFile); if (maps == null) { maps = new HashMap<String, Object>(); ResourceBundle rb = ResourceBundle.getBundle(propertiesFile); Enumeration<String> enu = rb.getKeys(); while (enu.hasMoreElements()) { String obj = enu.nextElement(); Object objv = rb.getObject(obj); maps.put(obj, objv); } map.put(propertiesFile, maps); } return maps; }
From source file:org.paxml.bean.BundleTag.java
private Properties toProperties(ResourceBundle bundle) { Properties props = new Properties(); Enumeration<String> en = bundle.getKeys(); while (en.hasMoreElements()) { String key = en.nextElement(); props.put(key, bundle.getObject(key)); }//from w w w . ja v a 2s . com return props; }
From source file:org.sonar.core.i18n.GwtI18n.java
void doStart(ResourceBundle englishBundle) { List<String> keys = Lists.newArrayList(); Enumeration<String> enumeration = englishBundle.getKeys(); while (enumeration.hasMoreElements()) { String propertyKey = enumeration.nextElement(); keys.add(propertyKey);// ww w . ja v a2s. c om } propertyKeys = keys.toArray(new String[keys.size()]); }
From source file:com.sfs.beans.SQLBean.java
/** * Instantiates a new sQL bean.//from w w w. j a va 2 s . c o m * * @param sqlPropertiesName the sql properties name */ public SQLBean(final String sqlPropertiesName) { /** * Loads SQL commands into memory from properties file **/ if (sqlPropertiesName != null) { ResourceBundle sqlBundle = ResourceBundle.getBundle(sqlPropertiesName); Enumeration<String> keySet = sqlBundle.getKeys(); while (keySet.hasMoreElements()) { String sqlKey = keySet.nextElement(); String sqlValue = sqlBundle.getString(sqlKey); sqlKey = StringUtils.replace(sqlKey, ".", "/"); if (sqlValue == null) { sqlValue = ""; } this.setValue(sqlKey, sqlValue); } } }
From source file:org.skyinn.quasar.struts.action.BaseAction.java
/** * @see org.apache.struts.actions.LookupDispatchAction#getKeyMethodMap() *///from www.jav a2s . c o m protected Map getKeyMethodMap() { Map map = new HashMap(); String pkg = this.getClass().getPackage().getName(); ResourceBundle methods = ResourceBundle.getBundle(pkg + ".LookupMethods"); Enumeration keys = methods.getKeys(); while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); map.put(key, methods.getString(key)); } return map; }
From source file:com.svds.geolocationservice.services.KafkaProducerService.java
/** * Create a producer connection to Kafka *///w w w.java 2 s. c om public KafkaProducerService() { LOG.info("KafkaProducerService - start"); long starttime = System.currentTimeMillis(); try { Properties kafkaProducerProps = new Properties(); ResourceBundle kafkaProducerBundle = ResourceBundle.getBundle(KafkaProducerService.KAFKA_CONFIG); Enumeration<String> keys = kafkaProducerBundle.getKeys(); while (keys.hasMoreElements()) { String key = keys.nextElement(); kafkaProducerProps.put(key, kafkaProducerBundle.getString(key)); } kafkaProducerConfig = new ProducerConfig(kafkaProducerProps); setKafkaProducer(new Producer<String, String>(kafkaProducerConfig)); } catch (Exception e) { LOG.error(e.getMessage(), e); } long endtime = System.currentTimeMillis() - starttime; LOG.info("KafkaProducerService : " + endtime); }
From source file:org.opencms.gwt.A_CmsClientMessageBundle.java
/** * @see org.opencms.gwt.I_CmsClientMessageBundle#export(java.util.Locale) *//*from w ww.j av a2 s . co m*/ public String export(Locale locale) { JSONObject keys = new JSONObject(); try { ResourceBundle resourceBundle = CmsResourceBundleLoader.getBundle(getBundleName(), locale); Enumeration<String> bundleKeys = resourceBundle.getKeys(); while (bundleKeys.hasMoreElements()) { String bundleKey = bundleKeys.nextElement(); keys.put(bundleKey, resourceBundle.getString(bundleKey)); } } catch (Throwable e) { LOG.error(e.getLocalizedMessage(), e); try { keys.put("error", e.getLocalizedMessage()); } catch (JSONException e1) { // ignore, should never happen LOG.error(e1.getLocalizedMessage(), e1); } } return getBundleName().replace('.', '_') + "=" + keys.toString() + ";"; }
From source file:org.apache.rave.portal.web.controller.MessageBundleController.java
private Map<String, String> convertResourceBundleToClientMessagesMap(ResourceBundle resourceBundle) { Map<String, String> map = new HashMap<String, String>(); Enumeration<String> keys = resourceBundle.getKeys(); while (keys.hasMoreElements()) { String key = keys.nextElement(); // only load the messages that are specifically used by the client code for performance reasons // strip off the _rave_client. part of the key if (key.startsWith(CLIENT_MESSAGE_IDENTIFIER)) { map.put(key.replaceFirst(CLIENT_MESSAGE_IDENTIFIER, ""), StringEscapeUtils.escapeEcmaScript(resourceBundle.getString(key))); }/*from w w w . j a v a2 s. co m*/ } return map; }
From source file:uk.co.grahamcox.yui.LanguageModuleBuilder.java
/** * Get the module file requested/*from ww w . jav a 2 s .c o m*/ * @param group the group of the module * @param file the file of the module * @return the contents of the module * @throws java.io.IOException if an error occurs loading module content */ public String getModuleFile(String group, String file, String language) throws IOException { if (groups.containsKey(group)) { ModuleGroup moduleGroup = groups.get(group); Module module = moduleGroup.findModule(file); if (module != null) { StringBuilder moduleOutput = new StringBuilder(); moduleOutput.append("YUI.add('lang/").append(module.getName()); if (language != null && !language.isEmpty()) { moduleOutput.append("_").append(language); } moduleOutput.append("', function (Y) {\n"); moduleOutput.append("Y.Intl.add(\n"); moduleOutput.append("'").append(module.getName()).append("',\n"); moduleOutput.append("'").append(language).append("',\n"); moduleOutput.append("{\n"); String resourceKey = module.getMessagesFile().toString(); Locale locale; if (language == null || language.isEmpty()) { locale = Locale.getDefault(); } else { locale = Locale.forLanguageTag(language); } ResourceBundle resourceBundle = ResourceBundle.getBundle(resourceKey, locale, new LanguageControl()); Enumeration<String> keys = resourceBundle.getKeys(); boolean isFirst = true; while (keys.hasMoreElements()) { String key = keys.nextElement(); String value = resourceBundle.getString(key); if (!isFirst) { moduleOutput.append(","); } isFirst = false; moduleOutput.append("'").append(key).append("': '").append(value).append("'"); } moduleOutput.append("});\n"); moduleOutput.append("}, '").append(module.getVersion()).append("');"); return moduleOutput.toString(); } else { throw new UnknownModuleException(group, file); } } else { throw new UnknownGroupException(group); } }