List of usage examples for java.util Properties entrySet
@Override
public Set<Map.Entry<Object, Object>> entrySet()
From source file:com.roche.iceboar.settings.GlobalSettingsFactory.java
private static List<String> getAllPropertiesForTarget(Properties properties) { List<String> allPropertiesForTarget = new ArrayList<String>(); for (Map.Entry<Object, Object> entry : properties.entrySet()) { Object key = entry.getKey(); if (key instanceof String) { String keyText = (String) key; if (keyText.startsWith("jnlp.") && !keyText.startsWith(JNLP_ICE_BOAR_PREFIX)) { allPropertiesForTarget.add("-D" + key + "=\"" + entry.getValue() + "\""); }// www . j a v a 2s .c o m } } return allPropertiesForTarget; }
From source file:com.netflix.config.util.ConfigurationUtils.java
public static void loadProperties(Properties props, Configuration config) { for (Entry<Object, Object> entry : props.entrySet()) { config.setProperty((String) entry.getKey(), entry.getValue()); }/*from w w w. jav a2 s . c o m*/ }
From source file:org.apache.jmeter.protocol.http.sampler.HttpClientDefaultParameters.java
private static void load(String file, GenericHttpParams params) { log.info("Trying httpclient parameters from " + file); File f = new File(file); if (!(f.exists() && f.canRead())) { f = new File(NewDriver.getJMeterDir() + File.separator + "bin" + File.separator + file); // $NON-NLS-1$ log.info(file + " httpclient parameters does not exist, trying " + f.getAbsolutePath()); if (!(f.exists() && f.canRead())) { log.error("Cannot read parameters file for HttpClient: " + file); return; }//from w w w.j a v a 2s .co m } log.info("Reading httpclient parameters from " + f.getAbsolutePath()); InputStream is = null; Properties props = new Properties(); try { is = new FileInputStream(f); props.load(is); for (Map.Entry<Object, Object> me : props.entrySet()) { String key = (String) me.getKey(); String value = (String) me.getValue(); int typeSep = key.indexOf('$'); // $NON-NLS-1$ try { if (typeSep > 0) { String type = key.substring(typeSep + 1);// get past separator String name = key.substring(0, typeSep); log.info("Defining " + name + " as " + value + " (" + type + ")"); if (type.equals("Integer")) { params.setParameter(name, Integer.valueOf(value)); } else if (type.equals("Long")) { params.setParameter(name, Long.valueOf(value)); } else if (type.equals("Boolean")) { params.setParameter(name, Boolean.valueOf(value)); } else if (type.equals("HttpVersion")) { // Commons HttpClient only params.setVersion(name, value); } else { log.warn("Unexpected type: " + type + " for name " + name); } } else { log.info("Defining " + key + " as " + value); params.setParameter(key, value); } } catch (Exception e) { log.error("Error in property: " + key + "=" + value + " " + e.toString()); } } } catch (IOException e) { log.error("Problem loading properties " + e.toString()); } finally { JOrphanUtils.closeQuietly(is); } }
From source file:uk.org.openeyes.oink.itest.karaf.OinkKarafITSupport.java
public static Dictionary<String, Object> convertToDictionary(Properties props) { Dictionary<String, Object> d = new Hashtable<String, Object>(); for (Entry<Object, Object> entry : props.entrySet()) { d.put((String) entry.getKey(), entry.getValue()); }//from w w w . j av a2s. c om return d; }
From source file:com.evolveum.midpoint.testing.model.client.sample.RunScript.java
private static String replaceParameters(String script, Properties properties) { for (Map.Entry entry : properties.entrySet()) { String key = PROPERTY_PREFIX + entry.getKey() + PROPERTY_SUFFIX; if (!script.contains(key)) { throw new IllegalStateException("Property " + key + " is not present in the script"); }/*from ww w .j a v a2 s.com*/ script = script.replace(key, (String) entry.getValue()); } int i = script.indexOf(PROPERTY_PREFIX); if (i != -1) { int j = script.indexOf(PROPERTY_SUFFIX, i); if (j == -1) { j = script.length(); } throw new IllegalStateException( "Unresolved property " + script.substring(i, j + PROPERTY_SUFFIX.length())); } return script; }
From source file:edu.kit.dama.dataworkflow.util.DataWorkflowTaskUtils.java
/** * Print the provided list of DataWorkflow tasks to StdOut, either in a basic * tabular view or in verbose mode, in a detailed representation. * * @param pTasks The list of tasks to print out. * @param pVerbose TRUE = print detailed view, FALSE = print basic tabular * view.//from ww w. ja v a2 s . c o m */ public static void printTaskList(List<DataWorkflowTask> pTasks, boolean pVerbose) { if (!pVerbose) { //do table listing //Headers: ID | STATUS | LAST_MODIFIED //Lengths: 10 | 34 | 34 StringBuilder listing = new StringBuilder(); listing.append(StringUtils.center("Task ID", 10)).append("|").append(StringUtils.center("Status", 34)) .append("|").append(StringUtils.center("Last Modified", 34)).append("\n"); for (DataWorkflowTask task : pTasks) { listing.append(StringUtils.center(Long.toString(task.getId()), 10)).append("|") .append(StringUtils.center(task.getStatus().toString(), 34)).append("|") .append(StringUtils.center(new SimpleDateFormat().format(task.getLastUpdate()), 34)) .append("\n"); } System.out.println(listing.toString()); } else { //do detailed listing //ID: <ID> Status: <STATUS> Last Update: <LAST_UPDATE> //Config: <CONFIG_ID> Environment: <ID> Predecessor: <ID> //Group: <GID> Executor: <UID> Contact: <EMAIL> //Investigation: <ID> //InputDir: <URL> //OutputDir: <URL> //WorkingDir: <URL> //TempDir: <URL> //Input Objects // Object | View // OID 1 | default // OID 2 | default //Transfers // Object | TransferId // OID 1 | 123 //-------------------------------------------------------------- StringBuilder builder = new StringBuilder(); for (DataWorkflowTask task : pTasks) { builder.append(StringUtils.rightPad("Id: " + task.getId(), 40)) .append(StringUtils.rightPad( "Predecessor: " + ((task.getPredecessor() != null) ? task.getPredecessor().getId() : "-"), 40)) .append("\n").append(StringUtils.rightPad("Status: " + task.getStatus(), 40)) .append(StringUtils.rightPad( "Last Update: " + new SimpleDateFormat().format(task.getLastUpdate()), 40)) .append("\n") .append(StringUtils.rightPad("Configuration: " + ((task.getConfiguration() != null) ? task.getConfiguration().getId() : "-"), 40)) .append(StringUtils.rightPad("Environment: " + ((task.getExecutionEnvironment() != null) ? task.getExecutionEnvironment().getId() : "-"), 40)) .append("\n").append(StringUtils.rightPad("Group: " + task.getExecutorGroupId(), 40)) .append(StringUtils.rightPad("User: " + task.getExecutorId(), 40)).append("\n") .append(StringUtils.rightPad("Contact UserId: " + ((task.getContactUserId() != null) ? task.getContactUserId() : "-"), 80)) .append("\n") .append(StringUtils.rightPad("InvestigationId: " + task.getInvestigationId(), 80)) .append("\n").append(StringUtils.rightPad("Input Dir:", 15)) .append(StringUtils.abbreviateMiddle(task.getInputDirectoryUrl(), "...", 65)).append("\n") .append(StringUtils.rightPad("Output Dir:", 15)) .append(StringUtils.abbreviateMiddle(task.getOutputDirectoryUrl(), "...", 65)).append("\n") .append(StringUtils.rightPad("Working Dir:", 15)) .append(StringUtils.abbreviateMiddle(task.getWorkingDirectoryUrl(), "...", 65)).append("\n") .append(StringUtils.rightPad("Temp Dir:", 15)) .append(StringUtils.abbreviateMiddle(task.getTempDirectoryUrl(), "...", 65)).append("\n") .append(StringUtils.rightPad("Input Objects:", 80)).append("\n") .append(StringUtils.center("ObjectId", 39)).append("|") .append(StringUtils.center("View", 40)).append("\n"); try { Properties objectViewMap = task.getObjectViewMapAsObject(); Set<Entry<Object, Object>> entries = objectViewMap.entrySet(); if (entries.isEmpty()) { builder.append(StringUtils.center("---", 39)).append("|") .append(StringUtils.center("---", 40)).append("\n"); } else { for (Entry<Object, Object> entry : entries) { builder.append(StringUtils.center((String) entry.getKey(), 39)).append("|") .append(StringUtils.center((String) entry.getValue(), 40)).append("\n"); } } } catch (IOException ex) { LOGGER.error("Failed to deserialize object-view map of DataWorkflow task " + task.getId(), ex); builder.append(StringUtils.center("---", 39)).append("|").append(StringUtils.center("---", 40)) .append("\n"); } builder.append(StringUtils.rightPad("Transfers:", 80)).append("\n") .append(StringUtils.center("ObjectId", 39)).append("|") .append(StringUtils.center("TransferId", 40)).append("\n"); try { Properties objectTransferMap = task.getObjectTransferMapAsObject(); Set<Entry<Object, Object>> entries = objectTransferMap.entrySet(); if (entries.isEmpty()) { builder.append(StringUtils.center("---", 39)).append("|") .append(StringUtils.center("---", 40)).append("\n"); } else { for (Entry<Object, Object> entry : entries) { builder.append(StringUtils.center((String) entry.getKey(), 39)).append("|") .append(StringUtils.center((String) entry.getValue(), 40)).append("\n"); } } } catch (IOException ex) { LOGGER.error("Failed to deserialize object-transfer map of DataWorkflow task " + task.getId(), ex); builder.append(StringUtils.center("---", 39)).append("|").append(StringUtils.center("---", 40)) .append("\n"); } //add closing line builder.append(StringUtils.leftPad("", 80, '-')).append("\n"); } System.out.println(builder.toString()); } }
From source file:com.cisco.oss.foundation.directory.Configurations.java
/** * Load the customer Properties to Configurations. * * @param props/* w w w . j a v a2 s.c o m*/ * the customer Properties. */ public static void loadCustomerProperties(Properties props) { for (Entry<Object, Object> entry : props.entrySet()) { setProperty((String) entry.getKey(), entry.getValue()); } }
From source file:com.comcast.cats.domain.configuration.CatsHome.java
public static void displaySystemProperties() { Properties props = System.getProperties(); logger.info("Found " + Integer.toString(props.size()) + " System Properties!"); Iterator<Entry<Object, Object>> iterator = props.entrySet().iterator(); Entry<Object, Object> entry; while (iterator.hasNext()) { entry = iterator.next();/*from ww w. j a va 2 s.c o m*/ logger.info(entry.getKey() + "=" + entry.getValue()); } }
From source file:gemlite.core.util.Util.java
public final static String printProperties() { StringBuilder bu = new StringBuilder(); Properties props = System.getProperties(); Iterator<Entry<Object, Object>> it = props.entrySet().iterator(); while (it.hasNext()) { Entry<Object, Object> e = it.next(); bu.append(e.getKey()).append("=").append(e.getValue()).append("\n"); }/*w ww . java2 s . c o m*/ Map<String, String> map = System.getenv(); Iterator<Entry<String, String>> it2 = map.entrySet().iterator(); while (it.hasNext()) { Entry<String, String> e = it2.next(); bu.append(e.getKey()).append("=").append(e.getValue()).append("\n"); } System.out.println(bu.toString()); return bu.toString(); }
From source file:org.apache.maven.wagon.providers.http.ConfigurationUtils.java
public static void copyConfig(HttpMethodConfiguration config, RequestConfig.Builder builder) { if (config.getConnectionTimeout() > 0) { builder.setConnectTimeout(config.getConnectionTimeout()); }/*from ww w .ja va2 s. co m*/ if (config.getReadTimeout() > 0) { builder.setSocketTimeout(config.getReadTimeout()); } Properties params = config.getParams(); if (params != null) { Pattern coercePattern = Pattern.compile(COERCE_PATTERN); for (Map.Entry entry : params.entrySet()) { String key = (String) entry.getKey(); String value = (String) entry.getValue(); Matcher matcher = coercePattern.matcher(value); if (matcher.matches()) { value = matcher.group(2); } if (key.equals(SO_TIMEOUT)) { builder.setSocketTimeout(Integer.parseInt(value)); } else if (key.equals(STALE_CONNECTION_CHECK)) { builder.setStaleConnectionCheckEnabled(Boolean.valueOf(value)); } else if (key.equals(CONNECTION_TIMEOUT)) { builder.setConnectTimeout(Integer.parseInt(value)); } else if (key.equals(USE_EXPECT_CONTINUE)) { builder.setExpectContinueEnabled(Boolean.valueOf(value)); } else if (key.equals(DEFAULT_PROXY)) { builder.setProxy(new HttpHost(value)); } else if (key.equals(LOCAL_ADDRESS)) { try { builder.setLocalAddress(InetAddress.getByName(value)); } catch (UnknownHostException ignore) { } } else if (key.equals(PROXY_AUTH_PREF)) { builder.setProxyPreferredAuthSchemes(Arrays.asList(value.split(","))); } else if (key.equals(TARGET_AUTH_PREF)) { builder.setTargetPreferredAuthSchemes(Arrays.asList(value.split(","))); } else if (key.equals(HANDLE_AUTHENTICATION)) { builder.setAuthenticationEnabled(Boolean.valueOf(value)); } else if (key.equals(ALLOW_CIRCULAR_REDIRECTS)) { builder.setCircularRedirectsAllowed(Boolean.valueOf(value)); } else if (key.equals(CONN_MANAGER_TIMEOUT)) { builder.setConnectionRequestTimeout(Integer.parseInt(value)); } else if (key.equals(COOKIE_POLICY)) { builder.setCookieSpec(value); } else if (key.equals(MAX_REDIRECTS)) { builder.setMaxRedirects(Integer.parseInt(value)); } else if (key.equals(HANDLE_REDIRECTS)) { builder.setRedirectsEnabled(Boolean.valueOf(value)); } else if (key.equals(REJECT_RELATIVE_REDIRECT)) { builder.setRelativeRedirectsAllowed(!Boolean.valueOf(value)); } } } }