List of usage examples for java.util Properties keys
@Override
public Enumeration<Object> keys()
From source file:net.jforum.util.JForumConfig.java
private void loadCustomProperties() throws Exception { InputStream is = this.getClass().getResourceAsStream("/jforumConfig/jforum-custom.properties"); if (is != null) { Properties custom = new Properties(); custom.load(is);/*from w ww. j av a2 s. c om*/ for (Enumeration<?> e = custom.keys(); e.hasMoreElements();) { String key = (String) e.nextElement(); this.clearProperty(key); this.addProperty(key, custom.get(key)); } } }
From source file:org.openflamingo.engine.util.VersionConfigurer.java
/** * ? Key Value ? Key ?? ? ./*from w ww . j a v a 2 s. c om*/ * * @param props {@link java.util.Properties} * @return Key ? ? ?? ? */ private int getMaxLength(Properties props) { Enumeration<Object> keys = props.keys(); int maxLength = -1; while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); if (maxLength < 0) { maxLength = key.getBytes().length; } else if (maxLength < key.getBytes().length) { maxLength = key.getBytes().length; } } return maxLength; }
From source file:org.displaytag.properties.TableProperties.java
/** * Local, non-default properties; these settings override the defaults from displaytag.properties and * TableTag.properties. Please note that the values are copied in, so that multiple calls with non-overlapping * properties will be merged, not overwritten. Note: setUserProperties() MUST BE CALLED before the first * TableProperties instantation./*from www . ja v a 2 s. c o m*/ * @param overrideProperties - The local, non-default properties */ public static void setUserProperties(Properties overrideProperties) { // copy keys here, so that this can be invoked more than once from different sources. // if default properties are not yet loaded they will be copied in constructor Enumeration keys = overrideProperties.keys(); while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); if (key != null) { userProperties.setProperty(key, (String) overrideProperties.get(key)); } } }
From source file:org.openflamingo.web.util.VersionConfigurer.java
private void print(StringBuilder builder, Properties props) { int maxLength = getMaxLength(props); Enumeration<Object> keys = props.keys(); while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); String value = props.getProperty(key); builder.append(" ").append(key).append(getCharacter(maxLength - key.getBytes().length, " ")) .append(" : ").append(value).append("\n"); }/*from w w w.jav a 2 s . c o m*/ }
From source file:org.exem.flamingo.web.util.ApplicationInformationDisplayContextListener.java
private void print(StringBuilder builder, Properties props) { int maxLength = getMaxLength(props); Enumeration<Object> keys = props.keys(); while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); String value = props.getProperty(key); builder.append(" ").append(key).append(getFixedSizeString(maxLength - key.getBytes().length, " ")) .append(" : ").append(value).append("\n"); }//from www . j av a 2s .c om }
From source file:org.smartfrog.avalanche.client.sf.apps.utils.SystemUtils.java
public static void addUser(String user, Properties props) throws UtilsException { if ((null == user) || (user.length() == 0)) { log.error("User name cannot be null"); throw new UtilsException("User name cannot be null"); }// ww w . ja v a 2 s . c o m String cmd = "adduser"; if ((null == props) || (props.isEmpty())) { log.error("Please provide user information...."); throw new UtilsException("Please provide user information...."); } String passwd = (String) props.getProperty("-p"); if ((null == passwd) || (passwd.length() == 0)) { log.error("Password is not provided....Cannot create user"); throw new UtilsException("Password is not provided...." + "Cannot create user"); } String epasswd = jcrypt.crypt("Tb", passwd); if (epasswd.length() == 0) { log.error("Error in encrypting passwd..."); throw new UtilsException("Error in encrypting passwd..."); } props.setProperty("-p", epasswd); props.setProperty("-c", "User-" + user); String key = null; String value = null; Enumeration e = props.keys(); while (e.hasMoreElements()) { key = (String) e.nextElement(); value = (String) props.getProperty(key); if ((null != value) || (value.length() != 0)) cmd += " " + key + " " + value; else cmd += " " + key; } cmd += " " + user; Process p = null; Runtime rt = Runtime.getRuntime(); BufferedReader cmdError = null; int exitVal = 0; try { p = rt.exec(cmd); exitVal = p.waitFor(); cmdError = new BufferedReader(new InputStreamReader(p.getErrorStream())); if (exitVal != 0) { String err = "Error in adding user " + user + "... returned with exit value 0 : "; log.error(err); String line = null; while ((line = cmdError.readLine()) != null) { log.error(line); err += line; } throw new UtilsException(err); } } catch (IOException ioe) { log.error(ioe); throw new UtilsException(ioe); } catch (InterruptedException ie) { log.error(ie); throw new UtilsException(ie); } log.info("User " + user + " added successfully"); }
From source file:ste.web.http.MimeUtils.java
private Map<String, String> convertToMap(Properties p) { Map<String, String> map = new HashMap<String, String>(); for (Enumeration e = p.keys(); e.hasMoreElements();) { String extensions = ((String) e.nextElement()); for (String extension : extensions.split(",")) { String mimeTypeFull = p.getProperty(extensions); map.put(extension, mimeTypeFull); }/*from w w w .j av a 2s .c o m*/ } return map; }
From source file:org.rhq.enterprise.gui.startup.Configurator.java
/** * There is a single properties file in the web application that defines the default user properties. That * properties file is loaded in and stored in the servlet context so a user that logs in but doesn't have * preferences set yet can obtain these default settings. *///from ww w . j av a 2 s . c o m private void loadPreferences(ServletContext ctx) { try { Configuration userPrefs = new Configuration(); Properties userProps = loadProperties(ctx, DEFAULT_USER_PREFERENCES_FILE); Enumeration keys = userProps.keys(); while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); userPrefs.put(new PropertySimple(key, userProps.getProperty(key))); } ctx.setAttribute(Constants.DEF_USER_PREFS, userPrefs); } catch (Exception e) { log.error("failed to load user preferences at [" + DEFAULT_USER_PREFERENCES_FILE + "]: ", e); } }
From source file:com.opengamma.language.context.DefaultGlobalContextEventHandler.java
/** * Merges user specified settings into the "system" settings. Typically, settings * will be provided by the O/S launcher (e.g. from the registry on Windows). A * properties file can be used for a fallback if the properties aren't defined in * the registry. For example to provide defaults. * /* www .j a v a 2 s. c om*/ * @param systemSettings the default settings to use */ public void setSystemSettings(final Properties systemSettings) { ArgumentChecker.notNull(systemSettings, "systemSettings"); final Properties existingSettings = System.getProperties(); final Enumeration<Object> keys = systemSettings.keys(); while (keys.hasMoreElements()) { final Object keyObject = keys.nextElement(); if (existingSettings.containsKey(keyObject)) { s_logger.debug("Ignoring {} in favour of system property", keyObject); } else { if (keyObject instanceof String) { final String key = (String) keyObject; final String value = systemSettings.getProperty(key); existingSettings.setProperty(key, value); s_logger.debug("Using {}={}", key, value); } } } }
From source file:com.agiletec.ConfigTestUtils.java
private void createDatasources(SimpleNamingContextBuilder builder, Properties testConfig) { List<String> dsNameControlKeys = new ArrayList<String>(); Enumeration<Object> keysEnum = testConfig.keys(); while (keysEnum.hasMoreElements()) { String key = (String) keysEnum.nextElement(); if (key.startsWith("jdbc.")) { String[] controlKeys = key.split("\\."); String dsNameControlKey = controlKeys[1]; if (!dsNameControlKeys.contains(dsNameControlKey)) { this.createDatasource(dsNameControlKey, builder, testConfig); dsNameControlKeys.add(dsNameControlKey); }// w w w . j a v a 2s . c o m } } }