List of usage examples for java.util Properties keys
@Override
public Enumeration<Object> keys()
From source file:com.pactera.edg.am.metamanager.extractor.util.Utils.java
public static String transformName(String name) { try {/* w w w . java 2s . c o m*/ Properties properties = TransformConfLoader.getProperties(); StringBuffer sb = new StringBuffer(); for (Enumeration<Object> enumer = properties.keys(); enumer.hasMoreElements();) { // ????? Object expression = enumer.nextElement(); Pattern regex = Pattern.compile((String) expression); Matcher regexMatcher = regex.matcher(name); // ????? String targetExpression = (String) properties.get(expression); if (regexMatcher.find()) { // ???? regexMatcher.appendReplacement(sb, targetExpression); // ? if (log.isDebugEnabled()) { log.debug(new StringBuilder("????:").append(name).append(" ????:") .append(sb).toString()); } return sb.toString(); } } } catch (Exception e) { log.warn("????!????:" + name, e); } return name; }
From source file:org.sonar.core.config.ConfigurationUtils.java
public static Properties interpolateVariables(Properties properties, Map<String, String> variables) { Properties result = new Properties(); Enumeration keys = properties.keys(); while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); String value = (String) properties.get(key); String interpolatedValue = StrSubstitutor.replace(value, variables, "${env:", "}"); result.setProperty(key, interpolatedValue); }//from ww w .ja v a2 s . c o m return result; }
From source file:no.joachimhs.server.JettyServer.java
private static void setProperties(Properties properties) { Enumeration<Object> propEnum = properties.keys(); while (propEnum.hasMoreElements()) { String property = (String) propEnum.nextElement(); System.setProperty(property, properties.getProperty(property)); }//from w w w . jav a 2 s . c o m if (System.getProperty("jetty.port") == null) { System.setProperty("jetty.port", "8080"); log.info( " * Property 'jetty.port' is not specified. Using default: 8080. Configure in file config.properties."); } if (System.getProperty("jetty.maxThreads") == null) { System.setProperty("jetty.maxThreads", "150"); log.info( " * Property 'jetty.maxThreads' is not specified. Using default: 150 Configure in file config.properties."); } if (System.getProperty("context.root") == null) { System.setProperty("context.root", ""); log.info( " * Property 'context.root' is not specified. Using default: '' Configure in file config.properties."); } }
From source file:com.bluexml.tools.miscellaneous.Translate.java
protected static TreeMap<String, String> loadProperties(File input) throws FileNotFoundException, IOException { TreeMap<String, String> map = new TreeMap<String, String>(); Properties props = new Properties(); FileInputStream fin = new FileInputStream(input); props.load(fin);/*from w w w . jav a 2 s . c o m*/ Enumeration<Object> keys = props.keys(); while (keys.hasMoreElements()) { String nextElement = (String) keys.nextElement(); String property = props.getProperty(nextElement); map.put(nextElement, property); } return map; }
From source file:com.glaf.core.config.Environment.java
public static Properties getSystemPropertiesByName(String name) { Properties props = systemProperties.get(name); Properties p = new Properties(); Enumeration<?> e = props.keys(); while (e.hasMoreElements()) { String key = (String) e.nextElement(); String value = props.getProperty(key); p.put(key, value);// w ww. j av a 2 s . co m } return p; }
From source file:com.twitter.ambrose.model.hadoop.MapReduceHelper.java
public static Configuration toConfiguration(Properties properties) { assert properties != null; final Configuration config = new Configuration(false); final Enumeration<Object> iter = properties.keys(); while (iter.hasMoreElements()) { final String key = (String) iter.nextElement(); final String val = properties.getProperty(key); config.set(key, val); }/* www. jav a2 s .co m*/ return config; }
From source file:org.apache.hadoop.hdfs.server.namenode.Namenode2Agent.java
/** * ? Key Value ? Key ?? ? ./* w w w. jav a 2 s. c o m*/ * * @param props {@link Properties} * @return Key ? ? ?? ? */ private static int getMaxLength(Properties props) { Enumeration<Object> keys = props.keys(); int maxLength = -1; while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); if (maxLength < 0) { maxLength = key.getBytes().length; } else if (maxLength < key.getBytes().length) { maxLength = key.getBytes().length; } } return maxLength; }
From source file:com.taobao.itest.util.PropertiesUtil.java
/** * The properties file key-value information into a Map, if the key contains * a underline into the next hump style change * /*from w w w. ja v a 2 s. com*/ * @param resourceName * @param characterSet * @return * @throws IOException */ public static Map<String, String> loadProperties(String resourceName, String characterSet) { Properties properties; Map<String, String> paramsMap = Collections.synchronizedMap(new CamelCasingHashMap<String, String>()); try { properties = PropertiesLoaderUtils.loadAllProperties(resourceName); for (Enumeration<?> keys = properties.keys(); keys.hasMoreElements();) { String key = (String) keys.nextElement(); paramsMap.put(key, getValue(properties.getProperty(key).trim(), characterSet)); } } catch (Exception e) { e.printStackTrace(); } return paramsMap; }
From source file:com.glaf.core.config.ViewProperties.java
public static void reload() { if (!loading.get()) { InputStream inputStream = null; try {//from w w w .j ava 2s . c om loading.set(true); String config = SystemProperties.getConfigRootPath() + "/conf/props/views"; File directory = new File(config); if (directory.exists() && directory.isDirectory()) { String[] filelist = directory.list(); if (filelist != null) { for (int i = 0, len = filelist.length; i < len; i++) { String filename = config + "/" + filelist[i]; File file = new File(filename); if (file.isFile() && file.getName().endsWith(".properties")) { inputStream = new FileInputStream(file); Properties p = PropertiesUtils.loadProperties(inputStream); if (p != null) { Enumeration<?> e = p.keys(); while (e.hasMoreElements()) { String key = (String) e.nextElement(); String value = p.getProperty(key); properties.setProperty(key, value); properties.setProperty(key.toLowerCase(), value); properties.setProperty(key.toUpperCase(), value); } } IOUtils.closeStream(inputStream); } } } } } catch (Exception ex) { throw new RuntimeException(ex); } finally { loading.set(false); IOUtils.closeStream(inputStream); } } }
From source file:com.mindcognition.mindraider.MindRaiderApplication.java
/** * Debug.// w ww . j av a2 s . c om */ public static void debug() { Properties properties = System.getProperties(); Enumeration<Object> propertyNames = properties.keys(); if (properties.size() > 0) { logger.debug(" Properties debug (" + properties.size() + "):"); //$NON-NLS-1$ //$NON-NLS-2$ String element = null; while (propertyNames.hasMoreElements()) { element = (String) propertyNames.nextElement(); if (element.startsWith(MindRaiderConstants.MR)) { logger.debug(" " + element + ": " //$NON-NLS-1$ //$NON-NLS-2$ + System.getProperty(element)); } } logger.debug(" - done -"); //$NON-NLS-1$ } }