List of usage examples for java.util Properties propertyNames
public Enumeration<?> propertyNames()
From source file:io.apiman.servers.gateway_h2.Starter.java
/** * Loads properties from a file and puts them into system properties. *//*from w ww.ja v a 2 s. c om*/ @SuppressWarnings({ "unchecked" }) protected static void loadProperties() { URL configUrl = Starter.class.getClassLoader().getResource("gateway_h2-apiman.properties"); if (configUrl == null) { throw new RuntimeException( "Failed to find properties file (see README.md): gateway_h2-apiman.properties"); } InputStream is = null; try { is = configUrl.openStream(); Properties props = new Properties(); props.load(is); Enumeration<String> names = (Enumeration<String>) props.propertyNames(); while (names.hasMoreElements()) { String name = names.nextElement(); String value = props.getProperty(name); System.setProperty(name, value); } } catch (IOException e) { throw new RuntimeException(e); } finally { IOUtils.closeQuietly(is); } }
From source file:de.hypoport.ep2.support.configuration.properties.PropertiesLoader.java
static void replacePropertyPlaceHolder(Properties properties) { Enumeration<?> keyEnum = properties.propertyNames(); while (keyEnum.hasMoreElements()) { String key = (String) keyEnum.nextElement(); Object value = properties.get(key); if (value != null && value instanceof String) { String valueString = (String) value; valueString = replacePropertyPlaceHolder(valueString, properties); properties.put(key, valueString); }/*ww w . ja v a 2 s. c o m*/ } }
From source file:Main.java
public static void mergePropertiesIntoMap(final Properties props, final Map<String, String> map) { if (map == null) { throw new IllegalArgumentException("Map must not be null"); }/*from w ww. j a v a 2s . c o m*/ if (props != null) { for (Enumeration<?> en = props.propertyNames(); en.hasMoreElements();) { String key = (String) en.nextElement(); map.put(key, props.getProperty(key)); } } }
From source file:Main.java
/** * Merge the given Properties instance into the given Map, * copying all properties (key-value pairs) over. * <p>Uses {@code Properties.propertyNames()} to even catch * default properties linked into the original Properties instance. * @param props the Properties instance to merge (may be {@code null}) * @param map the target Map to merge the properties into *///w ww.j a v a 2 s. co m @SuppressWarnings("unchecked") public static <K, V> void mergePropertiesIntoMap(Properties props, Map<K, V> map) { if (map == null) { throw new IllegalArgumentException("Map must not be null"); } if (props != null) { for (Enumeration<?> en = props.propertyNames(); en.hasMoreElements();) { String key = (String) en.nextElement(); Object value = props.get(key); if (value == null) { // Allow for defaults fallback or potentially overridden accessor... value = props.getProperty(key); } map.put((K) key, (V) value); } } }
From source file:Main.java
/** * Merge the given Properties instance into the given Map, copying all * properties (key-value pairs) over./*from www . j ava 2s . c o m*/ * <p> * Uses {@code Properties.propertyNames()} to even catch default properties * linked into the original Properties instance. * * @param props * the Properties instance to merge (may be {@code null}) * @param map * the target Map to merge the properties into */ @SuppressWarnings("unchecked") public static <K, V> void mergePropertiesIntoMap(Properties props, Map<K, V> map) { if (map == null) { throw new IllegalArgumentException("Map must not be null"); } if (props != null) { for (Enumeration<?> en = props.propertyNames(); en.hasMoreElements();) { String key = (String) en.nextElement(); Object value = props.getProperty(key); if (value == null) { // Potentially a non-String value... value = props.get(key); } map.put((K) key, (V) value); } } }
From source file:Main.java
/** * Merge the given Properties instance into the given Map, copying all properties (key-value pairs) over. * <p>/*w w w . jav a2s . c om*/ * Uses <code>Properties.propertyNames()</code> to even catch default properties linked into the original Properties instance. * * @param props * the Properties instance to merge (may be <code>null</code>) * @param map * the target Map to merge the properties into */ @SuppressWarnings({ "unchecked", "rawtypes" }) public static void mergePropertiesIntoMap(Properties props, Map map) { if (map == null) { throw new IllegalArgumentException("Map must not be null"); } if (props != null) { for (final Enumeration<?> en = props.propertyNames(); en.hasMoreElements();) { final String key = (String) en.nextElement(); Object value = props.getProperty(key); if (value == null) { // Potentially a non-String value... value = props.get(key); } map.put(key, value); } } }
From source file:org.official.json.Property.java
/** * Converts a property file object into a JSONObject. The property file object is a table of name value pairs. * @param properties java.util.Properties * @return JSONObject//from ww w .j a v a 2 s . c o m * @throws JSONException */ public static JSONObject toJSONObject(java.util.Properties properties) throws JSONException { JSONObject jo = new JSONObject(); if (properties != null && !properties.isEmpty()) { Enumeration enumProperties = properties.propertyNames(); while (enumProperties.hasMoreElements()) { String name = (String) enumProperties.nextElement(); jo.put(name, properties.getProperty(name)); } } return jo; }
From source file:Main.java
/** * Merge the given Properties instance into the given Map, copying all properties (key-value pairs) over. * <p>//from w w w . j ava 2 s. c om * Uses <code>Properties.propertyNames()</code> to even catch default properties linked into the original Properties * instance. * @param props the Properties instance to merge (may be <code>null</code>) * @param map the target Map to merge the properties into */ public static void mergePropertiesIntoMap(Properties props, Map<String, Object> map) { if (map == null) { throw new IllegalArgumentException("Map must not be null"); } if (props != null) { for (Enumeration<?> en = props.propertyNames(); en.hasMoreElements();) { String key = (String) en.nextElement(); Object value = props.getProperty(key); if (value == null) { // Potentially a non-String value... value = props.get(key); } map.put(key, value); } } }
From source file:Main.java
/** * Merge the given Properties instance into the given Map, * copying all properties (key-value pairs) over. * <p>Uses <code>Properties.propertyNames()</code> to even catch * default properties linked into the original Properties instance. * @param props the Properties instance to merge (may be <code>null</code>) * @param map the target Map to merge the properties into *///from ww w .j av a 2s . c om public static void mergePropertiesIntoMap(Properties props, Map<? super String, ? super String> map) { if (map == null) { throw new IllegalArgumentException("Map must not be null"); } if (props != null) { for (Enumeration<?> en = props.propertyNames(); en.hasMoreElements();) { String key = (String) en.nextElement(); map.put(key, props.getProperty(key)); } } }
From source file:org.kawanfw.sql.api.client.RemoteDriverUtil.java
/** * Copy a set of properties from one Property to another. * <p>//from www .ja va 2 s . c o m * * @param srcProp Source set of properties to copy from. * @param destProp Dest Properties to copy into. * **/ public static void copyProperties(Properties srcProp, Properties destProp) { for (Enumeration<?> propertyNames = srcProp.propertyNames(); propertyNames.hasMoreElements();) { Object key = propertyNames.nextElement(); destProp.put(key, srcProp.get(key)); } }