Example usage for java.util Collections list

List of usage examples for java.util Collections list

Introduction

In this page you can find the example usage for java.util Collections list.

Prototype

public static <T> ArrayList<T> list(Enumeration<T> e) 

Source Link

Document

Returns an array list containing the elements returned by the specified enumeration in the order they are returned by the enumeration.

Usage

From source file:no.java.swing.resource.ResourceMapImpl.java

@Override
public Set<String> keySet() {
    if (keys == null) {
        keys = Collections.unmodifiableSet(new HashSet<String>(Collections.list(bundle.getKeys())));
    }/* ww w  .  j a v  a 2  s  .c o m*/
    return keys;
}

From source file:com.arrggh.eve.api.sde.StaticDataExportImporter.java

public void importFile(File zipFile) throws IOException {
    try (ZipFile sdeZip = new ZipFile(zipFile)) {
        Map<Long, Type> types = processMap("Types",
                sdeZip.getInputStream(sdeZip.getEntry("sde/fsd/typeIDs.yaml")), Types.TYPE_MAP);

        List<InventoryType> items = processArray("Items",
                sdeZip.getInputStream(sdeZip.getEntry("sde/bsd/invItems.yaml")), Types.INVENTORY_TYPE_ARRAY);

        Map<Long, Blueprint> blueprints = processMap("Blueprint",
                sdeZip.getInputStream(sdeZip.getEntry("sde/fsd/blueprints.yaml")), Types.BLUEPRINT_MAP);

        for (ZipEntry entry : Collections.list(sdeZip.entries())) {
            String entryName = entry.getName();
            if (entryName.contains("sde/fsd/universe") && entryName.endsWith(".staticdata")) {
                if (entryName.endsWith("constellation.staticdata")) {
                    Constellation constellation = process(sdeZip.getInputStream(entry),
                            Types.CONSTELLATION_TYPE);
                }/*w w w .  jav  a 2  s. co m*/
                if (entryName.endsWith("solarsystem.staticdata")) {
                    SolarSystem solarsystem = process(sdeZip.getInputStream(entry), Types.SOLARSYSTEM_TYPE);
                }
            }
        }

        Map<Long, Icon> icons = processMap("Icons",
                sdeZip.getInputStream(sdeZip.getEntry("sde/fsd/iconIDs.yaml")), Types.ICON_MAP);
        Map<Long, Graphic> graphics = processMap("Graphics",
                sdeZip.getInputStream(sdeZip.getEntry("sde/fsd/graphicIDs.yaml")), Types.GRAPHICS_MAP);
        Map<Long, Certificate> certificates = processMap("Certificates",
                sdeZip.getInputStream(sdeZip.getEntry("sde/fsd/certificates.yaml")), Types.CERTIFICATE_MAP);
        Map<Long, Group> groups = processMap("Groups",
                sdeZip.getInputStream(sdeZip.getEntry("sde/fsd/groupIDs.yaml")), Types.GROUPS_MAP);
        Map<Long, Category> categories = processMap("Categories",
                sdeZip.getInputStream(sdeZip.getEntry("sde/fsd/categoryIDs.yaml")), Types.CATEGORY_MAP);
        Map<Long, SkinLicense> skinLicenses = processMap("Skin Licenses",
                sdeZip.getInputStream(sdeZip.getEntry("sde/fsd/skinLicenses.yaml")), Types.SKIN_LICENCE_MAP);
        Map<Long, SkinMaterial> skinMaterials = processMap("Skin Materials",
                sdeZip.getInputStream(sdeZip.getEntry("sde/fsd/skinMaterials.yaml")), Types.SKIN_MATERIAL_MAP);
        Map<Long, Skin> skins = processMap("Skins",
                sdeZip.getInputStream(sdeZip.getEntry("sde/fsd/skins.yaml")), Types.SKIN_MAP);
        List<TournamentRuleSet> tournamentRuleSets = processArray("Tournament Rule Sets",
                sdeZip.getInputStream(sdeZip.getEntry("sde/fsd/tournamentRuleSets.yaml")),
                Types.TOURNAMENT_RULE_SET_ARRAY);
    }
}

From source file:org.wso2.carbon.identity.webfinger.builders.DefaultWebFingerRequestBuilder.java

@Override
public WebFingerRequest buildRequest(HttpServletRequest request) throws WebFingerEndpointException {
    WebFingerRequest webFingerRequest = new WebFingerRequest();
    List<String> parameters = Collections.list(request.getParameterNames());
    if (parameters.size() != 2 || !parameters.contains(WebFingerConstants.REL)
            || !parameters.contains(WebFingerConstants.RESOURCE)) {
        throw new WebFingerEndpointException(WebFingerConstants.ERROR_CODE_INVALID_REQUEST,
                "Bad Web " + "Finger request.");
    }// w  w  w  .ja v  a  2s  .c o  m
    webFingerRequest.setServletRequest(request);
    String resource = request.getParameter(WebFingerConstants.RESOURCE);
    webFingerRequest.setRel(request.getParameter(WebFingerConstants.REL));
    webFingerRequest.setResource(resource);

    if (StringUtils.isBlank(resource)) {
        log.warn("Can't normalize null or empty URI: " + resource);
        throw new WebFingerEndpointException(WebFingerConstants.ERROR_CODE_INVALID_RESOURCE,
                "Null or empty URI.");

    } else {
        URI resourceURI = URI.create(resource);
        if (StringUtils.isBlank(resourceURI.getScheme())) {
            throw new WebFingerEndpointException("Scheme of the resource cannot be empty");
        }
        String userInfo;
        if (WebFingerConstants.ACCT_SCHEME.equals(resourceURI.getScheme())) {
            //acct scheme
            userInfo = resourceURI.getSchemeSpecificPart();
            userInfo = userInfo.substring(0, userInfo.lastIndexOf('@'));
        } else {
            //https scheme
            userInfo = resourceURI.getUserInfo();
            webFingerRequest.setScheme(resourceURI.getScheme());
            webFingerRequest.setHost(resourceURI.getHost());
            webFingerRequest.setPort(resourceURI.getPort());
            webFingerRequest.setPath(resourceURI.getPath());
            webFingerRequest.setQuery(resourceURI.getQuery());
        }

        String tenant;
        if (StringUtils.isNotBlank(userInfo)) {
            try {
                userInfo = URLDecoder.decode(userInfo, "UTF-8");
            } catch (UnsupportedEncodingException e) {
                throw new WebFingerEndpointException("Cannot decode the userinfo");
            }
            tenant = MultitenantUtils.getTenantDomain(userInfo);
            webFingerRequest.setUserInfo(resourceURI.getUserInfo());
        } else {
            tenant = MultitenantConstants.SUPER_TENANT_DOMAIN_NAME;
        }
        validateTenant(tenant);
        webFingerRequest.setTenant(tenant);
    }

    return webFingerRequest;
}

From source file:com.github.jrialland.ajpclient.servlet.TestServletProxy.java

public TestServletProxy() {
    super(Protocol.Ajp);
    addStaticResource("/dizzy.mp4", DIZZY_MP4);

    addServlet("/test_post", new HttpServlet() {

        private static final long serialVersionUID = 168417L;

        @Override//from  ww w .  j  a v  a  2  s . c om
        protected void doPost(final HttpServletRequest req, final HttpServletResponse resp)
                throws ServletException, IOException {
            final int nParams = Collections.list(req.getParameterNames()).size();
            resp.getWriter().print(nParams);
        }
    });

    addServlet("/long_request", new HttpServlet() {

        private static final long serialVersionUID = 168411L;

        @Override
        protected void service(final HttpServletRequest req, final HttpServletResponse resp)
                throws ServletException, IOException {
            try {
                final int time = Integer.parseInt(req.getParameter("duration"));
                Thread.sleep(time);
            } catch (final Exception e) {
                throw new ServletException(e);
            }
        }
    });
}

From source file:org.nuxeo.runtime.jtajca.NuxeoConnectionManagerFactory.java

@Override
public Object getObjectInstance(Object obj, Name objName, Context nameCtx, Hashtable<?, ?> env) {
    Reference ref = (Reference) obj;
    if (!ConnectionManager.class.getName().equals(ref.getClassName())) {
        return null;
    }/*  ww  w .  j a v  a2 s.  c o  m*/
    String name;
    int size = objName.size();
    if (size == 1) {
        name = "default";
    } else {
        name = objName.get(size - 1);
    }

    final ConnectionManager cm = NuxeoContainer.connectionManagers.get(name);
    if (cm != null) {
        return cm;
    }

    NuxeoConnectionManagerConfiguration config = new NuxeoConnectionManagerConfiguration();
    for (RefAddr addr : Collections.list(ref.getAll())) {
        String type = addr.getType();
        String content = (String) addr.getContent();
        try {
            BeanUtils.setProperty(config, type, content);
        } catch (ReflectiveOperationException e) {
            log.error(String.format("NuxeoConnectionManagerFactory cannot set %s = %s", type, content));
        }
    }
    return NuxeoContainer.initConnectionManager(config);
}

From source file:eu.betaas.betaasandroidapp.configuration.Configuration.java

private void setDeviceIp() {
    try {//w  w w  . java 2  s .  c  o  m
        List<NetworkInterface> interfaces = Collections.list(NetworkInterface.getNetworkInterfaces());
        for (NetworkInterface intf : interfaces) {
            List<InetAddress> addrs = Collections.list(intf.getInetAddresses());
            for (InetAddress addr : addrs) {
                if (!addr.isLoopbackAddress()) {
                    String sAddr = addr.getHostAddress().toUpperCase();
                    boolean isIPv4 = InetAddressUtils.isIPv4Address(sAddr);
                    if (isIPv4) {
                        deviceIP = sAddr;
                    }
                }
            }
        }
    } catch (Exception ex) {
        deviceIP = null;
    }
}

From source file:org.musicrecital.webapp.filter.LocaleRequestWrapper.java

/**
 * {@inheritDoc}//from   w w w. j  av  a2 s .c  o  m
 */
@SuppressWarnings("unchecked")
public Enumeration<Locale> getLocales() {
    if (null != preferredLocale) {
        List<Locale> l = Collections.list(super.getLocales());
        if (l.contains(preferredLocale)) {
            l.remove(preferredLocale);
        }
        l.add(0, preferredLocale);
        return Collections.enumeration(l);
    } else {
        return super.getLocales();
    }
}

From source file:com.googleapis.ajax.services.example.ResourceBundleGenerator.java

/**
 * Process command line./*w  w  w  . j  a  v a2s . c  o  m*/
 * 
 * @param line the line
 * @param options the options
 */
@SuppressWarnings("unchecked")
private static void processCommandLine(CommandLine line, Options options) {
    if (line.hasOption(HELP_OPTION)) {
        printHelp(options);
    } else if (line.hasOption(APPLICATION_KEY_OPTION) && line.hasOption(RESOURCE_OPTION)) {
        GoogleSearchQueryFactory factory = GoogleSearchQueryFactory
                .newInstance(line.getOptionValue(APPLICATION_KEY_OPTION));
        Properties resourceMessages = loadResourceMessages(line.getOptionValue(RESOURCE_OPTION));
        List<String> propertyNames = (List<String>) Collections.list(resourceMessages.propertyNames());
        List<Language> targetLanguages = getTargetLanguages(line.getOptionValue(LANGUAGES_OPTION));

        for (Language language : targetLanguages) {
            Properties translatedResources = new Properties();
            TranslateLanguageQuery translateQuery = factory.newTranslateLanguageQuery();
            translateQuery.withLanguagePair(Language.ENGLISH, language);

            for (String name : propertyNames) {
                translateQuery.withQuery(resourceMessages.getProperty(name));
            }
            List<TranslateLanguageResult> result = translateQuery.list();
            if (result.size() == propertyNames.size()) {
                int index = 0;
                for (String name : propertyNames) {
                    translatedResources.setProperty(name, result.get(index++).getTranslatedText());
                }
            }
            saveResourceMessages(translatedResources, line.getOptionValue(RESOURCE_OPTION), language);
        }
    } else {
        printHelp(options);
    }
}

From source file:de.tbuchloh.kiskis.gui.feedback.AbstractSubmitFeedback.java

/**
 * @return/*from  w  w w . j  a  va 2 s. c  om*/
 */
@SuppressWarnings("unchecked")
protected String createBuildInformation() {
    final StringBuilder sb = new StringBuilder();
    final Set<String> props = new TreeSet(Collections.list(BuildProperties.getBuildProperties().getKeys()));
    for (final String key : props) {
        sb.append(key);
        sb.append("=");
        sb.append(BuildProperties.getBuildProperties().getString(key));
        sb.append("\n");
    }
    return sb.toString();
}

From source file:org.jasig.portlet.test.mvc.tests.GetExpectedUserAttributesTest.java

@ActionMapping
public void handleActionRequestInternal(ActionRequest request, ActionResponse response) throws Exception {
    final List<String> attributesNames = Collections.list(request.getAttributeNames());
    final Map<String, String> userInfo = (Map<String, String>) request.getAttribute(PortletRequest.USER_INFO);
    final Map<String, List<Object>> multivaluedUserInfo = (Map<String, List<Object>>) request
            .getAttribute(USER_INFO_MULTIVALUED);

    response.setRenderParameter("AttributeNames", String.valueOf(attributesNames));
    response.setRenderParameter(PortletRequest.USER_INFO, String.valueOf(userInfo));
    response.setRenderParameter(USER_INFO_MULTIVALUED, String.valueOf(multivaluedUserInfo));
}