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.impalaframework.extension.mvc.util.RequestModelHelperTest.java

@SuppressWarnings("unchecked")
public void testSetParameters() {
    HttpServletRequest request = createMock(HttpServletRequest.class);
    HashMap model = new HashMap();
    model.put("p2", "2a");
    model.put("p3", null);

    expect(request.getParameterNames())/*from  w ww . j  a v a2s.  c  om*/
            .andReturn(Collections.enumeration(Arrays.asList("p1", "p2", "p3", "p4")));
    expect(request.getParameter("p1")).andReturn("1");
    //expect(request.getParameter("p2")).andReturn("2");
    //expect(request.getParameter("p3")).andReturn("3");
    expect(request.getParameter("p4")).andReturn("");

    replay(request);

    RequestModelHelper.setParameters(request, model);

    assertEquals(4, model.size());
    assertEquals("1", model.get("p1"));
    assertEquals("2a", model.get("p2"));
    assertEquals(null, model.get("p3"));
    assertEquals("", model.get("p4"));

    verify(request);
}

From source file:org.impalaframework.extension.mvc.annotation.resolver.RequestParameterMapTest.java

private Object doRequestAttribute(String methodName, final String attributeName, final String value)
        throws Exception {

    MethodParameter methodParameter = new MethodParameter(
            ReflectionUtils.findMethod(AnnotatedClass.class, methodName, new Class[] { String.class }), 0);

    expect(nativeRequest.getNativeRequest()).andReturn(request);
    expect(request.getParameterNames()).andReturn(Collections.enumeration(Arrays.asList("one", "two")));
    expect(request.getParameter("one")).andReturn("1");
    expect(request.getParameter("two")).andReturn("2");

    replayMocks();//from  w ww . j  ava2 s .  co m

    Object arg = resolver.resolveArgument(methodParameter, nativeRequest);

    verifyMocks();
    return arg;
}

From source file:br.com.SGIURD.utils.FileUploadWrapper.java

/**
 * Return all request parameter names, for both regular controls and file
 * upload controls.//w ww  . j a va2s  .c  o m
 */
@Override
public Enumeration<String> getParameterNames() {
    @SuppressWarnings("unchecked")
    Set<String> allNames = new LinkedHashSet();
    allNames.addAll(fRegularParams.keySet());
    allNames.addAll(fFileParams.keySet());
    return Collections.enumeration(allNames);
}

From source file:Enumerations.java

/**
 * Returns an enumeration that iterates over provided array.
 * @param arr the array of object/*  www  . j a  v a2s .c om*/
 * @return enumeration of those objects
 */
public static <T> Enumeration<T> array(T... arr) {
    return Collections.enumeration(Arrays.asList(arr));
}

From source file:org.apache.accumulo.examples.wikisearch.parser.TreeNode.java

public Enumeration<TreeNode> getChildrenAsEnumeration() {
    return Collections.enumeration(children);
}

From source file:org.vosao.i18n.VosaoResourceBundle.java

@Override
public Enumeration<String> getKeys() {
    List<String> result = new ArrayList<String>();
    for (ResourceBundle bundle : getResourceBundles()) {
        result.addAll(Collections.list(bundle.getKeys()));
    }/*from  w  w  w .  j  ava 2s  . com*/
    return Collections.enumeration(result);
}

From source file:it.scoppelletti.sdk.schemaupdate.SpringResourceAccessor.java

/**
 * Restituisce le risorse corrispondenti ad un pacchetto.
 * /*from  w  w w  .  j  a va2 s  .  co  m*/
 * @param  packageName Nome del pacchetto.
 * @return             Collezione.
 */
public Enumeration<URL> getResources(String packageName) throws IOException {
    List<URL> list = new ArrayList<URL>(1);

    list.add(getResource(packageName).getURL());

    return Collections.enumeration(list);
}

From source file:io.gravitee.gateway.reactor.handler.ExecutionContextImpl.java

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

From source file:Utils.java

/**
 * Concatenates the content of two enumerations into one.
 * Until the// w  w  w.  java2 s.c  o m
 * end of <code>en1</code> is reached its elements are being served.
 * As soon as the <code>en1</code> has no more elements, the content
 * of <code>en2</code> is being returned.
 *
 * @param en1 first enumeration
 * @param en2 second enumeration
 * @return enumeration
 */
public static <T> Enumeration<T> concat(Enumeration<? extends T> en1, Enumeration<? extends T> en2) {
    ArrayList<Enumeration<? extends T>> two = new ArrayList<Enumeration<? extends T>>();
    two.add(en1);
    two.add(en2);
    return new SeqEn<T>(Collections.enumeration(two));
}

From source file:ltistarter.oauth.OAuth1LibraryTests.java

@Test
public void testParseParameters() throws Exception {
    CoreOAuthProviderSupport support = new CoreOAuthProviderSupport();
    when(request.getHeaders("Authorization"))
            .thenReturn(Collections.enumeration(Arrays.asList("OAuth realm=\"http://sp.example.com/\",\n"
                    + "                oauth_consumer_key=\"0685bd9184jfhq22\",\n"
                    + "                oauth_token=\"ad180jjd733klru7\",\n"
                    + "                oauth_signature_method=\"HMAC-SHA1\",\n"
                    + "                oauth_signature=\"wOJIO9A2W5mFwDgiDvZbTSMK%2FPY%3D\",\n"
                    + "                oauth_timestamp=\"137131200\",\n"
                    + "                oauth_nonce=\"4572616e48616d6d65724c61686176\",\n"
                    + "                oauth_version=\"1.0\"")));

    Map<String, String> params = support.parseParameters(request);
    assertEquals("http://sp.example.com/", params.get("realm"));
    assertEquals("0685bd9184jfhq22", params.get(OAuthConsumerParameter.oauth_consumer_key.toString()));
    assertEquals("ad180jjd733klru7", params.get(OAuthConsumerParameter.oauth_token.toString()));
    assertEquals("HMAC-SHA1", params.get(OAuthConsumerParameter.oauth_signature_method.toString()));
    assertEquals("wOJIO9A2W5mFwDgiDvZbTSMK/PY=", params.get(OAuthConsumerParameter.oauth_signature.toString()));
    assertEquals("137131200", params.get(OAuthConsumerParameter.oauth_timestamp.toString()));
    assertEquals("4572616e48616d6d65724c61686176", params.get(OAuthConsumerParameter.oauth_nonce.toString()));
    assertEquals("1.0", params.get(OAuthConsumerParameter.oauth_version.toString()));
}