List of usage examples for java.util Properties entrySet
@Override
public Set<Map.Entry<Object, Object>> entrySet()
From source file:com.cws.esolutions.security.config.xml.SecurityConfigurationData.java
public static final String expandEnvVars(final String value) { final String methodName = SecurityConfigurationData.CNAME + "#expandEnvVars(final String value)"; if (DEBUG) {/* w w w . jav a2s . c om*/ DEBUGGER.debug(methodName); DEBUGGER.debug("Value: {}", value); } String returnValue = null; if (!(StringUtils.contains(value, "$"))) { return null; } final Properties sysProps = System.getProperties(); final Map<String, String> envMap = System.getenv(); final String text = StringUtils.replaceEachRepeatedly(value.split("=")[1].trim(), new String[] { "${", "}" }, new String[] { "", "" }).trim(); if (DEBUG) { DEBUGGER.debug("Properties sysProps: {}", sysProps); DEBUGGER.debug("Map<String, String> envMap: {}", envMap); DEBUGGER.debug("String text: {}", text); } for (Entry<Object, Object> property : sysProps.entrySet()) { if (DEBUG) { DEBUGGER.debug("Entry<Object, Object> property: {}", property); } String key = (String) property.getKey(); if (DEBUG) { DEBUGGER.debug("String key: {}", key); } if (StringUtils.equals(key.trim(), text)) { returnValue = sysProps.getProperty(key.trim()); break; } } for (Entry<String, String> entry : envMap.entrySet()) { if (DEBUG) { DEBUGGER.debug("Entry<String, String> entry: {}", entry); } String key = entry.getKey(); if (DEBUG) { DEBUGGER.debug("String key: {}", key); } if (StringUtils.equals(key.trim(), text)) { returnValue = entry.getValue(); break; } } if (DEBUG) { DEBUGGER.debug("String returnValue: {}", returnValue); } return returnValue; }
From source file:org.apache.kylin.common.KylinConfig.java
public static void writeOverrideProperties(Properties properties) throws IOException { File propFile = getKylinPropertiesFile(); File overrideFile = new File(propFile.getParentFile(), propFile.getName() + ".override"); overrideFile.createNewFile();/*from w w w.ja v a 2s. com*/ FileInputStream fis2 = null; Properties override = new Properties(); try { fis2 = new FileInputStream(overrideFile); override.load(fis2); for (Map.Entry<Object, Object> entries : properties.entrySet()) { override.setProperty(entries.getKey().toString(), entries.getValue().toString()); } } catch (IOException e) { throw new RuntimeException(e); } finally { IOUtils.closeQuietly(fis2); } PrintWriter pw = null; try { pw = new PrintWriter(overrideFile); Enumeration<?> e = override.propertyNames(); while (e.hasMoreElements()) { String key = (String) e.nextElement(); pw.println(key + "=" + override.getProperty(key)); } pw.close(); } finally { IOUtils.closeQuietly(pw); } }
From source file:com.datatorrent.stram.client.StramClientUtils.java
public static void evalConfiguration(Configuration conf) { Properties props = new Properties(); for (Map.Entry entry : conf) { props.put(entry.getKey(), entry.getValue()); }//from w w w . ja v a 2 s.c o m evalProperties(props, conf); for (Map.Entry<Object, Object> entry : props.entrySet()) { conf.set((String) entry.getKey(), (String) entry.getValue()); } }
From source file:edu.umd.cs.eclipse.courseProjectManager.TurninProjectAction.java
public static void addPropertiesNotAlreadyDefined(Properties dst, Properties src) { for (Map.Entry<?, ?> entry : src.entrySet()) { if (!dst.containsKey(entry.getKey())) dst.setProperty((String) entry.getKey(), (String) entry.getValue()); }/*w w w . j a v a 2 s. co m*/ }
From source file:net.oauth.example.provider.core.SampleOAuthProvider.java
public static synchronized void loadConsumers(ServletConfig config) throws IOException { Properties p = consumerProperties; if (p == null) { p = new Properties(); String resourceName = "/" + SampleOAuthProvider.class.getPackage().getName().replace(".", "/") + "/provider.properties"; URL resource = SampleOAuthProvider.class.getClassLoader().getResource(resourceName); if (resource == null) { throw new IOException("resource not found: " + resourceName); }/*from www .j av a2 s .c o m*/ InputStream stream = resource.openStream(); try { p.load(stream); } finally { stream.close(); } } consumerProperties = p; // for each entry in the properties file create a OAuthConsumer for (Map.Entry prop : p.entrySet()) { String consumer_key = (String) prop.getKey(); // make sure it's key not additional properties if (!consumer_key.contains(".")) { String consumer_secret = (String) prop.getValue(); if (consumer_secret != null) { String consumer_description = (String) p.getProperty(consumer_key + ".description"); String consumer_callback_url = (String) p.getProperty(consumer_key + ".callbackURL"); // Create OAuthConsumer w/ key and secret OAuthConsumer consumer = new OAuthConsumer(consumer_callback_url, consumer_key, consumer_secret, null); consumer.setProperty("name", consumer_key); consumer.setProperty("description", consumer_description); ALL_CONSUMERS.put(consumer_key, consumer); } } } }
From source file:com.jajja.jorm.Database.java
private static void configure(URL url) { Database.get().log.debug("Found jorm configuration @ " + url.toString()); Properties properties = new Properties(); try {//www . j a va2 s. co m InputStream is = url.openStream(); properties.load(is); is.close(); } catch (IOException ex) { Database.get().log.error("Failed to open jorm.properties: " + ex.getMessage(), ex); return; } for (Entry<Object, Object> property : properties.entrySet()) { String[] parts = ((String) property.getKey()).split("\\."); boolean isMalformed = false; if (parts[0].equals("database") && parts.length > 1) { String database = parts[1]; Configuration configuration = configurations.get(database); if (configuration == null) { configuration = new Configuration(database); configurations.put(database, configuration); } String value = (String) property.getValue(); switch (parts.length) { case 2: if (parts[1].equals("context")) { Database.get().globalDefaultContext = value; } else { isMalformed = true; } break; case 3: if (parts[2].equals("destroyMethod")) { configuration.destroyMethodName = value; } else if (parts[2].equals("dataSource")) { configuration.dataSourceClassName = value; } else if (parts[2].equals("defaultContext")) { if (database.indexOf(Context.CONTEXT_SEPARATOR) != -1) { isMalformed = true; } else { Database.get().defaultContext.put(database, value); } } else { isMalformed = true; } break; case 4: if (parts[2].equals("dataSource")) { configuration.dataSourceProperties.put(parts[3], value); } else { isMalformed = true; } break; default: isMalformed = true; } } else { isMalformed = true; } if (isMalformed) { Database.get().log.warn(String.format("Malformed jorm property: %s", property.toString())); } } }
From source file:org.apache.james.mailbox.model.MailboxACL.java
private static Map<EntryKey, Rfc4314Rights> toMap(Properties props) throws UnsupportedRightException { ImmutableMap.Builder<EntryKey, Rfc4314Rights> builder = ImmutableMap.builder(); if (props != null) { for (Map.Entry<?, ?> prop : props.entrySet()) { builder.put(EntryKey.deserialize((String) prop.getKey()), Rfc4314Rights.fromSerializedRfc4314Rights((String) prop.getValue())); }/*from w w w . ja va 2 s .c o m*/ } return builder.build(); }
From source file:com.splicemachine.derby.utils.SpliceAdmin.java
/** * Tag each property value with a 'type' of SERVICE or DATABASE. The structure of the map changes from: * {key --> value}//w w w.ja va 2 s . co m * to: * {key --> [value, type]} * * @param props Map of properties to tag with type * @return the new map of typed properties */ private static Properties addTypeToProperties(Properties props) { Properties typedProps = new Properties(); if (props != null) { for (Entry<Object, Object> objectObjectEntry : props.entrySet()) { Entry prop = (Entry) objectObjectEntry; String key = (String) prop.getKey(); String[] typedValue = new String[2]; typedValue[0] = (String) prop.getValue(); typedValue[1] = PropertyUtil.isServiceProperty(key) ? "SERVICE" : "DATABASE"; typedProps.put(key, typedValue); } } return typedProps; }
From source file:edu.umd.cs.eclipse.courseProjectManager.TurninProjectAction.java
/** * @param allSubmissionProps//ww w . j a v a2s.c o m * @param filePost */ static void addAllPropertiesButSubmitURL(Properties allSubmissionProps, MultipartPostMethod filePost) { for (Map.Entry<?, ?> e : allSubmissionProps.entrySet()) { String key = (String) e.getKey(); String value = (String) e.getValue(); if (!key.equals("submitURL")) filePost.addParameter(key, value); } }
From source file:com.senseidb.svc.impl.HttpRestSenseiServiceImpl.java
private static String convertSelectionProperties(Properties props) { List<String> propList = new ArrayList<String>(props.size()); final String format = "%s:%s"; Set<Entry<Object, Object>> entries = props.entrySet(); for (Entry<Object, Object> entry : entries) { propList.add(String.format(format, entry.getKey(), entry.getValue())); }/*from w ww .j ava 2 s .c om*/ return join(propList, ","); }