List of usage examples for java.util Collections list
public static <T> ArrayList<T> list(Enumeration<T> e)
From source file:org.springframework.cloud.function.adapter.aws.SpringFunctionInitializer.java
private static Class<?> getStartClass() { ClassLoader classLoader = SpringFunctionInitializer.class.getClassLoader(); if (System.getenv("MAIN_CLASS") != null) { return ClassUtils.resolveClassName(System.getenv("MAIN_CLASS"), classLoader); }//from ww w . j av a2s. co m try { Class<?> result = getStartClass(Collections.list(classLoader.getResources("META-INF/MANIFEST.MF"))); if (result == null) { result = getStartClass(Collections.list(classLoader.getResources("meta-inf/manifest.mf"))); } logger.info("Main class: " + result); return result; } catch (Exception ex) { logger.error("Failed to find main class", ex); return null; } }
From source file:org.codice.ddf.configuration.persistence.felix.FelixPersistenceStrategy.java
private void checkForInvalidProperties(Set<String> expectedPropertyName, Dictionary properties) throws ConfigurationFileException { if (properties.size() != expectedPropertyName.size()) { @SuppressWarnings("unchecked") Set<String> propertyNames = new HashSet<>(Collections.list(properties.keys())); LOGGER.error("Unable to convert all config file properties. One of [{}] is invalid", expectedPropertyName.removeAll(propertyNames)); throw new ConfigurationFileException("Unable to convert all config file properties."); }// w w w. j a va2 s. c om }
From source file:net.centro.rtb.monitoringcenter.infos.NodeInfo.java
private static String detectPublicIpAddress() { Enumeration<NetworkInterface> networkInterfaces = null; try {/*from w w w.j a va 2s .c om*/ networkInterfaces = NetworkInterface.getNetworkInterfaces(); } catch (SocketException e) { logger.debug("Unable to obtain network interfaces!", e); return null; } for (NetworkInterface networkInterface : Collections.list(networkInterfaces)) { boolean isLoopback = false; try { isLoopback = networkInterface.isLoopback(); } catch (SocketException e) { logger.debug("Unable to identify if a network interface is a loopback or not"); } if (!isLoopback) { Enumeration<InetAddress> inetAddresses = networkInterface.getInetAddresses(); while (inetAddresses.hasMoreElements()) { InetAddress inetAddress = inetAddresses.nextElement(); if (Inet4Address.class.isInstance(inetAddress)) { if (!inetAddress.isLoopbackAddress() && !inetAddress.isAnyLocalAddress() && !inetAddress.isLinkLocalAddress() && !inetAddress.isSiteLocalAddress()) { return inetAddress.getHostAddress(); } } } } } return null; }
From source file:jp.mathes.databaseWiki.web.DbwServlet.java
@SuppressWarnings("unchecked") private void redirect(final String baseURL, final HttpServletRequest req, final HttpServletResponse resp, final String db, final String table, String name, final boolean withParameters) throws IOException { name = URLEncoder.encode(name, "UTF-8"); StringBuilder paramStr = new StringBuilder(); if (withParameters) { for (String paramName : Collections.list((Enumeration<String>) req.getParameterNames())) { if (paramName.startsWith("_") || paramName.equals("name")) { continue; }/*from www . jav a 2 s .co m*/ for (String value : req.getParameterValues(paramName)) { paramStr.append(paramName).append("=").append(value).append("&"); } } } if (paramStr.length() > 0) { resp.sendRedirect( String.format(baseURL + "?%s", req.getContextPath(), db, table, name, paramStr.toString())); } else { resp.sendRedirect(String.format(baseURL, req.getContextPath(), db, table, name)); } }
From source file:license.rsa.WakeRSA.java
/** * ?mac/*www. j av a 2 s .c o m*/ * @param sb * @throws Exception */ private static void mac(StringBuilder sb) throws Exception { Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces(); int i = 12; Base64 base64 = new Base64(); for (NetworkInterface ni : Collections.list(interfaces)) if (ni.getName().substring(0, 1).equalsIgnoreCase("e")) { sb.append(String.valueOf(i)).append('=').append(ni.getName()).append('\n'); i++; byte[] mac = ni.getHardwareAddress(); sb.append(String.valueOf(i)).append('=').append(base64.encodeAsString(mac)).append('\n'); i++; } }
From source file:com.jean.farCam.SettingsActivity.java
public static String getIPAddress() { try {// www. ja va 2s.co 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(); if (InetAddressUtils.isIPv4Address(sAddr)) { return sAddr; } } } } } catch (Exception ex) { } return ""; }
From source file:org.kohsuke.stapler.RequestImplTest.java
@Test public void test_mutipart_formdata() throws IOException, ServletException { final Stapler stapler = new Stapler(); final byte[] buf = generateMultipartData(); final ByteArrayInputStream is = new ByteArrayInputStream(buf); final MockRequest mockRequest = new MockRequest() { @Override//from w w w .j a v a 2s . c o m public String getContentType() { return "multipart/form-data; boundary=mpboundary"; } @Override public String getCharacterEncoding() { return "UTF-8"; } @Override public int getContentLength() { return buf.length; } @Override public Enumeration getParameterNames() { return Collections.enumeration(Arrays.asList("p1")); } @Override public ServletInputStream getInputStream() throws IOException { return new ServletInputStream() { @Override public int read() throws IOException { return is.read(); } @Override public int read(byte[] b) throws IOException { return is.read(b); } @Override public int read(byte[] b, int off, int len) throws IOException { return is.read(b, off, len); } }; } }; RequestImpl request = new RequestImpl(stapler, mockRequest, Collections.<AncestorImpl>emptyList(), null); // Check that we can get the Form Fields. See https://github.com/stapler/stapler/issues/52 Assert.assertEquals("text1_val", request.getParameter("text1")); Assert.assertEquals("text2_val", request.getParameter("text2")); // Check that we can get the file FileItem fileItem = request.getFileItem("pomFile"); Assert.assertNotNull(fileItem); // Check getParameterValues Assert.assertEquals("text1_val", request.getParameterValues("text1")[0]); // Check getParameterNames Assert.assertTrue(Collections.list(request.getParameterNames()).contains("p1")); Assert.assertTrue(Collections.list(request.getParameterNames()).contains("text1")); // Check getParameterMap Assert.assertTrue(request.getParameterMap().containsKey("text1")); }
From source file:com.ctc.storefront.filters.StorefrontFilter.java
protected void initDefaults(final HttpServletRequest request) { getStoreSessionFacade().initializeSession(Collections.list(request.getLocales())); }
From source file:org.wso2.appserver.monitoring.utils.EventBuilder.java
/** * Gets all request headers and their corresponding values. * * @param request The Request object of client * @return A string containing all request headers and their values *//*from w w w . ja va2 s . c om*/ private static String getRequestHeaders(Request request) { List<String> requestHeaders = new ArrayList<>(); Collections.list(request.getHeaderNames()).forEach(header -> { List<String> values = new ArrayList<>(); values.add(request.getHeader(header)); String tmpString = "(" + StringUtils.join(values, ",") + ")"; requestHeaders.add(header + ":" + tmpString); }); return StringUtils.join(requestHeaders, ";"); }
From source file:org.apache.james.mailbox.backup.ZipAssert.java
public ZipAssert containsOnlyEntriesMatching(EntryChecks... entryChecks) throws Exception { isNotNull();/*from www . java2 s . co m*/ List<EntryChecks> sortedEntryChecks = Arrays.stream(entryChecks) .sorted(Comparator.comparing(checks -> checks.name)).collect(Guavate.toImmutableList()); List<ZipArchiveEntry> entries = Collections.list(zipFile.getEntries()).stream() .sorted(Comparator.comparing(ZipArchiveEntry::getName)).collect(Guavate.toImmutableList()); if (entries.size() != entryChecks.length) { throwAssertionError(shouldHaveSize(zipFile, entryChecks.length, entries.size())); } for (int i = 0; i < entries.size(); i++) { sortedEntryChecks.get(i).check.test(assertThatZipEntry(zipFile, entries.get(i))); } return myself; }