List of usage examples for java.util Properties keySet
@Override
public Set<Object> keySet()
From source file:org.opennms.ng.dao.support.ResourceTypeUtils.java
private static void loadRrdAttributes(File rrdDirectory, String relativePath, Set<OnmsAttribute> attributes) { int suffixLength = RrdFileConstants.getRrdSuffix().length(); File resourceDir = new File(rrdDirectory, relativePath); File[] files = resourceDir.listFiles(RrdFileConstants.RRD_FILENAME_FILTER); if (files == null) { return;/* ww w.jav a 2 s . c om*/ } for (final File file : files) { String fileName = file.getName(); if (isStoreByGroup() && !isResponseTime(relativePath)) { String groupName = fileName.substring(0, fileName.length() - suffixLength); Properties props = getDsProperties(resourceDir); for (Object o : props.keySet()) { String dsName = (String) o; if (props.getProperty(dsName).equals(groupName)) { attributes.add(new RrdGraphAttribute(dsName, relativePath, fileName)); } } } else { String dsName = fileName.substring(0, fileName.length() - suffixLength); attributes.add(new RrdGraphAttribute(dsName, relativePath, fileName)); } } }
From source file:io.uengine.util.StringUtils.java
/** * Properties? key value ? ./*from w w w . j a v a 2 s. c o m*/ * * @param properties Properties * @return key value ? */ public static String propertiesToString(Properties properties) { StringWriter writer = new StringWriter(); PrintWriter out = new PrintWriter(writer); Set<Object> keys = properties.keySet(); for (Object key : keys) { out.println(key + "=" + properties.get(key)); } return writer.getBuffer().toString(); }
From source file:eu.scidipes.toolkits.pawebapp.util.FrameworkUtils.java
private static void populateMapFromRILProps(final Properties props, final Map<FormType, Map<String, CurationPersistentIdentifier>> rilMap, final FormType key) { final Map<String, CurationPersistentIdentifier> innerMap = new DualTreeBidiMap<>(); for (final Object o : props.keySet()) { final String innerKey = (String) o; try {/*from w ww .j av a 2s. co m*/ final CurationPersistentIdentifier cpid = new CoreCurationPersistentIdentifier( props.getProperty(innerKey)); /* If corresponding RIL does not exist on an enabled registry, the CPID won't be added */ innerMap.put(innerKey, FrameworkWrapper.getRepInfoLabel(cpid).getCpid()); } catch (final RIException e) { LOG.warn(e.getMessage()); } } rilMap.put(key, innerMap); }
From source file:com.davidgildeh.hadoop.utils.FileUtils.java
/** * Given a path to a valid key/value properties file on HDFS, all values will be * loaded into the provided JobConf to provide configuration properties for the * Hadoop Job// w w w .j av a 2 s . co m * * @param jobConf The JobConf to load property values into * @param path The path to the properties file * @return The JobConf with loaded properties values added */ public static JobConf loadJobConf(JobConf jobConf, String path) throws IOException { Properties propFile = loadPropertiesFile(path); // Loop through all properties in properties file for (Object keyObject : propFile.keySet()) { String key = (String) keyObject; String value = propFile.getProperty(key); jobConf.set(key, value); if (LOG.isDebugEnabled()) { LOG.debug("Loaded Configuration Property " + key + ": " + value); } } return jobConf; }
From source file:org.alfresco.bm.test.prop.TestPropertyFactory.java
private static void getPropertyAndProjectNames(Properties properties, Set<String> propNames, Set<String> projectNames) { for (Object propDeclarationObj : properties.keySet()) { String propDeclaration = (String) propDeclarationObj; // Ignore everything that is not a "*.default" property, which marks a true property definition if (!propDeclaration.endsWith(SUFFIX_DEFAULT)) { continue; }//from w w w.j av a 2 s. c om // Find end of project name int projectEndDot = propDeclaration.indexOf('.'); if (projectEndDot < 1) { logger.debug("Ignoring property: " + propDeclaration); continue; } int propDeclarationLen = propDeclaration.length(); int propEndDot = propDeclarationLen - SUFFIX_DEFAULT.length(); // Ignore if there is no substance between the first dot and default suffix e.g. project..default= int propNameStart = projectEndDot + 1; int propNameLen = (propEndDot - projectEndDot) - 1; // Length of characters between dots if (projectEndDot < 0 || propNameLen < 1) { logger.debug("Ignoring property: " + propDeclaration); continue; } String projectName = propDeclaration.substring(0, projectEndDot); String propName = propDeclaration.substring(propNameStart, propEndDot); // Check that the project is inherited at all if (!projectNames.contains(projectName)) { logger.debug("Ignoring property not in project set (" + projectNames + ") : " + propDeclaration); continue; } projectNames.add(projectName); propNames.add(propName); } // Done if (logger.isDebugEnabled()) { logger.debug("All projects: " + projectNames); logger.debug("All properties: " + propNames); } }
From source file:ca.hec.commons.utils.MergePropertiesUtils.java
private static void importNewProps(Properties enProperties, Properties frCAProperties) { Set<Object> enKeys = enProperties.keySet(); System.out.println("#----Start importing-----"); for (Object key : enKeys) { if (!frCAProperties.containsKey(key)) { System.out.println(key + "=---TO TRANSLATE ----" + enProperties.getProperty((String) key)); }// w w w.jav a2s.c o m } System.out.println(); System.out.println(); System.out.println(); }
From source file:com.enonic.cms.framework.util.PropertiesUtil.java
/** * Interpolate properties names like ${..}. *//* w w w. j a v a 2s .c om*/ public static Properties interpolate(final Properties props) { Properties target = new Properties(); Properties source = new Properties(); source.putAll(System.getProperties()); source.putAll(props); StrLookup lookup = StrLookup.mapLookup(source); StrSubstitutor substitutor = new StrSubstitutor(lookup); for (Object key : props.keySet()) { String value = props.getProperty((String) key); try { value = substitutor.replace(value); } catch (IllegalStateException e) { // Do nothing } target.put(key, value); } return target; }
From source file:org.apache.samza.sql.testutil.ConfigUtil.java
/** * Method is used to filter just the properties with the prefix. * @param props Full set of properties// www . j av a 2 s . com * @param prefix Prefix of the keys that in the config that needs to be filtered out. * @param preserveFullKey If set to true, after filtering, preserves the full key including the prefix. * If set to false, Strips out the prefix from the key before returning. * @return Returns the filtered set of properties matching the prefix from the input property bag. */ public static Properties getDomainProperties(Properties props, String prefix, boolean preserveFullKey) { String fullPrefix; if (StringUtils.isBlank(prefix)) { fullPrefix = ""; // this will effectively retrieve all properties } else { fullPrefix = prefix.endsWith(".") ? prefix : prefix + "."; } Properties ret = new Properties(); props.keySet().stream().map(String.class::cast).forEach(keyStr -> { if (keyStr.startsWith(fullPrefix) && !keyStr.equals(fullPrefix)) { if (preserveFullKey) { ret.put(keyStr, props.get(keyStr)); } else { ret.put(keyStr.substring(fullPrefix.length()), props.get(keyStr)); } } }); return ret; }
From source file:com.attilax.zip.FileUtil.java
/** * ??Map//from www . java 2s . c o m * * @param inputStream * @return * @throws Exception */ public static final Map<String, String> getPropertiesMap(InputStream inputStream) throws Exception { Properties properties = new Properties(); properties.load(inputStream); Map<String, String> map = new HashMap<String, String>(); Set<Object> keySet = properties.keySet(); for (Object key : keySet) { map.put((String) key, properties.getProperty((String) key)); } return map; }
From source file:com.kixeye.chassis.bootstrap.configuration.ConfigurationBuilder.java
private static void join(Map<String, Object> base, Properties properties, String propertyFile, String[] propertyFiles) { for (Object key : properties.keySet()) { if (base.get(key) != null) { BootstrapException.moduleKeysConflictFound(propertyFile, propertyFiles); }// ww w . j a v a 2 s . com base.put((String) key, properties.get(key)); } }