List of usage examples for java.util List addAll
boolean addAll(Collection<? extends E> c);
From source file:org.jboss.spring.vfs.VFSResourcePatternResolvingHelper.java
public static Resource[] locateResources(String locationPattern, String rootDirPath, ClassLoader classLoader, PathMatcher pathMatcher, boolean oneMatchingRootOnly) throws IOException { String subPattern = locationPattern.substring(rootDirPath.length()); if (rootDirPath.startsWith("/")) { rootDirPath = rootDirPath.substring(1); }/*from ww w . j a v a2s . c o m*/ List<Resource> resources = new ArrayList<Resource>(); Enumeration<URL> urls = classLoader.getResources(rootDirPath); if (!oneMatchingRootOnly) { while (urls.hasMoreElements()) { resources.addAll(getVFSResources(urls.nextElement(), subPattern, pathMatcher)); } } else { resources.addAll(getVFSResources(classLoader.getResource(rootDirPath), subPattern, pathMatcher)); } return resources.toArray(new Resource[resources.size()]); }
From source file:com.exxonmobile.ace.hybris.storefront.util.MetaSanitizerUtil.java
/** * Takes a List of KeywordModels and returns a comma separated list of keywords as String. * /*w w w .ja va 2 s . c om*/ * @param keywords * List of KeywordModel objects * @return String of comma separated keywords */ public static String sanitizeKeywords(final List<KeywordModel> keywords) { // Remove duplicates final List<String> keywordList = new ArrayList<String>(); for (final KeywordModel kw : keywords) { keywordList.add(kw.getKeyword()); } final Set<String> keywordSet = new HashSet<String>(keywordList); keywordList.clear(); keywordList.addAll(keywordSet); // Format keywords final StringBuilder stringBuilder = new StringBuilder(); String formattedKeywords = null; for (final String kw : keywordList) { stringBuilder.append(kw); stringBuilder.append(','); } if (stringBuilder.length() > 0) { formattedKeywords = stringBuilder.substring(0, stringBuilder.length() - 1); } return formattedKeywords; }
From source file:com.powers.wsexplorer.gui.GUIUtil.java
/** * Takes the map and returns the keys as a sorted list. * Sorted by using the Collator. /* w w w .jav a2 s . com*/ * * @see Collator * @param map * @return List of sorted keys */ public static List<String> sortKeys(Map<String, ?> map) { Set<String> keys = map.keySet(); List<String> listToSort = new LinkedList<String>(); listToSort.addAll(keys); Collections.sort(listToSort, Collator.getInstance(Locale.getDefault())); return listToSort; }
From source file:net.sourceforge.vulcan.web.JstlFunctions.java
public static List<String> getAvailableDashboardColumns(PageContext pageContext) { final List<String> availableColumns = getAllDashboardColumns(Keys.DASHBOARD_COLUMNS); availableColumns.addAll(getAvailableMetrics()); final PreferencesDto prefs = (PreferencesDto) pageContext.findAttribute(Keys.PREFERENCES); if (prefs != null && prefs.getDashboardColumns() != null) { // Start with the chosen columns in the chosen order. final List<String> userSorted = new ArrayList<String>(Arrays.asList(prefs.getDashboardColumns())); // Remove any columns that are no longer valid. userSorted.retainAll(availableColumns); // Remove duplicates from set of unselected columns. availableColumns.removeAll(userSorted); // Add the unselected columns to the end of the list. userSorted.addAll(availableColumns); return userSorted; }/*from w w w . jav a 2 s .c om*/ return availableColumns; }
From source file:jsonclient.JsonClient.java
public static List<Place> getCountries() { String jsonQuery;// w ww . j av a2 s . c om String repsonse; Places countries = null; jsonQuery = "{\"data\":{\"action\":\"GetCountryList\", \"param\":{}}}"; List<Place> countriesList = new ArrayList<Place>(); try { repsonse = JsonClient.setSlide(jsonQuery); countries = new Gson().fromJson(repsonse, Places.class); } catch (IOException ex) { System.out.println(ex); } countriesList.addAll(countries.getData().getList()); countriesList.addAll(countries.getData().getPrefferedList()); return countriesList; }
From source file:com.enonic.cms.core.content.imports.ImportValueFormater.java
private static List<String> getStringArrayValue(final AbstractSourceValue value) { List<String> list = new ArrayList<String>(); if (value instanceof StringSourceValue) { list.add(((StringSourceValue) value).getValue()); } else if (value instanceof StringArraySourceValue) { list.addAll(((StringArraySourceValue) value).getValues()); } else {//ww w . j a v a 2 s. c o m throw new ImportException("Invalid source value type. Expected: " + StringSourceValue.class.getSimpleName() + " or " + StringArraySourceValue.class.getSimpleName() + ", Was: " + value.getClass().getSimpleName()); } return list; }
From source file:com.cdd.bao.template.SchemaUtil.java
public static void gatherAssayStats(Schema schema, List<String> stats) { List<Integer> idxAssay = new ArrayList<>(); for (int n = 0; n < schema.numAssays(); n++) if (schema.getAssay(n).annotations.size() > 0) idxAssay.add(n);/*from w w w.j av a2s . c o m*/ final int nassay = idxAssay.size(); stats.add("Assays with partial or complete annotations: " + nassay); List<Schema.Group> stack = new ArrayList<>(); stack.add(schema.getRoot()); List<Schema.Assignment> assignments = new ArrayList<>(); while (stack.size() > 0) { Schema.Group grp = stack.remove(0); assignments.addAll(grp.assignments); for (int n = 0; n < grp.subGroups.size(); n++) stack.add(n, grp.subGroups.get(n)); } List<Set<String>> assnValues = new ArrayList<>(), assnHits = new ArrayList<>(); for (Schema.Assignment assn : assignments) { Set<String> values = new HashSet<>(); for (Schema.Value val : assn.values) if (val.uri.length() > 0) values.add(val.uri); assnValues.add(values); assnHits.add(new HashSet<>()); } final int nassn = assignments.size(); if (nassn == 0) return; int[] assnCount = new int[nassn]; for (int n : idxAssay) { Schema.Assay assay = schema.getAssay(n); boolean[] assnHit = new boolean[nassn]; for (Schema.Annotation annot : assay.annotations) { for (int i = 0; i < nassn; i++) if (schema.matchAnnotation(annot, assignments.get(i))) { assnHit[i] = true; if (annot.value != null && assnValues.get(i).contains(annot.value.uri)) assnHits.get(i).add(annot.value.uri); } } for (int i = 0; i < nassn; i++) if (assnHit[i]) assnCount[i]++; } for (int n = 0; n < nassn; n++) { Schema.Assignment assn = assignments.get(n); String assnName = assn.name; for (Schema.Group p = assn.parent; p.parent != null; p = p.parent) assnName = p.name + " / " + assnName; stats.add("[" + assnName + "]"); stats.add(String.format(" assigned: count=%d/%d (%.1f%%)", assnCount[n], nassay, assnCount[n] * 100.0f / nassay)); int nhits = assnHits.get(n).size(), nvals = assnValues.get(n).size(); stats.add(String.format(" values used: count=%d/%d (%.1f%%)", nhits, nvals, nhits * 100.0f / nvals)); } }
From source file:com.flexive.tests.embedded.TestUsers.java
public static synchronized void deleteUsers() throws FxApplicationException { try {/*from ww w .j a v a 2 s. c o m*/ FxContext.get().runAsSystem(); List<TestUser> users = new ArrayList<TestUser>(ALL_USERS); users.addAll(USER_DEFINED_USERS); for (TestUser user : users) { try { user.deleteUser(); } catch (FxApplicationException e) { System.out.println("Failed to remove test user from database: " + e.getMessage()); e.printStackTrace(); } } // remove shared test group EJBLookup.getUserGroupEngine().remove(sharedTestGroupId); EJBLookup.getAclEngine().remove(sharedInstanceAclId); // remove test mandator EJBLookup.getMandatorEngine().remove(mandatorId); } finally { initialized = false; FxContext.get().stopRunAsSystem(); } }
From source file:controllers.oer.Application.java
private static Result processQuery(String q, String t, String location) { List<String> hits = hits(q, t, location); if (location.isEmpty()) hits.addAll(useQueryTermAsLocation(q, t)); String jsonString = "[" + Joiner.on(",").join(hits) + "]"; return response(Json.parse(jsonString)); }
From source file:com.bluexml.side.form.workflow.utils.WorkflowInitialization.java
/** * Launch initialization from a Workflow Form Collection * // w w w. ja v a 2s .c o m * @param fc * @param domain * @return */ public static Command initialize(WorkflowFormCollection fc, EditingDomain domain) { CompoundCommand cmd = null; Process p = fc.getLinked_process(); if (p != null) { // fix update fc.name if (StringUtils.trimToNull(fc.getName()) == null) { fc.setName(p.getName()); } boolean doWork = true; if (fc.getForms().size() > 0) { doWork = UIUtils.showConfirmation("Workflow already set", "This Workflow Form Collection has already been set. Do you want to overwrite it?"); } if (doWork) { cmd = new CompoundCommand(); // Delete all childs: if (fc.getForms().size() > 0) { cmd.append(RemoveCommand.create(domain, fc.getForms())); } // Get All Tasks List<State> l = new ArrayList<State>(); l.add(p.getStartstate()); l.addAll(p.getTasknode()); // List of Form List<FormWorkflow> lf = new ArrayList<FormWorkflow>(); // For each task we create a form for (State s : l) { FormWorkflow fw = createTaskForForm(s); lf.add(fw); } cmd.append(AddCommand.create(domain, fc, FormPackage.eINSTANCE.getFormCollection_Forms(), lf)); } } else { UIUtils.showError("No Process defined", "No Process has been defined. \n" + "Choose one and run Initialize again."); } return cmd; }