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:spring.travel.site.request.RequestInfoInterceptorTest.java

@Test
public void shouldStripTheQuotesAroundTheCookieValue() throws Exception {
    String cookieValue = "90348039864-id=111";
    List<String> cookies = Arrays.asList(cookieName + "=" + "\"" + cookieValue + "\"");
    when(request.getHeaders("Cookie")).thenReturn(Collections.enumeration(cookies));

    assertTrue(interceptor.preHandle(request, response, new Object()));

    verify(request, times(1)).setAttribute(eq(attributeName), requestCaptor.capture());
    Request requestInfo = requestCaptor.getValue();

    assertEquals(Optional.of(cookieValue), requestInfo.getCookieValue());
    assertEquals(ipAddress, requestInfo.getRemoteAddress());
    assertEquals(Optional.empty(), requestInfo.getUser());
}

From source file:com.adobe.aem.demomachine.gui.AemDemoUtils.java

public static AemDemoProperty[] listDemoAddons(File buildFile) {

    List<AemDemoProperty> addons = new ArrayList<AemDemoProperty>();
    Properties defaultProps = loadProperties(
            buildFile.getParentFile().getAbsolutePath() + File.separator + "build.properties");

    @SuppressWarnings("serial")
    Properties sortedProps = new Properties() {
        @Override/*  w w  w  . j  a  va2  s .  c o  m*/
        public synchronized Enumeration<Object> keys() {
            return Collections.enumeration(new TreeSet<Object>(super.keySet()));
        }
    };
    sortedProps.putAll(defaultProps);

    // Looping through all possible options
    Enumeration<?> e = sortedProps.keys();

    // List of paths to demo packages
    List<String[]> listPaths = Arrays.asList(AemDemoConstants.demoPaths);

    while (e.hasMoreElements()) {
        String key = (String) e.nextElement();
        if (key.startsWith("demo.addons.") & !(key.endsWith("help") || key.endsWith("label"))) {
            String newKey = key.substring(1 + key.lastIndexOf("."));

            // Check if downloads are required
            boolean downloadRequired = false;
            for (String[] path : listPaths) {
                if (path.length == 5 && path[4] != null && path[4].equals(newKey)) {
                    File pathFolder = new File(buildFile.getParentFile().getAbsolutePath()
                            + (path[1].length() > 0 ? (File.separator + path[1]) : ""));
                    if (!pathFolder.exists()) {
                        downloadRequired = true;
                    }
                }
            }
            addons.add(new AemDemoProperty(newKey,
                    sortedProps.getProperty(key + ".label") + (downloadRequired ? " (*)" : "")));
        }
    }

    AemDemoProperty[] aemPropertyArray = new AemDemoProperty[addons.size()];
    addons.toArray(aemPropertyArray);
    return aemPropertyArray;

}

From source file:com.aplos.core.listeners.MultipartRequest.java

@Override
public Enumeration getParameterNames() {
    Set<String> paramNames = new LinkedHashSet<String>();
    paramNames.addAll(formParams.keySet());

    Enumeration<String> original = super.getParameterNames();
    while (original.hasMoreElements()) {
        paramNames.add(original.nextElement());
    }/*from  www . j a v  a 2  s . c  o m*/

    return Collections.enumeration(paramNames);
}

From source file:org.dspace.app.webui.util.FileUploadRequest.java

public Enumeration<String> getFileNames() {
    return Collections.enumeration(filenames);
}

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

/**
 * Method enumerateMevalue.//from w ww .j a  v  a 2s . c  o  m
 * 
 * @return an Enumeration over all possible elements of this
 * collection
 */
public Enumeration<String> enumerateMevalue() {
    return Collections.enumeration(this.m_mevalueList);
}

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

/**
 * Method enumerateVarbind.//from w ww  .  j a va  2 s.c  om
 * 
 * @return an Enumeration over all possible elements of this
 * collection
 */
public Enumeration<Varbind> enumerateVarbind() {
    return Collections.enumeration(this.m_varbindList);
}

From source file:org.ireland.jnetty.webapp.ServletContextImpl.java

/**
 * Returns an enumeration of the attribute names.
 *///  www .  j  ava2s . c o  m
@Override
public Enumeration<String> getAttributeNames() {
    synchronized (_attributes) {
        return Collections.enumeration(_attributes.keySet());
    }
}

From source file:org.ireland.jnetty.loader.WebAppClassLoader.java

@Override
public Enumeration<URL> getResources(String name) throws IOException {
    List<URL> from_parent = toList(_parent.getResources(name));
    List<URL> from_webapp = toList(this.findResources(name));

    if (delegate) {
        from_parent.addAll(from_webapp);
        return Collections.enumeration(from_parent);
    }/*from  ww  w .  ja va  2  s .c  o  m*/

    from_webapp.addAll(from_parent);
    return Collections.enumeration(from_webapp);
}

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

@Override
public Enumeration<String> getHeaderNames() {
    final Set<String> headerNames = new LinkedHashSet<String>();

    for (final Enumeration<String> headerNamesEnum = super.getHeaderNames(); headerNamesEnum
            .hasMoreElements();) {//from  w ww  . j  av a  2s  .  c om
        final String name = headerNamesEnum.nextElement();
        headerNames.add(name);
    }

    headerNames.addAll(this.additionalHeaders.keySet());

    return Collections.enumeration(headerNames);
}

From source file:org.sakaiproject.util.DbResourceBundle.java

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