List of usage examples for java.util Properties keys
@Override
public Enumeration<Object> keys()
From source file:org.jboss.dashboard.ui.utils.javascriptUtils.JavascriptTree.java
public static String replaceAll(String value, Properties properties) { for (Enumeration en = properties.keys(); en.hasMoreElements();) { String key = (String) en.nextElement(); String val = properties.getProperty(key); value = StringUtil.replaceAll(value, key, val); }//ww w. j a va 2 s . c om return value; }
From source file:tufts.oki.dr.fedora.DR.java
public static String getMetadataString(Properties dcFields) { String metadata = ""; Enumeration e = dcFields.keys(); while (e.hasMoreElements()) { String field = (String) e.nextElement(); if (isSupportedMetadataField(field)) metadata += "<" + DC_NAMESPACE + field + ">" + dcFields.getProperty(field) + "</" + DC_NAMESPACE + field + ">"; }//from w ww .j a v a2 s.c o m return metadata; }
From source file:org.eclipse.gemini.blueprint.test.internal.util.PropertiesUtil.java
/** * Filter/Eliminate keys that start with the given prefix. * /*from w ww . j a va2s .c om*/ * @param properties * @param prefix * @return */ public static Properties filterKeysStartingWith(Properties properties, String prefix) { if (!StringUtils.hasText(prefix)) return EMPTY_PROPERTIES; Assert.notNull(properties); Properties excluded = (properties instanceof OrderedProperties ? new OrderedProperties() : new Properties()); // filter ignore keys out for (Enumeration enm = properties.keys(); enm.hasMoreElements();) { String key = (String) enm.nextElement(); if (key.startsWith(prefix)) { excluded.put(key, properties.get(key)); } } for (Enumeration enm = excluded.keys(); enm.hasMoreElements();) { properties.remove(enm.nextElement()); } return excluded; }
From source file:com.halseyburgund.roundware.server.RWHttpManager.java
public static String doGet(String page, Properties props) throws Exception { HttpParams httpParams = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpParams, CONNECTION_TIMEOUT_MSEC); HttpConnectionParams.setSoTimeout(httpParams, CONNECTION_TIMEOUT_MSEC); HttpClient httpClient = new DefaultHttpClient(httpParams); StringBuilder uriBuilder = new StringBuilder(page); StringBuffer sbResponse = new StringBuffer(); Enumeration<Object> enumProps = props.keys(); String key, value = null;/* w ww . j a v a2s . c o m*/ uriBuilder.append('?'); while (enumProps.hasMoreElements()) { key = enumProps.nextElement().toString(); value = props.get(key).toString(); uriBuilder.append(key); uriBuilder.append('='); uriBuilder.append(java.net.URLEncoder.encode(value)); if (enumProps.hasMoreElements()) { uriBuilder.append('&'); } } if (D) { RWHtmlLog.i(TAG, "GET request: " + uriBuilder.toString(), null); } HttpGet request = new HttpGet(uriBuilder.toString()); HttpResponse response = httpClient.execute(request); int status = response.getStatusLine().getStatusCode(); // we assume that the response body contains the error message if (status != HttpStatus.SC_OK) { ByteArrayOutputStream ostream = new ByteArrayOutputStream(); response.getEntity().writeTo(ostream); RWHtmlLog.e(TAG, "GET ERROR: " + ostream.toString(), null); throw new Exception(HTTP_POST_FAILED + status); } else { InputStream content = response.getEntity().getContent(); BufferedReader reader = new BufferedReader(new InputStreamReader(content)); String line; while ((line = reader.readLine()) != null) { sbResponse.append(line); } content.close(); // this will also close the connection } if (D) { RWHtmlLog.i(TAG, "GET response: " + sbResponse.toString(), null); } return sbResponse.toString(); }
From source file:com.halseyburgund.rwframework.core.RWHttpManager.java
public static String doGet(String page, Properties props, int timeOutSec) throws Exception { HttpParams httpParams = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpParams, timeOutSec * 1000); HttpConnectionParams.setSoTimeout(httpParams, timeOutSec * 1000); HttpClient httpClient = new DefaultHttpClient(httpParams); StringBuilder uriBuilder = new StringBuilder(page); StringBuffer sbResponse = new StringBuffer(); Enumeration<Object> enumProps = props.keys(); String key, value = null;// w w w .ja va 2s . c o m uriBuilder.append('?'); while (enumProps.hasMoreElements()) { key = enumProps.nextElement().toString(); value = props.get(key).toString(); uriBuilder.append(key); uriBuilder.append('='); uriBuilder.append(java.net.URLEncoder.encode(value)); if (enumProps.hasMoreElements()) { uriBuilder.append('&'); } } if (D) { Log.d(TAG, "GET request: " + uriBuilder.toString(), null); } HttpGet request = new HttpGet(uriBuilder.toString()); HttpResponse response = httpClient.execute(request); int status = response.getStatusLine().getStatusCode(); // we assume that the response body contains the error message if (status != HttpStatus.SC_OK) { ByteArrayOutputStream ostream = new ByteArrayOutputStream(); response.getEntity().writeTo(ostream); Log.e(TAG, "GET ERROR: " + ostream.toString(), null); throw new HttpException(String.valueOf(status)); } else { InputStream content = response.getEntity().getContent(); BufferedReader reader = new BufferedReader(new InputStreamReader(content)); String line; while ((line = reader.readLine()) != null) { sbResponse.append(line); } content.close(); // this will also close the connection } if (D) { Log.d(TAG, "GET response: " + sbResponse.toString(), null); } return sbResponse.toString(); }
From source file:no.joachimhs.server.JettyServer.java
private static void configure() throws Exception { Properties properties = new Properties(); File configFile = new File("config.properties"); if (!configFile.exists()) { configFile = new File("../config.properties"); }/*from www .j a v a 2s . co m*/ if (!configFile.exists()) { configFile = new File("../../config.properties"); } if (configFile.exists()) { FileInputStream configStream = new FileInputStream(configFile); properties.load(configStream); configStream.close(); log.info("Server properties loaded from " + configFile.getAbsolutePath()); for (Enumeration<Object> e = properties.keys(); e.hasMoreElements();) { Object property = (String) e.nextElement(); log.info("\t\t* " + property + "=" + properties.get(property)); } } setProperties(properties); Integer port = IntegerParser.parseIntegerFromString(System.getProperty("jetty.port"), 8080); Integer maxThreads = IntegerParser.parseIntegerFromString(System.getProperty("jetty.maxThreads"), 768); jettyServer = new Server(); log.info("Starting connector on port: " + port); log.info("Maximum threads configured: " + maxThreads); SelectChannelConnector webConnector = new SelectChannelConnector(); webConnector.setPort(port); webConnector.setThreadPool(new QueuedThreadPool(maxThreads)); jettyServer.addConnector(webConnector); //MBeanContainer mbContainer=new MBeanContainer(ManagementFactory.getPlatformMBeanServer()); //jettyServer.getContainer().addEventListener(mbContainer); //jettyServer.addBean(mbContainer); //mbContainer.addBean(log); setWebAppContext(); }
From source file:com.adobe.aem.demomachine.gui.AemDemoUtils.java
public static int[] getDemoAddons(File buildFile) { List<Integer> listIndices = new ArrayList<Integer>(); Properties defaultProps = loadProperties( buildFile.getParentFile().getAbsolutePath() + File.separator + "build.properties"); Properties personalProps = loadProperties(buildFile.getParentFile().getAbsolutePath() + File.separator + "conf" + File.separator + "build-personal.properties"); @SuppressWarnings("serial") Properties sortedProps = new Properties() { @Override/*from w w w. j av a2 s . c o m*/ public synchronized Enumeration<Object> keys() { return Collections.enumeration(new TreeSet<Object>(super.keySet())); } }; sortedProps.putAll(defaultProps); // Looping through all possible options Enumeration<?> e = sortedProps.keys(); int currentIndice = 0; while (e.hasMoreElements()) { String key = (String) e.nextElement(); if (key.startsWith("demo.addons.") & !(key.endsWith("help") || key.endsWith("label"))) { String value = sortedProps.getProperty(key); if (personalProps.containsKey(key)) { value = personalProps.getProperty(key); } if (value.equals("true")) { listIndices.add(currentIndice); } currentIndice = currentIndice + 1; } } int[] array = new int[listIndices.size()]; for (int i = 0; i < listIndices.size(); i++) array[i] = listIndices.get(i); return array; }
From source file:com.adobe.aem.demomachine.gui.AemDemoUtils.java
public static AemDemoProperty[] listDemoAddons(File buildFile) { List<AemDemoProperty> addons = new ArrayList<AemDemoProperty>(); Properties defaultProps = loadProperties( buildFile.getParentFile().getAbsolutePath() + File.separator + "build.properties"); @SuppressWarnings("serial") Properties sortedProps = new Properties() { @Override/*from w w w . ja va 2 s . co m*/ public synchronized Enumeration<Object> keys() { return Collections.enumeration(new TreeSet<Object>(super.keySet())); } }; sortedProps.putAll(defaultProps); // Looping through all possible options Enumeration<?> e = sortedProps.keys(); // List of paths to demo packages List<String[]> listPaths = Arrays.asList(AemDemoConstants.demoPaths); while (e.hasMoreElements()) { String key = (String) e.nextElement(); if (key.startsWith("demo.addons.") & !(key.endsWith("help") || key.endsWith("label"))) { String newKey = key.substring(1 + key.lastIndexOf(".")); // Check if downloads are required boolean downloadRequired = false; for (String[] path : listPaths) { if (path.length == 5 && path[4] != null && path[4].equals(newKey)) { File pathFolder = new File(buildFile.getParentFile().getAbsolutePath() + (path[1].length() > 0 ? (File.separator + path[1]) : "")); if (!pathFolder.exists()) { downloadRequired = true; } } } addons.add(new AemDemoProperty(newKey, sortedProps.getProperty(key + ".label") + (downloadRequired ? " (*)" : ""))); } } AemDemoProperty[] aemPropertyArray = new AemDemoProperty[addons.size()]; addons.toArray(aemPropertyArray); return aemPropertyArray; }
From source file:com.halseyburgund.roundware.server.RWHttpManager.java
public static String doPost(String page, Properties props) throws Exception { HttpParams httpParams = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpParams, CONNECTION_TIMEOUT_MSEC); HttpConnectionParams.setSoTimeout(httpParams, CONNECTION_TIMEOUT_MSEC); HttpClient httpClient = new DefaultHttpClient(httpParams); HttpPost request = new HttpPost(page); HttpResponse response = null;/*ww w. j a v a 2 s . c o m*/ HttpEntity entity = null; StringBuffer sbResponse = new StringBuffer(); Enumeration<Object> enumProps = props.keys(); String key, value = null; List<NameValuePair> nvps = new ArrayList<NameValuePair>(); while (enumProps.hasMoreElements()) { key = (String) enumProps.nextElement(); value = (String) props.get(key); nvps.add(new BasicNameValuePair(key, value)); } UrlEncodedFormEntity uf = new UrlEncodedFormEntity(nvps, HTTP.UTF_8); request.setEntity(uf); request.setHeader("Content-Type", POST_MIME_TYPE); // Post, check and show the result (not really spectacular, but works): response = httpClient.execute(request); entity = response.getEntity(); int status = response.getStatusLine().getStatusCode(); // we assume that the response body contains the error message if (status != HttpStatus.SC_OK) { ByteArrayOutputStream ostream = new ByteArrayOutputStream(); entity.writeTo(ostream); RWHtmlLog.e(TAG, "Error status code = " + status, null); RWHtmlLog.e(TAG, ostream.toString(), null); throw new Exception(HTTP_POST_FAILED + status); } else { InputStream content = response.getEntity().getContent(); // <consume response> BufferedReader reader = new BufferedReader(new InputStreamReader(content)); String line; while ((line = reader.readLine()) != null) sbResponse.append(line); content.close(); // this will also close the connection return sbResponse.toString(); } }
From source file:org.globus.common.CoGProperties.java
public static void fixSpace(Properties p) { // this will get rid off the trailing spaces String key, value;//from w ww . j ava 2 s . c o m Enumeration e = p.keys(); while (e.hasMoreElements()) { key = e.nextElement().toString(); value = p.getProperty(key); p.put(key, value.trim()); } }