List of usage examples for java.util Properties entrySet
@Override
public Set<Map.Entry<Object, Object>> entrySet()
From source file:de.tudarmstadt.ukp.dkpro.argumentation.io.writer.ArgumentDumpWriter.java
/** * Prints to string all non-null {@code properties} of the the given unit * * @param argumentUnit argument unit//from w ww .j a v a 2 s . c om * @return string */ private static String formatProperties(ArgumentUnit argumentUnit) { StringBuilder sb = new StringBuilder("Properties:\n"); Properties properties = ArgumentUnitUtils.getProperties(argumentUnit); for (Map.Entry<Object, Object> entry : properties.entrySet()) { if (entry.getValue() != null) { sb.append(" "); sb.append(entry.getKey()); sb.append(": "); sb.append(entry.getValue()); sb.append("\n"); } } return sb.toString(); }
From source file:com.intuit.autumn.utils.PropertyFactory.java
private static void fromJar(final String propertyResourceName, @Nullable final Class base, final Properties properties) { if (base == null) { return;//from w w w .j a v a2 s .c o m } CodeSource src = base.getProtectionDomain().getCodeSource(); if (src == null) { return; } Properties propertiesFromJar = getPropertyFromJar(base, propertyResourceName.substring(1), src); for (Entry<Object, Object> entry : propertiesFromJar.entrySet()) { if (!properties.containsKey(entry.getKey())) { LOGGER.debug("overriding key: {}, newValue: {}, originalValue: {}", new Object[] { entry.getKey(), propertiesFromJar, entry.getValue() }); properties.setProperty((String) entry.getKey(), (String) entry.getValue()); } } }
From source file:com.asakusafw.yaess.tools.log.cli.Main.java
private static Map<String, String> parseArgs(CommandLine cmd, Option opt) { Properties props = cmd.getOptionProperties(opt.getOpt()); Map<String, String> results = new TreeMap<>(); for (Map.Entry<Object, Object> entry : props.entrySet()) { results.put((String) entry.getKey(), (String) entry.getValue()); }/*w w w. ja v a 2 s. c om*/ return results; }
From source file:org.apache.hcatalog.cli.HCatCli.java
private static void setConfProperties(HiveConf conf, Properties props) { for (java.util.Map.Entry<Object, Object> e : props.entrySet()) conf.set((String) e.getKey(), (String) e.getValue()); }
From source file:gobblin.util.PropertiesUtils.java
/** * Extract all the keys that start with a <code>prefix</code> in {@link Properties} to a new {@link Properties} * instance.//from w ww .ja va 2 s . c o m * * @param properties the given {@link Properties} instance * @param prefix of keys to be extracted * @return a {@link Properties} instance */ public static Properties extractPropertiesWithPrefix(Properties properties, Optional<String> prefix) { Preconditions.checkNotNull(properties); Preconditions.checkNotNull(prefix); Properties extractedProperties = new Properties(); for (Map.Entry<Object, Object> entry : properties.entrySet()) { if (StringUtils.startsWith(entry.getKey().toString(), prefix.or(StringUtils.EMPTY))) { extractedProperties.put(entry.getKey().toString(), entry.getValue()); } } return extractedProperties; }
From source file:fr.cls.atoll.motu.library.misc.utils.PropertiesUtilities.java
/** * Replace in the properties values the name of the system variable that follows the scheme * <tt>${var}<tt> with their corresponding values. * //from w w w. j a va2 s. c o m * @param props properties to substitute. */ static public void replaceSystemVariable(Properties props) { Iterator it; Map.Entry entry; String value; for (it = props.entrySet().iterator(); it.hasNext();) { entry = (Map.Entry) it.next(); try { value = replaceSystemVariable((String) entry.getValue()); } catch (NoSuchElementException ex) { throw new NoSuchElementException( ex.getMessage() + " subsitution for property " + (String) entry.getKey()); } entry.setValue(value); } }
From source file:io.openmessaging.rocketmq.utils.BeanUtils.java
public static <T> T populate(final Properties properties, final T obj) { Class<?> clazz = obj.getClass(); try {/* ww w . j ava2 s .c om*/ Set<Map.Entry<Object, Object>> entries = properties.entrySet(); for (Map.Entry<Object, Object> entry : entries) { String entryKey = entry.getKey().toString(); String[] keyGroup = entryKey.split("\\."); for (int i = 0; i < keyGroup.length; i++) { keyGroup[i] = keyGroup[i].toLowerCase(); keyGroup[i] = StringUtils.capitalize(keyGroup[i]); } String beanFieldNameWithCapitalization = StringUtils.join(keyGroup); try { setProperties(clazz, obj, "set" + beanFieldNameWithCapitalization, entry.getValue()); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) { //ignored... } } } catch (RuntimeException e) { log.warn("Error occurs !", e); } return obj; }
From source file:com.roche.iceboar.settings.GlobalSettingsFactory.java
private static List<String> readRemoteResourcesByPrefix(String codeBase, Properties properties, String prefix) { List<String> urls = new ArrayList<String>(); for (Map.Entry<Object, Object> entry : properties.entrySet()) { Object key = entry.getKey(); if (key instanceof String && ((String) key).startsWith(prefix)) { String urlText = getAbsoluteUrl(codeBase, entry.getValue().toString()); urls.add(urlText);//from www. ja v a2 s . co m } } return urls; }
From source file:com.stratuscom.harvester.Utils.java
public static String format(Properties props) { if (props == null) { return "null"; }// w w w. j a v a 2s. c om StringBuffer sb = new StringBuffer(); sb.append("["); for (Map.Entry entry : props.entrySet()) { boolean first = true; if (!first) { sb.append(", "); } else { first = false; } sb.append(entry.getKey() + "=\""); sb.append(entry.getValue()); sb.append("\""); } sb.append("]"); return sb.toString(); }
From source file:io.cloudslang.lang.cli.SlangBootstrap.java
private static void loadUserProperties() throws IOException { String appHome = System.getProperty("app.home"); String propertyFilePath = appHome + File.separator + USER_CONFIG_FILEPATH; File propertyFile = new File(propertyFilePath); Properties rawProperties = new Properties(); if (propertyFile.isFile()) { try (InputStream propertiesStream = new FileInputStream(propertyFilePath)) { rawProperties.load(propertiesStream); }//w w w . j a va 2 s . c o m } Set<Map.Entry<Object, Object>> propertyEntries = rawProperties.entrySet(); for (Map.Entry<Object, Object> property : propertyEntries) { String key = (String) property.getKey(); String value = (String) property.getValue(); value = substitutePropertyReferences(value); System.setProperty(key, value); } }