List of usage examples for java.util Collection add
boolean add(E e);
From source file:com.evolveum.midpoint.security.api.SecurityUtil.java
public static Collection<String> getActions(Collection<ConfigAttribute> configAttributes) { Collection<String> actions = new ArrayList<>(configAttributes.size()); for (ConfigAttribute attr : configAttributes) { actions.add(attr.getAttribute()); }//from w ww . j a v a 2 s. co m return actions; }
From source file:Main.java
public static Collection<String> getXmlFilenames(String path) throws NullPointerException { Collection<String> results = new ArrayList<>(); File folder = new File(path); // We will grab all XML files from the target directory. File[] listOfFiles = folder.listFiles(); String file;/*from www. j a v a2s .c om*/ for (int i = 0; i < listOfFiles.length; i++) { if (listOfFiles[i].isFile()) { file = listOfFiles[i].getAbsolutePath(); if (file.endsWith(".xml") || file.endsWith(".xml")) { results.add(file); } } } return results; }
From source file:Main.java
private static void innerListFiles(File dir, Collection<File> accumulator, FileFilter filter) { String[] filenames = dir.list(); if (filenames != null) { for (int i = 0; i < filenames.length; i++) { File file = new File(dir, filenames[i]); if (file.isDirectory()) { innerListFiles(file, accumulator, filter); } else { if (filter != null && filter.accept(file)) { accumulator.add(file); }//from ww w .j a v a 2s . c o m } } } }
From source file:tools.xor.util.ClassUtil.java
public static Collection jsonArrayToCollection(JSONArray jsonArray) { Collection collection = new ArrayList<>(jsonArray.length()); try {//from www. j a v a 2 s . co m for (int i = 0; i < jsonArray.length(); i++) { collection.add(jsonArray.get(i)); } } catch (JSONException e) { throw ClassUtil.wrapRun(e); } return collection; }
From source file:com.evolveum.midpoint.schema.SelectorOptions.java
public static <T> Map<T, Collection<ItemPath>> extractOptionValues( Collection<SelectorOptions<GetOperationOptions>> options, Function<GetOperationOptions, T> supplier) { Map<T, Collection<ItemPath>> rv = new HashMap<>(); for (SelectorOptions<GetOperationOptions> selectorOption : CollectionUtils.emptyIfNull(options)) { T value = supplier.apply(selectorOption.getOptions()); if (value != null) { Collection<ItemPath> itemPaths = rv.computeIfAbsent(value, t -> new HashSet<>()); itemPaths.add(selectorOption.getItemPath()); }//from ww w . j a va 2s . c o m } return rv; }
From source file:com.github.ipaas.ideploy.agent.util.SVNUtil.java
public static void getDeta4UpdateAll(final String path, final long revision, String localPath) throws Exception { DefaultSVNOptions options = SVNWCUtil.createDefaultOptions(true); ISVNAuthenticationManager authManager = SVNWCUtil .createDefaultAuthenticationManager(Constants.CRS_REPOS_USER, Constants.CRS_REPOS_PWD); SVNClientManager svnClientManager = null; try {//from w w w . j ava2 s . c o m // File localDict = new File(localPath); if (!localDict.exists()) { localDict.mkdirs(); } else { FileUtils.cleanDirectory(localDict); } svnClientManager = SVNClientManager.newInstance(options, authManager); Collection<SVNLog> logs = new LinkedList<SVNLog>(); logs.add(new SVNLog4All()); // export(svnClientManager, path, revision, localPath + Constants.UPDPKG_CODEDIR); // writeLogToFile(logs, new File(localPath + Constants.UPDPKG_UPDTXT)); } finally { if (svnClientManager != null) { svnClientManager.dispose(); } } }
From source file:com.hypersocket.i18n.I18N.java
private static Object[] formatParameters(Object... arguments) { Collection<Object> formatted = new ArrayList<Object>(arguments.length); for (Object arg : arguments) { if (arg instanceof Date) { formatted.add(DateFormat.getDateTimeInstance().format(arg)); } else {/*w w w . j av a 2 s . c o m*/ formatted.add(arg); } } return formatted.toArray(new Object[formatted.size()]); }
From source file:org.keycloak.testsuite.saml.ConcurrentAuthnRequestTest.java
private static void loginRepeatedly(UserRepresentation user, URI samlEndpoint, Document samlRequest, String relayState, Binding requestBinding) { CloseableHttpResponse response = null; SamlClient.RedirectStrategyWithSwitchableFollowRedirect strategy = new SamlClient.RedirectStrategyWithSwitchableFollowRedirect(); ExecutorService threadPool = Executors.newFixedThreadPool(CONCURRENT_THREADS); try (CloseableHttpClient client = HttpClientBuilder.create().setRedirectStrategy(strategy).build()) { HttpUriRequest post = requestBinding.createSamlUnsignedRequest(samlEndpoint, relayState, samlRequest); Collection<Callable<Void>> futures = new LinkedList<>(); for (int i = 0; i < ITERATIONS; i++) { final int j = i; Callable<Void> f = () -> { performLogin(post, samlEndpoint, relayState, samlRequest, response, client, user, strategy); return null; };// ww w. j av a2 s . c o m futures.add(f); } threadPool.invokeAll(futures); } catch (Exception ex) { throw new RuntimeException(ex); } }
From source file:com.gc.iotools.fmt.base.TestUtils.java
public static String[] listFilesExcludingExtension(final String[] forbidden) throws IOException { final URL fileURL = TestUtils.class.getResource("/testFiles"); String filePath = URLDecoder.decode(fileURL.getPath(), "UTF-8"); final File dir = new File(filePath); final String[] files = dir.list(); final Collection<String> goodFiles = new Vector<String>(); if (!filePath.endsWith(File.separator)) { filePath = filePath + File.separator; }/*from w w w .ja va2 s . c om*/ for (final String file : files) { boolean insert = true; for (final String extForbidden : forbidden) { insert &= !(file.endsWith(extForbidden)); } if (insert) { goodFiles.add(filePath + file); } } return goodFiles.toArray(new String[goodFiles.size()]); }
From source file:com.egt.ejb.toolkit.ColUtils.java
public static <T> Collection<T> filterAll(Collection<T> collection, Predicado<T>... predicates) { Collection<T> arrayList = new ArrayList<T>(); boolean b;/*w w w . j a va 2 s .com*/ for (T element : collection) { b = true; for (Predicado<T> predicate : predicates) { b = predicate.evaluate(element); if (b) { continue; } else { break; } } if (b) { arrayList.add(element); } } return arrayList; }