List of usage examples for java.util Collection add
boolean add(E e);
From source file:com.datascience.gal.scripts.MainClient.java
private static Collection<AssignedLabel> loadAssignedLabels(String inputfile) { Collection<AssignedLabel> out = new HashSet<AssignedLabel>(); String[] lines = Utils.getFile(inputfile).split("\n"); for (String line : lines) { String[] parts = line.split("\t"); if (parts.length < 3) { System.err.println("invalid worker assigned label: " + line); continue; }/* w w w. j a v a2s . co m*/ out.add(new AssignedLabel(parts[0], parts[1], parts[2])); } return out; }
From source file:net.gtaun.shoebill.util.config.MapConfiguration.java
@SuppressWarnings("unchecked") public static void getKeyList(Collection<String> collection, String path, Map<String, Object> map) { if (map == null) return;//from ww w .j ava 2 s . c om try { for (Entry<String, Object> entry : map.entrySet()) { Object obj = entry.getValue(); String curPath = path.isEmpty() ? entry.getKey() : path + "." + entry.getKey(); if (obj instanceof Map<?, ?> == false) collection.add(curPath); else getKeyList(collection, curPath, (Map<String, Object>) obj); } } catch (ClassCastException e) { } }
From source file:net.sourceforge.fenixedu.domain.AlumniIdentityCheckRequest.java
public static Object readClosedRequests() { Collection<AlumniIdentityCheckRequest> pendingRequests = new ArrayList<AlumniIdentityCheckRequest>(); AlumniIdentityCheckRequest request;//from ww w .j a v a 2 s .c o m Iterator<AlumniIdentityCheckRequest> iter = Bennu.getInstance().getAlumniIdentityRequestSet().iterator(); while (iter.hasNext()) { request = iter.next(); if (request.getApproved() != null) { pendingRequests.add(request); } } return pendingRequests; }
From source file:com.msopentech.odatajclient.engine.communication.request.batch.ODataBatchUtilities.java
/** * Parses and adds the given header line to the given target map. * * @param headerLine header line to be added. * @param targetMap target map./*from w ww.java 2s .co m*/ */ public static void addHeaderLine(final String headerLine, final Map<String, Collection<String>> targetMap) { final int sep = headerLine.indexOf(':'); if (sep > 0 && sep < headerLine.length() - 1) { final String key = headerLine.substring(0, sep).trim(); final Collection<String> value; if (targetMap.containsKey(key)) { value = targetMap.get(key); } else { value = new HashSet<String>(); targetMap.put(key, value); } value.add(headerLine.substring(sep + 1, headerLine.length()).trim()); } }
From source file:es.pode.buscador.presentacion.avanzado.buscarAvanzado.BuscarAvanzadoCU.java
public static void loadSortingMethodCombo(Properties props, Collection sortingMethodLabelList, Collection sortingMethodValueList) { sortingMethodLabelList .add(props.getProperty("sortingMethod.relevance.label", "sortingMethod.relevance.label")); sortingMethodValueList.add("RELEVANCE"); int i = 1;//from w w w .ja v a2 s . co m String fieldname = props.getProperty("sortingMethod.field" + i); String fieldlabel = props.getProperty("sortingMethod.field" + i + ".label"); String fieldreverse = props.getProperty("sortingMethod.field" + i + ".reverse"); while (fieldname != null && fieldlabel != null && fieldreverse != null) { sortingMethodLabelList.add(fieldlabel); sortingMethodValueList.add(fieldname + "," + fieldreverse); i++; fieldname = props.getProperty("sortingMethod.field" + i); fieldlabel = props.getProperty("sortingMethod.field" + i + ".label"); fieldreverse = props.getProperty("sortingMethod.field" + i + ".reverse"); } sortingMethodLabelList.add(props.getProperty("sortingMethod.format.label", "sortingMethod.format.label")); sortingMethodValueList.add("FORMAT"); }
From source file:org.eclipse.lyo.testsuite.server.oslcv1tests.QueryTests.java
public static Collection<Object[]> getReferencedUrls(String base) throws IOException, XPathException, ParserConfigurationException, SAXException { Properties setupProps = SetupProperties.setup(null); String userId = setupProps.getProperty("userId"); String pw = setupProps.getProperty("pw"); HttpResponse resp = OSLCUtils.getResponseFromUrl(base, base, new UsernamePasswordCredentials(userId, pw), OSLCConstants.CT_DISC_CAT_XML + ", " + OSLCConstants.CT_DISC_DESC_XML); //If our 'base' is a ServiceDescription, find and add the simpleQuery service url if (resp.getEntity().getContentType().getValue().contains(OSLCConstants.CT_DISC_DESC_XML)) { Document baseDoc = OSLCUtils.createXMLDocFromResponseBody(EntityUtils.toString(resp.getEntity())); Node simpleQueryUrl = (Node) OSLCUtils.getXPath().evaluate("//oslc_cm:simpleQuery/oslc_cm:url", baseDoc, XPathConstants.NODE); Collection<Object[]> data = new ArrayList<Object[]>(); data.add(new Object[] { simpleQueryUrl.getTextContent() }); return data; }/* w w w . j av a 2 s . co m*/ String respBody = EntityUtils.toString(resp.getEntity()); Document baseDoc = OSLCUtils.createXMLDocFromResponseBody(respBody); //ArrayList to contain the urls from all of the SPCs Collection<Object[]> data = new ArrayList<Object[]>(); //Get all the ServiceDescriptionDocuments from this ServiceProviderCatalog NodeList sDescs = (NodeList) OSLCUtils.getXPath().evaluate("//oslc_disc:services/@rdf:resource", baseDoc, XPathConstants.NODESET); for (int i = 0; i < sDescs.getLength(); i++) { String serviceUrl = OSLCUtils.absoluteUrlFromRelative(base, sDescs.item(i).getNodeValue()); Collection<Object[]> subCollection = getReferencedUrls(serviceUrl); Iterator<Object[]> iter = subCollection.iterator(); while (iter.hasNext()) { data.add(iter.next()); } } //Get all ServiceProviderCatalog urls from the base document in order to recursively add all the //simple query services from the eventual service description documents from them as well. NodeList spcs = (NodeList) OSLCUtils.getXPath().evaluate( "//oslc_disc:entry/oslc_disc:ServiceProviderCatalog/@rdf:about", baseDoc, XPathConstants.NODESET); for (int i = 0; i < spcs.getLength(); i++) { String uri = spcs.item(i).getNodeValue(); uri = OSLCUtils.absoluteUrlFromRelative(base, uri); if (!uri.equals(base)) { Collection<Object[]> subCollection = getReferencedUrls(uri); Iterator<Object[]> iter = subCollection.iterator(); while (iter.hasNext()) { data.add(iter.next()); } } } return data; }
From source file:net.sourceforge.fenixedu.presentationTier.docs.academicAdministrativeOffice.ApprovementInfoForEquivalenceProcess.java
static private void reportApprovedCurriculumLines(final Collection<ICurriculumEntry> result, final Collection<CurriculumLine> lines) { for (final CurriculumLine line : lines) { if (line.isApproved()) { if (line.isEnrolment()) { result.add((IEnrolment) line); } else if (line.isDismissal() && ((Dismissal) line).getCredits().isSubstitution()) { result.addAll(((Dismissal) line).getSourceIEnrolments()); }/*from w w w.j ava2s . co m*/ } } }
From source file:com.datascience.gal.scripts.MainClient.java
private static Collection<MisclassificationCost> loadMisclassificationCosts(String costfile) { Collection<MisclassificationCost> out = new HashSet<MisclassificationCost>(); String[] lines_cost = Utils.getFile(costfile).split("\n"); for (String line : lines_cost) { String[] parts = line.split("\t"); if (parts.length < 3) { System.err.println("invalid cost input: " + line); continue; }//from www .j a v a 2 s . c o m out.add(new MisclassificationCost(parts[0], parts[1], Double.parseDouble(parts[2]))); } return out; }
From source file:com.netflix.spinnaker.clouddriver.kubernetes.v2.caching.agent.KubernetesCacheDataConverter.java
static Map<String, Collection<CacheData>> stratifyCacheDataByGroup(Collection<CacheData> ungroupedCacheData) { Map<String, Collection<CacheData>> result = new HashMap<>(); for (CacheData cacheData : ungroupedCacheData) { String key = cacheData.getId(); Keys.CacheKey parsedKey = Keys.parseKey(key).orElseThrow( () -> new IllegalStateException("Cache data produced with illegal key format " + key)); String group = parsedKey.getGroup(); Collection<CacheData> groupedCacheData = result.get(group); if (groupedCacheData == null) { groupedCacheData = new ArrayList<>(); }/*from w ww .jav a 2s .c o m*/ groupedCacheData.add(cacheData); result.put(group, groupedCacheData); } return result; }