Example usage for java.util Collections enumeration

List of usage examples for java.util Collections enumeration

Introduction

In this page you can find the example usage for java.util Collections enumeration.

Prototype

public static <T> Enumeration<T> enumeration(final Collection<T> c) 

Source Link

Document

Returns an enumeration over the specified collection.

Usage

From source file:com.icesoft.faces.webapp.http.servlet.ServletEnvironmentRequest.java

public Enumeration getHeaders(String name) {
    List values = (List) headers.get(name);
    return Collections.enumeration(values);
}

From source file:org.xwiki.portlet.controller.DispatchedRequest.java

/**
 * {@inheritDoc}/*from w ww. java 2s  .  co m*/
 * 
 * @see HttpServletRequestWrapper#getParameterNames()
 */
@SuppressWarnings("unchecked")
@Override
public Enumeration<String> getParameterNames() {
    Set<String> parameterNames = new HashSet<String>();
    if (!redirected) {
        parameterNames.addAll(super.getParameterMap().keySet());
    }
    if (!dispatchParametersStack.isEmpty()) {
        parameterNames.addAll(dispatchParametersStack.peek().keySet());
    }
    return Collections.enumeration(parameterNames);
}

From source file:org.openmrs.util.OpenmrsClassLoader.java

/**
 * @see java.net.URLClassLoader#findResources(java.lang.String)
 *///from  ww  w .  ja va2s  .  c o m
@Override
public Enumeration<URL> findResources(final String name) throws IOException {
    Set<URI> results = new HashSet<URI>();
    for (ModuleClassLoader classLoader : ModuleFactory.getModuleClassLoaders()) {
        Enumeration<URL> urls = classLoader.findResources(name);
        while (urls.hasMoreElements()) {
            URL result = urls.nextElement();
            if (result != null) {
                try {
                    results.add(result.toURI());
                } catch (URISyntaxException e) {
                    throwInvalidURI(result, e);
                }
            }
        }
    }

    for (Enumeration<URL> en = super.findResources(name); en.hasMoreElements();) {
        URL url = en.nextElement();
        try {
            results.add(url.toURI());
        } catch (URISyntaxException e) {
            throwInvalidURI(url, e);
        }
    }

    List<URL> resources = new ArrayList<URL>(results.size());
    for (URI result : results) {
        resources.add(result.toURL());
    }

    return Collections.enumeration(resources);
}

From source file:org.jruby.rack.mock.MockServletContext.java

public Enumeration<Servlet> getServlets() {
    return Collections.enumeration(new HashSet<Servlet>());
}

From source file:cn.dreampie.LessCompiler.java

/**
 * Initializes this <code>LessCompiler</code>.
 * <p>//from www  .  j  a  va2  s .co m
 * It is not needed to call this method manually, as it is called implicitly by the compile methods if needed.
 * </p>
 */
public synchronized void init() {
    long start = System.currentTimeMillis();

    try {
        Context cx = Context.enter();
        //cx.setOptimizationLevel(-1);
        cx.setLanguageVersion(Context.VERSION_1_7);

        Global global = new Global();
        global.init(cx);
        scope = cx.initStandardObjects(global);
        scope.put("logger", scope, Context.toObject(logger, scope));

        out = new ByteArrayOutputStream();
        global.setOut(new PrintStream(out));

        // Combine all of the streams (less, custom, lessc) into one big stream
        List<InputStream> streams = new ArrayList<InputStream>();

        // less should be first
        streams.add(lessJs.openConnection().getInputStream());

        // then the custom js so it has a chance to add any hooks
        for (URL url : customJs) {
            streams.add(url.openConnection().getInputStream());
        }

        // then the lessc so we can do the compile
        streams.add(lesscJs.openConnection().getInputStream());

        InputStreamReader reader = new InputStreamReader(
                new SequenceInputStream(Collections.enumeration(streams)));

        // Load the streams into a function we can run
        compiler = (Function) cx.compileReader(reader, lessJs.toString(), 1, null);

    } catch (Exception e) {
        String message = "Failed to initialize LESS compiler.";
        logger.error(message, e);
        throw new IllegalStateException(message, e);
    } finally {
        Context.exit();
    }

    if (logger.isDebugEnabled()) {
        logger.debug("Finished initialization of LESS compiler in %,d ms.%n",
                System.currentTimeMillis() - start);
    }
}

From source file:org.apache.myfaces.webapp.filter.PortletMultipartRequestWrapper.java

public Enumeration getParameterNames() {
    if (parametersMap == null)
        parseRequest();

    return Collections.enumeration(parametersMap.keySet());
}

From source file:org.jruby.rack.mock.MockServletContext.java

public Enumeration<String> getServletNames() {
    return Collections.enumeration(new HashSet<String>());
}

From source file:com.adobe.acs.commons.http.headers.impl.AbstractDispatcherCacheHeaderFilterTest.java

@Test
public void testDoFilterNoServerAgent() throws Exception {

    when(request.getHeaders(AbstractDispatcherCacheHeaderFilter.SERVER_AGENT_NAME))
            .thenReturn(Collections.enumeration(agents));

    filter.doFilter(request, response, chain);
    verify(chain).doFilter(request, response);

    verify(request).getHeaders(AbstractDispatcherCacheHeaderFilter.SERVER_AGENT_NAME);
    verify(request).getMethod();//from www .jav  a2 s.  c  om
    verify(request).getParameterMap();
    verifyNoMoreInteractions(request, this.request, response, chain);
}

From source file:org.treeingwalker.LessCompiler.java

/**
 * Initializes this <code>LessCompiler</code>.
 * <p>//from w  w w.  j  av a  2  s. c o m
 * It is not needed to call this method manually, as it is called implicitly by the compile methods if needed.
 * </p>
 */
public synchronized void init() {
    long start = System.currentTimeMillis();

    try {
        Context cx = Context.enter();
        //cx.setOptimizationLevel(-1);
        cx.setLanguageVersion(Context.VERSION_1_7);

        Global global = new Global();
        global.init(cx);
        scope = cx.initStandardObjects(global);
        scope.put("logger", scope, Context.toObject(logger, scope));

        out = new ByteArrayOutputStream();
        global.setOut(new PrintStream(out));

        // Combine all of the streams (less, custom, lessc) into one big stream
        List<InputStream> streams = new ArrayList<>();

        // less should be first
        streams.add(lessJs.openConnection().getInputStream());

        // then the custom js so it has a chance to add any hooks
        for (URL url : customJs) {
            streams.add(url.openConnection().getInputStream());
        }

        // then the lessc so we can do the compile
        streams.add(lesscJs.openConnection().getInputStream());

        InputStreamReader reader = new InputStreamReader(
                new SequenceInputStream(Collections.enumeration(streams)));

        // Load the streams into a function we can run 
        compiler = (Function) cx.compileReader(reader, lessJs.toString(), 1, null);

    } catch (Exception e) {
        String message = "Failed to initialize LESS compiler.";
        logger.error(message, e);
        throw new IllegalStateException(message, e);
    } finally {
        Context.exit();
    }

    if (logger.isDebugEnabled()) {
        logger.debug("Finished initialization of LESS compiler in %,d ms.%n",
                System.currentTimeMillis() - start);
    }
}

From source file:org.lwes.ArrayEvent.java

@Override
public Enumeration<String> getEventAttributeNames() {
    return Collections.enumeration(getEventAttributes());
}