List of usage examples for java.util Collections list
public static <T> ArrayList<T> list(Enumeration<T> e)
From source file:it.anyplace.sync.core.configuration.ConfigurationService.java
private synchronized Properties export() { Properties properties = new Properties() { @Override/*from w w w. j a v a 2s . c om*/ public synchronized Enumeration<Object> keys() { List<String> list = (List) Collections.list(super.keys()); Collections.sort(list); return Collections.enumeration((List) list); } }; if (!isBlank(deviceName)) { properties.setProperty(DEVICE_NAME, deviceName); } if (!isBlank(deviceId)) { properties.setProperty(DEVICE_ID, deviceId); } FolderConfigList folderConfigList = new FolderConfigList(); for (FolderInfo folderInfo : folders.values()) { FolderConfig folderConfig = new FolderConfig(); folderConfig.setFolder(folderInfo.getFolder()); folderConfig.setLabel(folderInfo.getLabel()); folderConfigList.getFolders().add(folderConfig); } properties.setProperty(FOLDERS, gson.toJson(folderConfigList)); DeviceConfigList deviceConfigList = new DeviceConfigList(); for (DeviceInfo deviceInfo : peers.values()) { DeviceConfig deviceConfig = new DeviceConfig(); deviceConfig.setDeviceId(deviceInfo.getDeviceId()); deviceConfig.setName(deviceInfo.getName()); deviceConfigList.getDevices().add(deviceConfig); } properties.setProperty(PEERS, gson.toJson(deviceConfigList)); properties.setProperty(DATABASE, database.getAbsolutePath()); properties.setProperty(TEMP, temp.getAbsolutePath()); properties.setProperty(CACHE, cache.getAbsolutePath()); if (keystore != null) { properties.setProperty(KEYSTORE, BaseEncoding.base64().encode(keystore)); } if (!isBlank(keystoreAlgo)) { properties.setProperty(KEYSTORE_ALGO, keystoreAlgo); } properties.setProperty(DISCOVERY_SERVERS, Joiner.on(",").join(discoveryServers)); return properties; }
From source file:com.opensymphony.xwork2.util.finder.UrlSet.java
private List<URL> getUrls(ClassLoaderInterface classLoader) throws IOException { List<URL> list = new ArrayList<URL>(); //find jars/*from ww w. j av a 2 s .c om*/ ArrayList<URL> urls = Collections.list(classLoader.getResources("META-INF")); for (URL url : urls) { if ("jar".equalsIgnoreCase(url.getProtocol())) { String externalForm = url.toExternalForm(); //build a URL pointing to the jar, instead of the META-INF dir url = new URL(StringUtils.substringBefore(externalForm, "META-INF")); list.add(url); } else if (LOG.isDebugEnabled()) LOG.debug("Ignoring URL [#0] because it is not a jar", url.toExternalForm()); } //usually the "classes" dir list.addAll(Collections.list(classLoader.getResources(""))); return list; }
From source file:org.apache.cassandra.hadoop.ColumnFamilyRecordReader.java
private String getLocation() { ArrayList<InetAddress> localAddresses = new ArrayList<InetAddress>(); try {//from w w w . j ava 2 s.co m Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces(); while (nets.hasMoreElements()) localAddresses.addAll(Collections.list(nets.nextElement().getInetAddresses())); } catch (SocketException e) { throw new AssertionError(e); } for (InetAddress address : localAddresses) { for (String location : split.getLocations()) { InetAddress locationAddress = null; try { locationAddress = InetAddress.getByName(location); } catch (UnknownHostException e) { throw new AssertionError(e); } if (address.equals(locationAddress)) { return location; } } } return split.getLocations()[0]; }
From source file:org.jkcsoft.java.util.JndiHelper.java
public static Object lookup(Context jndi, String name) throws NamingException { // String l_name = cleanName(p_name); Object retObj = jndi.lookup(name); if (log.isDebugEnabled()) { try {/*from w w w .jav a 2s . c om*/ StringBuilder sbLog = new StringBuilder(); NameParser parser = jndi.getNameParser(name); Name jndiName = parser.parse(name); List lNames = Collections.list(jndiName.getAll()); if (lNames != null) { Iterator iNames = lNames.iterator(); while (iNames.hasNext()) { String elemName = (String) iNames.next(); Strings.appendLine(sbLog, "name [" + elemName + "]"); } } log.debug("Jndi parse of [" + name + "] => " + sbLog); } catch (NamingException e) { log.warn("Error in getting JNDI name info", e); } } return retObj; }
From source file:com.jefftharris.passwdsafe.SavedPasswordsMgr.java
/** * Remove all saved passwords and keys/*from w w w . j av a 2 s .c om*/ */ public synchronized void removeAllSavedPasswords() { getPrefs().edit().clear().apply(); if (isAvailable()) { try { KeyStore keyStore = getKeystore(); for (String key : Collections.list(keyStore.aliases())) { PasswdSafeUtil.dbginfo(TAG, "removeAllSavedPasswords key: %s", key); keyStore.deleteEntry(key); } } catch (CertificateException | NoSuchAlgorithmException | IOException | KeyStoreException e) { e.printStackTrace(); } } }
From source file:org.apache.solr.servlet.cache.HttpCacheHeaderUtil.java
/** * Check for etag related conditional headers and set status * //w w w . jav a2s. c o m * @return true if no request processing is necessary and HTTP response status has been set, false otherwise. * @throws IOException */ @SuppressWarnings("unchecked") public static boolean checkETagValidators(final HttpServletRequest req, final HttpServletResponse resp, final Method reqMethod, final String etag) throws IOException { // First check If-None-Match because this is the common used header // element by HTTP clients final List<String> ifNoneMatchList = Collections.list(req.getHeaders("If-None-Match")); if (ifNoneMatchList.size() > 0 && isMatchingEtag(ifNoneMatchList, etag)) { if (reqMethod == Method.GET || reqMethod == Method.HEAD) { sendNotModified(resp); } else { sendPreconditionFailed(resp); } return true; } // Check for If-Match headers final List<String> ifMatchList = Collections.list(req.getHeaders("If-Match")); if (ifMatchList.size() > 0 && !isMatchingEtag(ifMatchList, etag)) { sendPreconditionFailed(resp); return true; } return false; }
From source file:org.impalaframework.classloader.graph.GraphClassLoader.java
/** * Returns enumeration of local resources, combined with those of parent * class loader./*from w ww .j a v a 2 s. co m*/ * * The implementation of {@link #getResources(String)} is pretty * conservative. For a given resource name, only one resource URL will ever * be found from within the module hierarchy. Also, only the current module * is searched. It's ancestor and dependent modules are not searched for the * resource. * * The module resource, if found, is returned as an {@link Enumeration} * which also includes the resources obtained from the standard or * application class loader via the super{@link #getResources(String)} call. */ @Override public Enumeration<URL> getResources(String name) throws IOException { Enumeration<URL> resources = super.getResources(name); Enumeration<URL> localResources = getLocalResources(name); if (localResources != null) { List<URL> combined = new ArrayList<URL>(); combined.addAll(Collections.list(localResources)); combined.addAll(Collections.list(resources)); return Collections.enumeration(combined); } return resources; }
From source file:framework.GlobalHelpers.java
public static List<String> headers(String name) { // TODO Move this code somewhere else HttpServletRequest req = req().getRequest(); return Collections.list(req.getHeaders(name)); }
From source file:de.pavloff.spark4knime.jsnippet.ui.JarListPanel.java
@SuppressWarnings("null") private void onJarURLAdd() { DefaultListModel<String> model = (DefaultListModel<String>) m_addJarList.getModel(); Set<String> hash = new HashSet<>(Collections.list(model.elements())); String input = "knime://knime.workflow/example.jar"; boolean valid; do {/* w w w. j av a2s .c o m*/ input = JOptionPane.showInputDialog(this, "Enter a \"knime:\" URL to a JAR file", input); if (StringUtils.isEmpty(input)) { valid = true; } else { URL url; try { url = new URL(input); File file = FileUtil.getFileFromURL(url); CheckUtils.checkArgument(file != null, "Could not resolve to local file"); CheckUtils.checkArgument(file.exists(), "File does not exists; location resolved to\n%s", file.getAbsolutePath()); valid = true; } catch (MalformedURLException | IllegalArgumentException mfe) { JOptionPane.showMessageDialog(this, "Invalid URL\n" + mfe.getMessage(), "Error parsing URL", JOptionPane.ERROR_MESSAGE); valid = false; continue; } } } while (!valid); if (!StringUtils.isEmpty(input) && hash.add(input)) { model.addElement(input); } }
From source file:ro.nextreports.designer.wizpublish.SelectEntityWizardPanel.java
/** * Called to validate the panel before moving to next panel. * * @param messages a List of messages to be displayed. * @return true if the panel is valid,// w ww . j a v a 2s . c o m */ public boolean validateNext(java.util.List<String> messages) { if (listModel.size() <= 0) { messages.add(I18NSupport.getString("wizard.publish.entities.select.error")); return false; } context.setAttribute(PublishBulkWizard.LIST, Collections.list(listModel.elements())); return true; }