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:com.amazonaws.serverless.proxy.internal.servlet.AwsProxyHttpServletRequest.java

@Override
public Enumeration<Locale> getLocales() {
    String localeHeader = getHeaderCaseInsensitive(HttpHeaders.ACCEPT_LANGUAGE);
    List<Locale> locales = new ArrayList<>();
    if (localeHeader == null) {
        locales.add(Locale.getDefault());
    } else {//from   w w  w  .  j  av a2s.c  o m
        if (localeHeader.contains(HEADER_VALUE_SEPARATOR)) {
            for (String locale : localeHeader.split(HEADER_VALUE_SEPARATOR)) {
                locales.add(new Locale(locale.trim()));
            }
        } else {
            locales.add(new Locale(localeHeader.trim()));
        }
    }
    return Collections.enumeration(locales);
}

From source file:org.ajax4jsf.request.MultipartRequest.java

@Override
@SuppressWarnings("unchecked")
public Enumeration getParameterNames() {
    if (parameters == null) {
        parseRequest();/*from  w w w  .j a  v  a  2 s  . co m*/
    }

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

From source file:org.apache.wicket.protocol.http.mock.MockHttpServletRequest.java

/**
 * Return all the accepted locales. This implementation always returns just one.
 * //from  w  w  w .  j  a  v a 2s  .co m
 * @return The locales
 */
@Override
public Enumeration<Locale> getLocales() {
    List<Locale> list = new ArrayList<>();
    String header = getHeader("Accept-Language");
    if (header != null) {
        int idxOfSemicolon = header.indexOf(';');
        if (idxOfSemicolon > -1) {
            header = header.substring(0, idxOfSemicolon);
        }
        final String[] locales = Strings.split(header, ',');
        for (String value : locales) {
            Locale locale = getLocale(value);
            if (locale != null) {
                list.add(locale);
            }
        }
    }

    if (list.size() == 0) {
        list.add(Locale.getDefault());
    }

    return Collections.enumeration(list);
}

From source file:org.xwoot.jxta.JxtaPeer.java

/** {@inheritDoc} **/
@SuppressWarnings("unchecked")
public Enumeration<PeerAdvertisement> getKnownPeers(/*PeerGroupAdvertisement group*/) {

    // Find the PeerGroup for this adv.  If we haven't joined the group,
    // we can't do the discovery.  (We get the DiscoveryService object from the
    // PeerGroup.
    ///*from  ww w  .  java  2  s.c o m*/
    /*PeerGroup pg = findJoinedGroup(group);
    if (pg == null)
    return null;*/

    if (!this.isConnectedToNetwork()) {
        logger.warn("Not conencted to network.");
        // return empty enumeration.
        return Collections.enumeration(new ArrayList<PeerAdvertisement>());
    }

    Enumeration en = null;
    DiscoveryService disco = this.currentJoinedGroup.getDiscoveryService();

    try {
        en = disco.getLocalAdvertisements(DiscoveryService.PEER, null, null);
    } catch (Exception e) {
        logger.warn("Failed to get locally stored known peers.\n", e);
        return Collections.enumeration(new ArrayList<PeerAdvertisement>());
    }

    discoverPeers(null, null);

    return (Enumeration<PeerAdvertisement>) en;
}

From source file:org.apache.shindig.common.testing.FakeHttpServletRequest.java

public Enumeration<?> getLocales() {
    return Collections.enumeration(locales);
}

From source file:org.pentaho.di.trans.steps.mailinput.ParseMailInputTest.java

private Enumeration<?> getEnum(Header[] headers) {
    return Collections.enumeration(Arrays.asList(headers));
}

From source file:net.lightbody.bmp.proxy.jetty.jetty.servlet.ServletHttpRequest.java

public Enumeration getParameterNames() {
    return Collections.enumeration(_httpRequest.getParameterNames());
}

From source file:cn.pku.sei.GHRC.MySpectralClusterer.java

/**
 * Returns an enumeration describing the available options.
 * <p>/*w w w . j a v  a 2s .  c o  m*/
 * 
 * @return an enumeration of all the available options
 **/
public Enumeration<?> listOptions() {
    return Collections.enumeration(OPTIONS);
}

From source file:de.ingrid.admin.Config.java

public void writeCommunicationToProperties() {
    Resource override = getOverrideConfigResource();
    try (InputStream is = new FileInputStream(override.getFile().getAbsolutePath())) {

        Properties props = new Properties() {
            private static final long serialVersionUID = 6956076060462348684L;

            @Override/*  w  ww .j a v a  2  s. c o m*/
            public synchronized Enumeration<Object> keys() {
                return Collections.enumeration(new TreeSet<Object>(super.keySet()));
            }
        };
        props.load(is);
        // ---------------------------
        props.setProperty("communication.clientName", communicationProxyUrl);

        String communications = "";
        for (int i = 0; i < ibusses.size(); i++) {
            CommunicationCommandObject ibus = ibusses.get(i);
            communications += ibus.getBusProxyServiceUrl() + "," + ibus.getIp() + "," + ibus.getPort();
            if (i != (ibusses.size() - 1))
                communications += "##";
        }
        props.setProperty("communications.ibus", communications);

        // ---------------------------
        try (OutputStream os = new FileOutputStream(override.getFile().getAbsolutePath())) {
            props.store(os, "Override configuration written by the application");
        }
    } catch (Exception e) {
        log.error("Error writing properties: ", e);
    }
}

From source file:org.xwoot.jxta.JxtaPeer.java

/** {@inheritDoc} **/
public Enumeration<Advertisement> getKnownAdvertisements(/*PeerGroupAdvertisement group,
                                                         */String attribute, String value) {

    // Find the PeerGroup for this adv.  If we haven't joined the group,
    // we can't do the discovery.  (We get the DiscoveryService object from the
    // PeerGroup.
    ///*  w ww. ja v  a  2 s  .  c o m*/
    //        PeerGroup pg = findJoinedGroup(group);
    //        if (pg == null)
    //            return null;

    if (!this.isConnectedToNetwork()) {
        logger.warn("Not conencted to network.");
        // return empty enumeration.
        return Collections.enumeration(new ArrayList<Advertisement>());
    }

    Enumeration<Advertisement> en = Collections.enumeration(new ArrayList<Advertisement>());
    DiscoveryService disco = this.currentJoinedGroup.getDiscoveryService();

    try {
        en = disco.getLocalAdvertisements(DiscoveryService.ADV, attribute, value);
    } catch (Exception e) {
        logger.warn("Failed to get locally stored known advertisements.\n", e);
        return Collections.enumeration(new ArrayList<Advertisement>());
    }

    // Flush advertisements to always be up to date.
    /*while(en.hasMoreElements()) {
    Advertisement adv = en.nextElement();
    try {
        disco.flushAdvertisement(adv);
    } catch (Exception e) {
        logger.warn("Failed to flush advertisement:\n" + adv, e);
    }
    }*/

    // Rediscover advertisements to always be up to date.
    discoverAdvertisements(null, null, attribute, value);

    return en;
}