List of usage examples for java.util Properties entrySet
@Override
public Set<Map.Entry<Object, Object>> entrySet()
From source file:io.smartspaces.launcher.bootstrap.FileConfigurationProvider.java
/** * Load all conf files in the configuration folder. *///from w ww . ja va 2 s.c om public void load() { // Look in the specified bundle directory to create a list // of all JAR files to install. File[] files = configFolder.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.toLowerCase().endsWith(CONFIGURATION_FILES_EXTENSION); } }); if (files == null || files.length == 0) { log.error(String.format("Couldn't load config files from %s\n", configFolder.getAbsolutePath())); } for (File file : files) { Properties props = new Properties(); try { props.load(new FileInputStream(file)); for (Entry<Object, Object> p : props.entrySet()) { currentConfiguration.put((String) p.getKey(), (String) p.getValue()); } } catch (IOException e) { log.error(String.format("Couldn't load config file %s\n", file)); } } }
From source file:com.turn.splicer.Config.java
public void writeAsJson(JsonGenerator jgen) throws IOException { if (properties == null) { jgen.writeStartObject();/*from ww w .j av a2s . c o m*/ jgen.writeEndObject(); return; } TreeMap<String, String> map = new TreeMap<>(); for (Map.Entry<Object, Object> e : properties.entrySet()) { map.put(String.valueOf(e.getKey()), String.valueOf(e.getValue())); } InputStream is = getClass().getClassLoader().getResourceAsStream(VERSION_FILE); if (is != null) { LOG.debug("Loaded {} bytes of version file configuration", is.available()); Properties versionProps = new Properties(); versionProps.load(is); for (Map.Entry<Object, Object> e : versionProps.entrySet()) { map.put(String.valueOf(e.getKey()), String.valueOf(e.getValue())); } } else { LOG.error("No version file found on classpath. VERSION_FILE={}", VERSION_FILE); } jgen.writeStartObject(); for (Map.Entry<String, String> e : map.entrySet()) { if (e.getValue().indexOf(',') > 0) { splitList(e.getKey(), e.getValue(), jgen); } else { jgen.writeStringField(e.getKey(), e.getValue()); } } jgen.writeEndObject(); }
From source file:de.bloxel.engine.material.ColorBloxelAssetManager.java
/** * @param theAssetManager//from ww w . j ava 2 s .c om * for loading textures etc. */ public ColorBloxelAssetManager(final AssetManager theAssetManager) { this.assetManager = theAssetManager; try { final Properties p = new Properties(); p.load(new ClassPathResource(COLORMAP_PROPERTIES).getInputStream()); final Set<Entry<Object, Object>> definitions = p.entrySet(); for (final Entry<Object, Object> d : definitions) { final Integer bloxelType = Integer.valueOf(d.getKey().toString()); final String value = String.format("%s", d.getValue()); final Iterable<String> rgb = Splitter.on(",").split(value); final float r = Integer.valueOf(Iterables.get(rgb, 0)); final float g = Integer.valueOf(Iterables.get(rgb, 1)); final float b = Integer.valueOf(Iterables.get(rgb, 2)); colormap.put(new MapKey(bloxelType, -1), new ColorRGBA(r, g, b, 1f)); } } catch (final IOException e) { throw new RuntimeException( format("Can't load bloxel definition file '%s' from classpath", COLORMAP_PROPERTIES), e); } theAssetManager.registerLocator("/de/bloxel/engine/material/", ClasspathLocator.class); }
From source file:com.cognifide.qa.bb.logging.reporter.SimpleReporter.java
@Override public void properties(Properties properties) { setStream();//w ww . j a v a2 s . c o m stream.println("Properties:"); Iterator<Entry<Object, Object>> entryIterator = properties.entrySet().iterator(); while (entryIterator.hasNext()) { Entry<Object, Object> entry = entryIterator.next(); stream.println(String.format("%s: %s", entry.getKey(), entry.getValue())); } }
From source file:interactivespaces.launcher.bootstrap.FileConfigurationProvider.java
/** * Load all conf files in the configuration folder. *//*from www. j av a2 s . c o m*/ public void load() { currentConfiguration = new HashMap<String, String>(); // Calculate the proper home directory for this install of interactive spaces. String isHomeEnvPath = System.getenv(INTERACTIVESPACES_HOME_ENVIRONMENT_KEY); File isHomeDir = isHomeEnvPath != null ? new File(isHomeEnvPath) : new File(baseInstallFolder, INTERACTIVESPACES_HOME_DEFAULT_DIR); currentConfiguration.put(CoreConfiguration.CONFIGURATION_INTERACTIVESPACES_HOME, isHomeDir.getAbsolutePath()); // Look in the specified bundle directory to create a list // of all JAR files to install. File[] files = configFolder.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.toLowerCase().endsWith(CONFIGURATION_FILES_EXTENSION); } }); if (files == null || files.length == 0) { log.error(String.format("Couldn't load config files from %s\n", configFolder.getAbsolutePath())); } for (File file : files) { Properties props = new Properties(); try { props.load(new FileInputStream(file)); for (Entry<Object, Object> p : props.entrySet()) { currentConfiguration.put((String) p.getKey(), (String) p.getValue()); } } catch (IOException e) { log.error(String.format("Couldn't load config file %s\n", file)); } } }
From source file:hu.petabyte.redflags.engine.tedintf.MaxNumberDeterminer.java
private void loadMaxNumCache() { try {//w w w. ja v a 2s. co m FileReader r = new FileReader(CACHE_FILENAME); Properties p = new Properties(); p.load(r); for (Entry<Object, Object> e : p.entrySet()) { if (e.getKey().toString().matches("\\d+") && e.getValue().toString().matches("\\d+")) { int y = Integer.valueOf(e.getKey().toString()); int n = Integer.valueOf(e.getValue().toString()); maxNumCache.put(y, n); } } r.close(); LOG.debug("Max number cache loaded: {}", maxNumCache); } catch (IOException e) { LOG.warn("Failed to load max number cache"); LOG.trace("Failed to load max number cache", e); } }
From source file:edu.monash.merc.system.config.SystemPropertyConfigurator.java
@Override protected void processProperties(ConfigurableListableBeanFactory confListBeanFactory, Properties props) throws BeansException { Map<String, String> tmpProps = new HashMap<String, String>(props.size()); super.processProperties(confListBeanFactory, props); for (Map.Entry<Object, Object> entry : props.entrySet()) { tmpProps.put(String.valueOf(entry.getKey()), String.valueOf(entry.getValue())); }/*w ww . j a v a2s . co m*/ this.resolvedProps = Collections.unmodifiableMap(tmpProps); }
From source file:org.apache.flume.client.avro.AvroCLIClient.java
private void parseHeaders(CommandLine commandLine) { String headerFile = commandLine.getOptionValue("headerFile"); FileInputStream fs = null;//from w w w . j a v a2s. c o m try { if (headerFile != null) { fs = new FileInputStream(headerFile); Properties properties = new Properties(); properties.load(fs); for (Map.Entry<Object, Object> propertiesEntry : properties.entrySet()) { String key = (String) propertiesEntry.getKey(); String value = (String) propertiesEntry.getValue(); logger.debug("Inserting Header Key [" + key + "] header value [" + value + "]"); headers.put(key, value); } } } catch (Exception e) { logger.error("Unable to load headerFile", headerFile, e); return; } finally { if (fs != null) { try { fs.close(); } catch (Exception e) { logger.error("Unable to close headerFile", e); return; } } } }
From source file:com.adaptris.core.http.jetty.JettyHashUserRealmVerifier.java
private Map<String, AccessCredentials> loadUsers(Properties properties) throws IOException { Map<String, AccessCredentials> result = new HashMap<>(); for (Map.Entry<Object, Object> entry : properties.entrySet()) { String username = ((String) entry.getKey()).trim(); String credentials = ((String) entry.getValue()).trim(); String roles = null;/* www .j a v a2 s .co m*/ int c = credentials.indexOf(','); if (c >= 0 && credentials.length() > 1) { roles = credentials.substring(c + 1).trim(); credentials = credentials.substring(0, c).trim(); } result.put(username, new AccessCredentials(credentials, roles)); } return result; }
From source file:edu.cornell.med.icb.identifier.IndexedIdentifier.java
/** * Set the current state of the object from a map of properties. * @param propertyMap A map of properties indexed by string key names that can be then * used to reconstruct the object state. */// w w w. jav a2 s.c o m public void fromPropertyMap(final Map<String, Properties> propertyMap) { if (propertyMap == null) { throw new IllegalArgumentException("Property map cannot be null"); } clear(); // reset any previous state // get the values contained in the Id to Index map final Properties id2IndexProperties = propertyMap.get(ID2_INDEX_KEY); if (id2IndexProperties != null) { for (final Map.Entry<Object, Object> entry : id2IndexProperties.entrySet()) { put(new MutableString(entry.getKey().toString()), NumberUtils.toInt(entry.getValue().toString())); } } // get the running index final Properties runningIndexProperties = propertyMap.get(RUNNING_INDEX_KEY); if (runningIndexProperties != null) { runningIndex = NumberUtils.toInt(runningIndexProperties.getProperty(RUNNING_INDEX_KEY)); } else { runningIndex = 0; } }