List of usage examples for java.util Properties propertyNames
public Enumeration<?> propertyNames()
From source file:com.haulmont.cuba.security.listener.EntityLogItemDetachListener.java
protected void fillAttributesFromChangesField(EntityLogItem item) { log.trace("fillAttributesFromChangesField for " + item); List<EntityLogAttr> attributes = new ArrayList<>(); StringReader reader = new StringReader(item.getChanges()); Properties properties = new Properties(); try {//from www . ja v a 2 s. c om properties.load(reader); Enumeration<?> names = properties.propertyNames(); while (names.hasMoreElements()) { String name = (String) names.nextElement(); if (StringUtils.endsWithAny(name, skipNames)) continue; EntityLogAttr attr = new EntityLogAttr(); attr.setLogItem(item); attr.setName(name); attr.setValue(properties.getProperty(name)); attr.setValueId(properties.getProperty(name + VALUE_ID_SUFFIX)); attr.setOldValue(properties.getProperty(name + OLD_VALUE_SUFFIX)); attr.setOldValueId(properties.getProperty(name + OLD_VALUE_ID_SUFFIX)); attr.setMessagesPack(properties.getProperty(name + MP_SUFFIX)); attributes.add(attr); } } catch (Exception e) { log.error("Unable to fill EntityLog attributes for " + item, e); } Collections.sort(attributes, (o1, o2) -> Ordering.natural().compare(o1.getName(), o2.getName())); item.setAttributes(new LinkedHashSet<>(attributes)); }
From source file:org.qedeq.base.io.IoUtility.java
/** * Print current system properties to System.out. *//* w w w .j a v a2s . com*/ public static void printAllSystemProperties() { Properties sysprops = System.getProperties(); for (Enumeration e = sysprops.propertyNames(); e.hasMoreElements();) { String key = (String) e.nextElement(); String value = sysprops.getProperty(key); System.out.println(key + "=" + value); } }
From source file:com.mengka.diamond.server.service.NotifyService.java
/** * ???//w w w.j a va2 s .co m * @param id */ public void notifyConfigInfoChange(String dataId, String group) { Properties nodeProperties = getNodeProperties(); Enumeration<?> enu = nodeProperties.propertyNames(); while (enu.hasMoreElements()) { String address = (String) enu.nextElement(); if (address.contains(SystemConfig.LOCAL_IP)) { continue; } //?url String urlString = generateNotifyConfigInfoPath(dataId, group, address, nodeProperties); //?get final String result = invokeURL(urlString); log.info("" + address + "??" + result); } }
From source file:edu.sampleu.admin.XmlIngester.java
/** * -DXMLIngester.userCnt=176 will override the userCnt in property files. * @param props//www . j av a 2 s .c o m */ private void systemPropertiesOverride(Properties props) { Enumeration<?> names = props.propertyNames(); Object nameObject; String name; while (names.hasMoreElements()) { nameObject = names.nextElement(); if (nameObject instanceof String) { name = (String) nameObject; props.setProperty(name, System.getProperty("XMLIngester." + name, props.getProperty(name))); } } }
From source file:org.cloudfoundry.identity.uaa.config.EnvironmentMapFactoryBeanTests.java
private Map<String, ?> getProperties(String input) { HashMap<String, Object> result = new HashMap<String, Object>(); Properties properties = StringUtils .splitArrayElementsIntoProperties(StringUtils.commaDelimitedListToStringArray(input), "="); for (Enumeration<?> keys = properties.propertyNames(); keys.hasMoreElements();) { String key = (String) keys.nextElement(); result.put(key, properties.getProperty(key)); }//w w w.j a va2s . c o m return result; }
From source file:com.conversantmedia.mapreduce.tool.PosixParserRequiredProps.java
@Override protected void processProperties(Properties properties) { super.processProperties(properties); if (properties == null) { return;//w w w.j a va 2 s.c o m } for (Enumeration<?> e = properties.propertyNames(); e.hasMoreElements();) { String option = e.nextElement().toString(); if (cmd.hasOption(option)) { Option opt = getOptions().getOption(option); this.getRequiredOptions().remove(opt.getOpt()); } } }
From source file:org.apache.stratos.metadataservice.registry.CarbonRegistry.java
/** * Get Properties of clustor/*w w w .ja v a 2s.c om*/ * @param applicationName * @param clusterId * @return * @throws RegistryException */ public List<NewProperty> getPropertiesOfCluster(String applicationName, String clusterId) throws RegistryException { Registry tempRegistry = getGovernanceUserRegistry(); String resourcePath = mainResource + applicationName + "/" + clusterId; if (!tempRegistry.resourceExists(resourcePath)) { return null; //throw new RegistryException("Cluster does not exist at " + resourcePath); } Resource regResource = tempRegistry.get(resourcePath); ArrayList<NewProperty> newProperties = new ArrayList<NewProperty>(); Properties props = regResource.getProperties(); Enumeration<?> x = props.propertyNames(); while (x.hasMoreElements()) { String key = (String) x.nextElement(); List<String> values = regResource.getPropertyValues(key); NewProperty property = new NewProperty(); property.setKey(key); String[] valueArr = new String[values.size()]; property.setValues(values.toArray(valueArr)); newProperties.add(property); } return newProperties; }
From source file:org.wso2.carbon.metrics.impl.MetricsLevelConfiguration.java
private void setLevels(Properties properties) { rootLevel = Level.toLevel(properties.getProperty(METRICS_ROOT_LEVEL, Level.OFF.name()).trim(), Level.OFF); Enumeration<?> enumeration = properties.propertyNames(); while (enumeration.hasMoreElements()) { String key = (String) enumeration.nextElement(); if (key.startsWith(METRIC_LEVEL_PREFIX)) { String metricName = key.substring(METRIC_LEVEL_PREFIX.length()); String value = properties.getProperty(key); if (value != null) { levelMap.put(metricName, Level.toLevel(value.trim(), Level.OFF)); }//from ww w. j a v a 2 s. co m } } }
From source file:mitm.common.properties.PropertiesResolver.java
/** * Resolves special property value types (for example a property that starts with file:// is converted the * the actual file content).//from w w w . ja va 2 s . c o m * * Currently only file: binding is supported */ public void resolve(Properties properties) throws PropertiesResolverException { Enumeration<?> propertyNamesEnum = properties.propertyNames(); while (propertyNamesEnum.hasMoreElements()) { Object obj = propertyNamesEnum.nextElement(); if (!(obj instanceof String)) { continue; } String key = (String) obj; String value = properties.getProperty(key); if (value == null) { continue; } int index = value.indexOf(SCHEMA_SEPARATOR); if (index == -1) { continue; } String binding = StringUtils.substring(value, 0, index).trim(); String toResolve = StringUtils.substring(value, index + SCHEMA_SEPARATOR.length()); if (FILE_SCHEMA.equalsIgnoreCase(binding)) { File file = new File(baseDir, toResolve); try { String resolved = FileUtils.readFileToString(file, CharacterEncoding.UTF_8); properties.setProperty(key, resolved); } catch (IOException e) { String canonicalPath = toResolve; try { canonicalPath = file.getCanonicalPath(); } catch (IOException ioe) { logger.error("Error getting canonical path.", ioe); } throw new PropertiesResolverException("Could not resolve file " + canonicalPath, e); } } else if (LITERAL_SCHEMA.equalsIgnoreCase(binding)) { /* * with literal binding the value after the binding should be taken * literal. */ properties.setProperty(key, toResolve); } else { throw new PropertiesResolverException("Unknown binding " + binding); } } }
From source file:org.jfrog.hudson.AbstractBuildInfoDeployer.java
private void addSystemVariables(BuildInfoBuilder builder, IncludeExcludePatterns patterns) { Properties systemProperties = System.getProperties(); Enumeration<?> enumeration = systemProperties.propertyNames(); while (enumeration.hasMoreElements()) { String propertyKey = (String) enumeration.nextElement(); if (PatternMatcher.pathConflicts(propertyKey, patterns)) { continue; }// w w w.j a v a 2s .c o m builder.addProperty(propertyKey, systemProperties.getProperty(propertyKey)); } }