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.jasig.springframework.mock.web.portlet.MockFilterConfig.java

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

From source file:org.apache.hadoop.gateway.identityasserter.common.filter.IdentityAsserterHttpServletRequestWrapper.java

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override/*from w  w  w  .j ava2 s  .c o m*/
public Enumeration getParameterNames() {
    Map<String, String[]> params = getParams();
    if (params == null) {
        params = new HashMap<>();
    }
    Enumeration<String> e = Collections.enumeration((Collection<String>) params.keySet());

    return e;
}

From source file:org.hippoecm.frontend.model.tree.JcrTreeNode.java

public Enumeration<? extends TreeNode> children() {
    ensureChildrenLoaded();
    return Collections.enumeration(children);
}

From source file:org.wso2.carbon.identity.gateway.api.request.GatewayRequest.java

public Enumeration<String> getHeaders(String name) {
    String headerValue = (String) headers.get(name);
    if (StringUtils.isNotEmpty(headerValue)) {
        String[] multiValuedHeader = headerValue.split(",");
        return Collections.enumeration(Arrays.asList(multiValuedHeader));
    }/*from ww  w .  j ava2 s .  c  o  m*/
    return Collections.emptyEnumeration();
}

From source file:net.oauth.signature.GoogleCodeCompatibilityTests.java

/**
 * tests compatibility of calculating the signature base string.
 *//*  w  w  w  . ja  v  a2  s .  c om*/
@Test
public void testCalculateSignatureBaseString() throws Exception {
    final String baseUrl = "http://www.springframework.org/schema/security/";
    CoreOAuthProviderSupport support = new CoreOAuthProviderSupport() {
        @Override
        protected String getBaseUrl(HttpServletRequest request) {
            return baseUrl;
        }
    };

    Map<String, String[]> parameterMap = new HashMap<String, String[]>();
    parameterMap.put("a", new String[] { "value-a" });
    parameterMap.put("b", new String[] { "value-b" });
    parameterMap.put("c", new String[] { "value-c" });
    parameterMap.put("param[1]", new String[] { "aaa", "bbb" });

    when(request.getParameterNames()).thenReturn(Collections.enumeration(parameterMap.keySet()));
    for (Map.Entry<String, String[]> param : parameterMap.entrySet()) {
        when(request.getParameterValues(param.getKey())).thenReturn(param.getValue());
    }

    String header = "OAuth realm=\"http://sp.example.com/\","
            + "                oauth_consumer_key=\"0685bd9184jfhq22\","
            + "                oauth_token=\"ad180jjd733klru7\","
            + "                oauth_signature_method=\"HMAC-SHA1\","
            + "                oauth_signature=\"wOJIO9A2W5mFwDgiDvZbTSMK%2FPY%3D\","
            + "                oauth_timestamp=\"137131200\"," + "                oauth_callback=\""
            + OAuthCodec.oauthEncode("http://myhost.com/callback") + "\","
            + "                oauth_nonce=\"4572616e48616d6d65724c61686176\","
            + "                oauth_version=\"1.0\"";
    when(request.getHeaders("Authorization")).thenReturn(Collections.enumeration(Arrays.asList(header)));
    when(request.getMethod()).thenReturn("GET");
    String ours = support.getSignatureBaseString(request);

    when(request.getHeaders("Authorization")).thenReturn(Collections.enumeration(Arrays.asList(header)));
    when(request.getParameterMap()).thenReturn(parameterMap);
    when(request.getHeaderNames()).thenReturn(null);
    OAuthMessage message = OAuthServlet.getMessage(request, baseUrl);

    String theirs = OAuthSignatureMethod.getBaseString(message);
    assertEquals(theirs, ours);
}

From source file:org.apache.cocoon.servletservice.ServletServiceContext.java

public Enumeration getAttributeNames() {
    return Collections.enumeration(this.attributes.keySet());
}

From source file:org.directwebremoting.util.FakeHttpServletRequest.java

public Enumeration<String> getHeaderNames() {
    return Collections.enumeration(Collections.<String>emptySet());
}

From source file:br.com.caelum.vraptor.ioc.spring.SpringProviderRegisteringComponentsTest.java

@Override
protected void configureExpectations() {
    when(context.getRealPath(anyString()))
            .thenReturn(SpringBasedContainer.class.getResource("../fixture").getFile());

    Enumeration<String> emptyEnumeration = Collections.enumeration(Collections.<String>emptyList());
    when(context.getInitParameterNames()).thenReturn(emptyEnumeration);
    when(context.getAttributeNames()).thenReturn(emptyEnumeration);
}

From source file:com.autentia.wuija.i18n.SequenceResource.java

/**
 * Devuelve un nico <code>InputStream</code> que es el resultado de concatenar todos los <code>InputStream</code>
 * de los <code>Resource</code> que se pasaron en el constructor.
 * <p>//from w  ww .ja  v  a2 s .  c o  m
 * Para conseguir esto, esta clase utiliza la clase <code>java.io.SequenceInputStream</code> de Java.
 * 
 * @return un nico <code>InputStream</code> que es el resultado de concatenar todos los <code>InputStream</code> de
 *         los <code>Resource</code> que se pasaron en el constructor.
 */
public InputStream getInputStream() throws IOException {
    final List<InputStream> ins = new ArrayList<InputStream>(resources.length);
    for (Resource resource : resources) {
        ins.add(resource.getInputStream());
    }
    final Enumeration<InputStream> streamsEnumeration = Collections.enumeration(ins);
    return new SequenceInputStream(streamsEnumeration);
}

From source file:FakeHttpSession.java

public Enumeration<String> getAttributeNames() {
    return Collections.enumeration(attributes.keySet());
}