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:org.jahia.services.atmosphere.AtmosphereServlet.java

@Override
public void init(final ServletConfig sc) throws ServletException {
    ServletConfig scFacade;//from  w  ww .j a  v a 2s  .c  om

    String asyncSupport = SettingsBean.getInstance().getAtmosphereAsyncSupport();
    // override asyncSupport only if explicitly set via jahia.properties or not set at all
    if (StringUtils.isNotEmpty(asyncSupport) || sc.getInitParameter(PROPERTY_COMET_SUPPORT) == null) {
        final String implName = StringUtils.defaultIfBlank(asyncSupport, DEFAULT_ASYNC_SUPPORT);
        scFacade = new ServletConfig() {
            @Override
            public String getInitParameter(String name) {
                return PROPERTY_COMET_SUPPORT.equals(name) ? implName : sc.getInitParameter(name);
            }

            @Override
            public Enumeration<String> getInitParameterNames() {
                ArrayList<String> names = Lists.newArrayList(PROPERTY_COMET_SUPPORT);
                CollectionUtils.addAll(names, sc.getInitParameterNames());
                return Collections.enumeration(names);
            }

            @Override
            public ServletContext getServletContext() {
                return sc.getServletContext();
            }

            @Override
            public String getServletName() {
                return sc.getServletName();
            }
        };
    } else {
        scFacade = sc;
    }

    super.init(scFacade);
}

From source file:org.opennms.netmgt.config.snmp.SnmpConfig.java

/**
 * Method enumerateDefinition.//from   w w  w.ja  v  a  2s  .c o m
 * 
 * @return an Enumeration over all possible elements of this
 * collection
 */
public java.util.Enumeration<Definition> enumerateDefinition() {
    return Collections.enumeration(this._definitionList);
}

From source file:org.sourcepit.m2p2.osgi.embedder.maven.P2Test.java

@Override
protected ClassLoader getClassLoader() {
    return new ClassLoader(super.getClassLoader()) {
        @Override//from   w  w w .  j av a2s  . c o  m
        public Enumeration<URL> getResources(String name) throws IOException {
            if ("META-INF/plexus/components.xml".equals(name)) {
                List<URL> res = new ArrayList<URL>();
                Enumeration<URL> resources = super.getResources(name);
                int i = 0;
                while (resources.hasMoreElements()) {
                    URL url = (URL) resources.nextElement();
                    if (i > 0) {
                        res.add(url);
                    }
                    i++;
                }
                return Collections.enumeration(res);
            }
            return super.getResources(name);
        }
    };
}

From source file:com.gettextresourcebundle.GettextResourceBundle.java

@Override
public Enumeration<String> getKeys() {
    return Collections.enumeration(resources.keySet());
}

From source file:org.wso2.carbon.identity.core.filter.AuthorizationHeaderFilter.java

public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
        throws IOException, ServletException {

    final HttpServletRequest req = (HttpServletRequest) request;
    final String authHeader = req.getHeader(HTTPConstants.HEADER_AUTHORIZATION);
    if (StringUtils.isEmpty(authHeader)) {
        chain.doFilter(request, response);
        return;//from  w ww  . j  ava 2 s .c om
    }

    String authType = null;
    if (authHeader.length() >= AUTH_TYPE_BASIC_LENGTH) {
        authType = authHeader.trim().substring(0, AUTH_TYPE_BASIC_LENGTH);
    }
    if (AUTH_TYPE_BASIC.equals(authType)) {
        final String authCredentials = (authHeader.trim().substring(AUTH_TYPE_BASIC_LENGTH)).trim();
        //if auth header comes in invalid format send error in response
        if (StringUtils.isBlank(authCredentials) || authCredentials.indexOf(' ') >= 0
                || authCredentials.length() < MINIMUM_CREDENTIAL_SIZE) {
            String errorMsg = "Internal Server Error";
            handleErrorResponse((HttpServletResponse) response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                    errorMsg);
        } else if (authHeader.substring((AUTH_TYPE_BASIC + " ").length()).startsWith(" ")) {
            //if there is more than single space between auth_type and credentials modify the request header
            HttpServletRequestWrapper wrapper = new HttpServletRequestWrapper(req) {

                @Override
                public Enumeration<String> getHeaders(String name) {

                    if (StringUtils.equalsIgnoreCase(name, HTTPConstants.HEADER_AUTHORIZATION)) {

                        Enumeration<String> headerValues = req.getHeaders(name);
                        ArrayList<String> newHeaderValues = new ArrayList<>();
                        while (headerValues.hasMoreElements()) {
                            String value = headerValues.nextElement();
                            if (StringUtils.equals(value, authHeader)) {
                                value = AUTH_TYPE_BASIC + " " + authCredentials;
                                newHeaderValues.add(value);
                            } else {
                                newHeaderValues.add(value);
                            }
                        }
                        return Collections.enumeration(newHeaderValues);
                    }
                    return super.getHeaders(name);
                }
            };
            // pass the request along the filter chain
            chain.doFilter(wrapper, response);
        }
        //if auth header comes in correct format, forward
        else {
            chain.doFilter(request, response);
        }
    } else {
        chain.doFilter(request, response);
    }
}

From source file:org.opennms.netmgt.xml.eventconf.Events.java

/**
 * Method enumerateEvent.//from www  .j a  v  a  2s. c  om
 * 
 * @return an Enumeration over all possible elements of this
 * collection
 */
public Enumeration<Event> enumerateEvent() {
    return Collections.enumeration(this.m_eventList);
}

From source file:org.nuxeo.ecm.webengine.loader.store.ResourceStoreClassLoader.java

@Override
protected Enumeration<URL> findResources(String name) throws IOException {
    ResourceStore[] _stores = stores; // use a local variable
    if (_stores != null) {
        List<URL> result = new ArrayList<URL>();
        for (final ResourceStore store : _stores) {
            final URL url = store.getURL(name);
            if (url != null) {
                if (log.isTraceEnabled()) {
                    log.trace(getId() + " found resource: " + name);
                }/*from  w  w w .  j  ava2s.  com*/
                result.add(url);
            }
        }
        return Collections.enumeration(result);
    }
    return null;
}

From source file:org.apereo.portal.url.PortalHttpServletRequestWrapper.java

@Override
public Enumeration<String> getHeaders(String name) {
    final String value = this.additionalHeaders.get(name);
    if (value == null) {
        return super.getHeaders(name);
    }/*from   w ww.j  a va2 s  . co m*/

    return Collections.enumeration(Collections.singleton(value));
}

From source file:org.deegree.client.core.filter.InputFileWrapper.java

@Override
public Enumeration<String> getParameterNames() {
    return Collections.enumeration(formParameters.keySet());
}

From source file:org.apache.struts.upload.MultipartRequestWrapper.java

/**
 * Returns the names of the parameters for this request.
 * The enumeration consists of the normal request parameter
 * names plus the parameters read from the multipart request
 *//*w w  w.  j a v a  2  s .c om*/
public Enumeration getParameterNames() {
    Enumeration baseParams = request.getParameterNames();
    Vector list = new Vector();
    while (baseParams.hasMoreElements()) {
        list.add(baseParams.nextElement());
    }
    Collection multipartParams = parameters.keySet();
    Iterator iterator = multipartParams.iterator();
    while (iterator.hasNext()) {
        list.add(iterator.next());
    }
    return Collections.enumeration(list);
}