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.ireland.jnetty.server.session.HttpSessionImpl.java

/**
 * Return an enumeration of all the sessions' attribute names.
 * /*from ww w  . j a  v  a 2 s.co m*/
 * @return enumeration of the attribute names.
 */
@Override
public Enumeration<String> getAttributeNames() {
    synchronized (_values) {
        if (!_isValid)
            throw new IllegalStateException(
                    this + " can't call getAttributeNames() when session is no longer valid.");

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

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

/**
 * Method enumerateAutoaction./*  w  w w .  j  a  va2 s . c  o  m*/
 * 
 * @return an Enumeration over all possible elements of this
 * collection
 */
public Enumeration<Autoaction> enumerateAutoaction() {
    return Collections.enumeration(this.m_autoactionList);
}

From source file:com.example.webapp.filter.MultipartFilter.java

/**
 * Wrap the given HttpServletRequest with the given parameterMap.
 * //from www.j  a  v a 2s. c  o m
 * @param request The HttpServletRequest of which the given parameterMap
 *            have to be wrapped in.
 * @param parameterMap The parameterMap to be wrapped in the given
 *            HttpServletRequest.
 * @return The HttpServletRequest with the parameterMap wrapped in.
 */
private static HttpServletRequest wrapRequest(HttpServletRequest request,
        final Map<String, String[]> parameterMap) {
    return new HttpServletRequestWrapper(request) {
        @Override
        public Map<String, String[]> getParameterMap() {
            return parameterMap;
        }

        @Override
        public String[] getParameterValues(String name) {
            return parameterMap.get(name);
        }

        @Override
        public String getParameter(String name) {
            String[] params = getParameterValues(name);
            return params != null && params.length > 0 ? params[0] : null;
        }

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

From source file:com.norconex.commons.lang.io.ByteArrayOutputStream.java

/**
 * Gets the current contents of this byte stream as a Input Stream. The
 * returned stream is backed by buffers of <code>this</code> stream,
 * avoiding memory allocation and copy, thus saving space and time.<br>
 * /*from   w  ww  .  j  a va 2  s. co  m*/
 * @return the current contents of this output stream.
 * @see java.io.ByteArrayOutputStream#toByteArray()
 * @see #reset()
 */
private InputStream toBufferedInputStream() {
    int remaining = totalCount;
    if (remaining == 0) {
        return new ClosedInputStream();
    }
    List<ByteArrayInputStream> list = new ArrayList<ByteArrayInputStream>(buffers.size());
    for (byte[] buf : buffers) {
        int c = Math.min(buf.length, remaining);
        list.add(new ByteArrayInputStream(buf, 0, c));
        remaining -= c;
        if (remaining == 0) {
            break;
        }
    }
    return new SequenceInputStream(Collections.enumeration(list));
}

From source file:com.liferay.portal.upload.UploadServletRequestImpl.java

@Override
public Enumeration<String> getParameterNames() {
    Set<String> parameterNames = new LinkedHashSet<String>();

    Enumeration<String> enu = super.getParameterNames();

    while (enu.hasMoreElements()) {
        String name = enu.nextElement();

        if (!_params.containsKey(name)) {
            parameterNames.add(name);/*from   ww w .  ja v a  2  s .  c  om*/
        }
    }

    parameterNames.addAll(_params.keySet());

    return Collections.enumeration(parameterNames);
}

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

/**
 * Method enumerateForward./*w  w w. j a  v a 2s.com*/
 * 
 * @return an Enumeration over all possible elements of this
 * collection
 */
public Enumeration<Forward> enumerateForward() {
    return Collections.enumeration(this.m_forwardList);
}

From source file:org.apache.click.servlet.MockRequest.java

/**
 * Get the names of all of the values.//from  w w  w  .  ja  v a2 s  . c  om
 *
 * @return The names
 */
public Enumeration<String> getAttributeNames() {
    return Collections.enumeration(attributes.keySet());
}

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

@Test
public void testDoFilterSuccess() throws Exception {

    agents.add(AbstractDispatcherCacheHeaderFilter.DISPATCHER_AGENT_HEADER_VALUE);
    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();// w ww . j  a v  a2 s .  c o  m
    verify(request).getParameterMap();
    verify(request).getAttribute(
            "com.adobe.acs.commons.http.headers.impl.AbstractDispatcherCacheHeaderFilter.header.Header Name");
    verify(request).setAttribute(eq(
            "com.adobe.acs.commons.http.headers.impl.AbstractDispatcherCacheHeaderFilter.header.Header Name"),
            any());
    verify(response).addHeader(headerName, headerValue);
    verifyNoMoreInteractions(request, this.request, response, chain);
}

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

public Enumeration<String> getInitParameterNames() {
    return Collections.enumeration(this.initParameters.keySet());
}

From source file:org.silverpeas.core.web.http.HttpRequest.java

/**
 * Returns an Enumeration of String objects containing the names of the parameters contained in
 * this request. If the request has no parameters, the method returns an empty Enumeration. The
 * parameters from a multipart/form-data stream are also considered by this method, unlike of the
 * default behavior of the decorated request.
 *
 * @return an Enumeration of String objects, each String containing the name of a request
 * parameter; or an empty Enumeration if the request has no parameters.
 *///  w  w  w .j a v a 2s. c  o  m
@Override
public Enumeration<String> getParameterNames() {
    Enumeration<String> names = super.getParameterNames();
    if (!names.hasMoreElements() && isContentInMultipart()) {
        List<FileItem> items = getFileItems();
        List<String> itemNames = new ArrayList<>(items.size());
        for (FileItem item : items) {
            if (item.isFormField()) {
                itemNames.add(item.getFieldName());
            }
        }
        names = Collections.enumeration(itemNames);
    }
    return names;
}