List of usage examples for java.util Properties keySet
@Override
public Set<Object> keySet()
From source file:info.magnolia.importexport.PropertiesImportExport.java
public static String dumpPropertiesToString(Properties properties) { final StringBuilder sb = new StringBuilder(); final Set<Object> propertyNames = properties.keySet(); for (Object propertyKey : propertyNames) { final String name = propertyKey.toString(); final String value = properties.getProperty(name); sb.append(name);/*from w w w . ja va 2s . c o m*/ sb.append("="); sb.append(value); sb.append("\n"); } return sb.toString(); }
From source file:edu.ku.brc.af.core.UsageTracker.java
/** * Transfers and removes any old statistics from the user prefs to the new location. * @param newProps the new statistics/* w ww.j av a 2 s . c o m*/ */ private static void transferOldStats(final Properties newProps) { Properties lpProps = AppPreferences.getLocalPrefs().getProperties(); // not a copy for (Object keyObj : new Vector<Object>(lpProps.keySet())) { String pName = keyObj.toString(); if (pName.startsWith(USAGE_PREFIX)) { newProps.put(pName.substring(6), lpProps.get(keyObj)); lpProps.remove(keyObj); } } save(); }
From source file:com.savoirfairelinux.jmeter.openstack.test.AbstractOpenstackSamplerTest.java
@BeforeClass public static void prepare() throws Exception { // load configuration configuration = new Properties(); InputStream inputStream = AbstractOpenstackSamplerTest.class.getClassLoader() .getResourceAsStream("configuration.properties"); if (inputStream != null) configuration.load(inputStream); // load arguments arguments = new Arguments(); Properties argumentsProps = new Properties(); inputStream = AbstractOpenstackSamplerTest.class.getClassLoader() .getResourceAsStream("arguments.properties"); if (inputStream != null) argumentsProps.load(inputStream); for (Object key : argumentsProps.keySet()) arguments.addArgument((String) key, argumentsProps.getProperty((String) key)); // setup JMeter JMeterUtils.loadJMeterProperties(""); // handle user defined global configuration for (Object key : configuration.keySet()) { String keyStr = (String) key; // set JVM properties if (keyStr.startsWith("jvm.")) System.setProperty(keyStr.replaceFirst("^jvm\\.", ""), configuration.getProperty(keyStr)); // set JMeter properties else if (keyStr.startsWith("jmeter.")) JMeterUtils.setProperty(keyStr.replaceFirst("^jmeter\\.", ""), configuration.getProperty(keyStr)); }//from w w w . ja v a 2s. c o m // disable stdout before the logging is correctly setup CustomStdOut customStdOut = new CustomStdOut(System.out); customStdOut.setEnabled(false); System.setOut(customStdOut); // initialize logging and locale JMeterUtils.initLogging(); JMeterUtils.initLocale(); // workaround to disable Jersey warning java.util.logging.Logger.getLogger("").setLevel(Level.SEVERE); // re-enable stdout customStdOut.setEnabled(true); }
From source file:de.pawlidi.openaletheia.utils.CipherUtils.java
/** * //from w ww .j av a2s.co m * @param properties * @return */ public static byte[] computeSignature(Properties properties) { if (properties != null && !properties.isEmpty()) { StringBuilder builder = new StringBuilder(); ArrayList keys = new ArrayList<Object>(properties.keySet()); Collections.sort(keys); for (Object key : keys) { Object value = properties.get(key); if (value != null) { builder.append(key); builder.append("="); builder.append(value); builder.append("\n"); } } String pattern = builder.toString(); if (!pattern.isEmpty()) { return computeSignature(Converter.getBytesIso8859(pattern)); } } return null; }
From source file:com.pactera.edg.am.metamanager.extractor.util.AdapterContextLoader.java
/** * //from ww w .j a v a 2 s . c om * SpringClassPathXMLApplicationContext,????${var} * prop??? ??.properties??,??${var} * * @param configLocations * application context? * @param props * ??application context????key/value * @return ApplicationContext Application * Context,?,??,bean,null * @exception */ public static ApplicationContext createApplicationContext(String[] configLocations, Properties props) { // :spring?system properties??. Properties bakProps = null; String logMsg = null; try { if (props != null && props.size() > 0) { // system properties bakProps = System.getProperties(); for (Object key : props.keySet()) { System.setProperty((String) key, props.getProperty((String) key)); } if (log.isDebugEnabled()) { StringBuffer sb = new StringBuffer(); sb.append("??springxml?${var}prop:\n"); for (Object key : props.keySet()) { sb.append(key + "=" + System.getProperty((String) key)); sb.append("\n"); } log.debug(sb.toString()); } } return new ClassPathXmlApplicationContext(configLocations); } catch (BeanDefinitionStoreException bse) { // logMsg = new StringBuilder("?spring,?") .append(Arrays.toString(configLocations)).append(bse.getMessage()).toString(); log.error(logMsg, bse); AdapterExtractorContext.addExtractorLog(ExtractorLogLevel.ERROR, logMsg); throw bse; } catch (BeanCreationException ce) { // BEAN,?RMI?? logMsg = new StringBuilder("?spring,?BEAN,") .append(Arrays.toString(configLocations)).append(ce.getMessage()).toString(); log.error(logMsg, ce); if (logMsg.indexOf("ORA-01017") > -1 || logMsg.indexOf("Invalid password") > -1) { // ORACLE???? AdapterExtractorContext.addExtractorLog(ExtractorLogLevel.ERROR, "??/?,?,???????!"); } else { AdapterExtractorContext.addExtractorLog(ExtractorLogLevel.ERROR, logMsg); } throw ce; } finally { // system properties,???,?? if (bakProps != null) { System.setProperties(bakProps); } } }
From source file:com.attilax.zip.FileUtil.java
/** * ??Map//from ww w. j a va2 s . co m * * @param propertiesFile * @return * @throws Exception */ public static final Map<String, String> getPropertiesMap(String propertiesFile) throws Exception { Properties properties = new Properties(); FileInputStream inputStream = new FileInputStream(propertiesFile); 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.joliciel.talismane.utils.PerformanceMonitor.java
/** * Must be called at start of the application run.<br/> * Uses a config properties file.<br/> * Lines starting with # will be skipped. * @throws IOException /*from w w w. j a v a2 s . co m*/ */ public static void start(File configFile) { try { if (configFile == null) return; Properties props = new Properties(); props.load(new FileReader(configFile)); for (Object keyObj : props.keySet()) { String key = (String) keyObj; if (key.equals(ALL_ACTIVE)) { boolean active = props.getProperty(key).equalsIgnoreCase("true"); activated = active; } else if (key.equals(DEFAULT_ACTIVE)) { boolean active = props.getProperty(key).equalsIgnoreCase("true"); defaultActive = active; } else if (key.startsWith(ACTIVE_PREFIX)) { String name = key.substring(ACTIVE_PREFIX.length()); boolean active = props.getProperty(key).equalsIgnoreCase("true"); activeMonitors.put(name, active); } } rootMonitor = new PerformanceMonitor("[[ROOT]]", "ROOT"); rootMonitor.setActive(true); if (monitors.size() > 0) { for (PerformanceMonitor monitor : monitors.values()) { monitor.updateActive(); } } rootMonitor.startTask("root"); decFormat.applyPattern("##0.00"); } catch (IOException e) { LogUtils.logError(LOG, e); throw new RuntimeException(e); } }
From source file:com.alibaba.rocketmq.common.MixAll.java
public static String properties2String(final Properties properties) { Set<Object> sets = properties.keySet(); StringBuilder sb = new StringBuilder(); for (Object key : sets) { Object value = properties.get(key); if (value != null) { sb.append(key.toString() + "=" + value.toString() + IOUtils.LINE_SEPARATOR); }/* w w w .ja va2 s . c o m*/ } return sb.toString(); }
From source file:com.wavemaker.common.util.SystemUtils.java
public static void writePropertiesFile(OutputStream os, Properties props, List<String> includePropertyNames, String comment) {//from w ww . j a v a 2s. c o m try { if (includePropertyNames != null) { Properties p = new Properties(); for (String key : CastUtils.<String>cast(props.keySet())) { if (includePropertyNames.contains(key)) { p.setProperty(key, props.getProperty(key)); } } props = p; } props.store(os, comment); } catch (IOException ex) { throw new RuntimeException(ex); } }
From source file:org.esgf.web.LiveSearchController.java
/** * // w w w. j a va 2s . c o m * @param facet * @return */ private static boolean isFacet(String facet) { boolean isFacet = false; Properties properties = new Properties(); try { properties.load(new FileInputStream(FACET_PROPERTIES_FILE)); for (Object key : properties.keySet()) { String keyStr = (String) key; if (facet.equals(keyStr)) isFacet = true; } } catch (Exception e) { System.out.println("Problem removing all properties"); e.printStackTrace(); } return isFacet; }