Search in sources :

Example 21 with Enumeration

use of java.util.Enumeration in project Fling by entertailion.

the class HttpServer method serve.

// ==================================================
// API parts
// ==================================================
/**
	 * Override this to customize the server.
	 * <p>
	 * 
	 * (By default, this delegates to serveFile() and allows directory listing.)
	 * 
	 * @param uri
	 *            Percent-decoded URI without parameters, for example
	 *            "/index.cgi"
	 * @param method
	 *            "GET", "POST" etc.
	 * @param parms
	 *            Parsed, percent decoded parameters from URI and, in case of
	 *            POST, data.
	 * @param header
	 *            Header entries, percent decoded
	 * @return HTTP response, see class Response for details
	 */
public Response serve(String uri, String method, Properties header, Properties parms, Properties files) {
    System.out.println(method + " '" + uri + "' ");
    Enumeration e = header.propertyNames();
    while (e.hasMoreElements()) {
        String value = (String) e.nextElement();
        System.out.println("  HDR: '" + value + "' = '" + header.getProperty(value) + "'");
    }
    e = parms.propertyNames();
    while (e.hasMoreElements()) {
        String value = (String) e.nextElement();
        System.out.println("  PRM: '" + value + "' = '" + parms.getProperty(value) + "'");
    }
    e = files.propertyNames();
    while (e.hasMoreElements()) {
        String value = (String) e.nextElement();
        System.out.println("  UPLOADED: '" + value + "' = '" + files.getProperty(value) + "'");
    }
    return serveFile(uri, header, new File("."), true);
}
Also used : Enumeration(java.util.Enumeration) File(java.io.File)

Example 22 with Enumeration

use of java.util.Enumeration in project vert.x by eclipse.

the class StarterTest method clearProperties.

private void clearProperties() {
    Set<String> toClear = new HashSet<>();
    Enumeration e = System.getProperties().propertyNames();
    // Uhh, properties suck
    while (e.hasMoreElements()) {
        String propName = (String) e.nextElement();
        if (propName.startsWith("vertx.options")) {
            toClear.add(propName);
        }
    }
    for (String propName : toClear) {
        System.clearProperty(propName);
    }
}
Also used : Enumeration(java.util.Enumeration) HashSet(java.util.HashSet)

Example 23 with Enumeration

use of java.util.Enumeration in project android_frameworks_base by ParanoidAndroid.

the class TestCaseUtil method getTests.

private static List<? extends Test> getTests(Test test, boolean flatten, Set<Class<?>> seen) {
    List<Test> testCases = Lists.newArrayList();
    if (test != null) {
        Test workingTest = null;
        /*
             * If we want to run a single TestCase method only, we must not
             * invoke the suite() method, because we will run all test methods
             * of the class then.
             */
        if (test instanceof TestCase && ((TestCase) test).getName() == null) {
            workingTest = invokeSuiteMethodIfPossible(test.getClass(), seen);
        }
        if (workingTest == null) {
            workingTest = test;
        }
        if (workingTest instanceof TestSuite) {
            TestSuite testSuite = (TestSuite) workingTest;
            Enumeration enumeration = testSuite.tests();
            while (enumeration.hasMoreElements()) {
                Test childTest = (Test) enumeration.nextElement();
                if (flatten) {
                    testCases.addAll(getTests(childTest, flatten, seen));
                } else {
                    testCases.add(childTest);
                }
            }
        } else {
            testCases.add(workingTest);
        }
    }
    return testCases;
}
Also used : Enumeration(java.util.Enumeration) TestSuite(junit.framework.TestSuite) Test(junit.framework.Test) TestCase(junit.framework.TestCase)

Example 24 with Enumeration

use of java.util.Enumeration in project android_frameworks_base by ParanoidAndroid.

the class TestCaseUtil method getTestAtIndex.

public static Test getTestAtIndex(TestSuite testSuite, int position) {
    int index = 0;
    Enumeration enumeration = testSuite.tests();
    while (enumeration.hasMoreElements()) {
        Test test = (Test) enumeration.nextElement();
        if (index == position) {
            return test;
        }
        index++;
    }
    return null;
}
Also used : Enumeration(java.util.Enumeration) Test(junit.framework.Test)

Example 25 with Enumeration

use of java.util.Enumeration in project sonarqube by SonarSource.

the class ConfigurationUtils method interpolateVariables.

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);
    }
    return result;
}
Also used : Enumeration(java.util.Enumeration) Properties(java.util.Properties)

Aggregations

Enumeration (java.util.Enumeration)1179 IOException (java.io.IOException)202 ArrayList (java.util.ArrayList)141 File (java.io.File)102 HashMap (java.util.HashMap)86 Properties (java.util.Properties)85 Vector (java.util.Vector)83 List (java.util.List)77 HashSet (java.util.HashSet)65 Hashtable (java.util.Hashtable)63 Map (java.util.Map)59 Set (java.util.Set)59 URL (java.net.URL)57 ZipEntry (java.util.zip.ZipEntry)55 ServletContext (javax.servlet.ServletContext)53 Iterator (java.util.Iterator)50 InputStream (java.io.InputStream)47 ZipFile (java.util.zip.ZipFile)46 FileInputStream (java.io.FileInputStream)40 X509Certificate (java.security.cert.X509Certificate)37