List of usage examples for java.util Set contains
boolean contains(Object o);
From source file:edu.uci.ics.hyracks.api.client.impl.ActivityClusterGraphBuilder.java
private static Pair<ActivityId, ActivityId> findMergePair(JobActivityGraph jag, Set<Set<ActivityId>> eqSets) { for (Set<ActivityId> eqSet : eqSets) { for (ActivityId t : eqSet) { List<IConnectorDescriptor> inputList = jag.getActivityInputMap().get(t); if (inputList != null) { for (IConnectorDescriptor conn : inputList) { ActivityId inTask = jag.getProducerActivity(conn.getConnectorId()); if (!eqSet.contains(inTask)) { return Pair.<ActivityId, ActivityId>of(t, inTask); }/*from ww w . j av a2 s .com*/ } } List<IConnectorDescriptor> outputList = jag.getActivityOutputMap().get(t); if (outputList != null) { for (IConnectorDescriptor conn : outputList) { ActivityId outTask = jag.getConsumerActivity(conn.getConnectorId()); if (!eqSet.contains(outTask)) { return Pair.<ActivityId, ActivityId>of(t, outTask); } } } } } return null; }
From source file:edu.ucsb.cs.eager.sa.cerebro.ProfessorX.java
private static void analyzeRepo(String root, String name, String classPath, Collection<String> classes) { System.out.println("----------------- PROJECT: " + name + " -----------------\n"); File repoDir = new File(root, name); File classPathDir = new File(repoDir, classPath); Set<String> analyzedMethods = new HashSet<String>(); for (String className : classes) { Cerebro cerebro = new Cerebro(classPathDir.getAbsolutePath(), className); //cerebro.setVerbose(true); cerebro.setWholeProgramMode(true); Map<SootMethod, CFGAnalyzer> results = cerebro.analyze(); for (Map.Entry<SootMethod, CFGAnalyzer> entry : results.entrySet()) { String method = toString(entry.getKey()); if (analyzedMethods.contains(method)) { continue; }//from ww w.ja v a 2 s . c o m analyzedMethods.add(method); cerebro.setVerbose(true); cerebro.printResult(entry.getKey(), entry.getValue()); } cerebro.cleanup(); } System.out.println(); }
From source file:coolmapplugin.util.CMCyCommunicationUtil.java
private static List<Long> iterRowAndMatchNodeName(String jsonStringRows, Set<String> nodeNames) { LinkedList<Long> matchedNodeSUIDs = new LinkedList<>(); try {// www. ja v a 2 s .co m JSONArray jsonRows = new JSONArray(jsonStringRows); for (int i = 0; i < jsonRows.length(); ++i) { JSONObject jsonRow = jsonRows.getJSONObject(i); String nodeName = jsonRow.getString("name"); if (nodeNames.contains(nodeName)) { matchedNodeSUIDs.add(jsonRow.getLong("SUID")); } } } catch (JSONException e) { return null; } return matchedNodeSUIDs; }
From source file:org.openmrs.module.laboratory.web.util.LaboratoryUtil.java
public static String getInvestigationName(Concept concept, Map<Concept, Set<Concept>> testTreeMap) { for (Concept investigationConcept : testTreeMap.keySet()) { Set<Concept> set = testTreeMap.get(investigationConcept); if (set.contains(concept)) { if (conceptNames.containsKey(investigationConcept)) { return conceptNames.get(investigationConcept); } else { Concept newInvestigationConcept = Context.getConceptService() .getConcept(investigationConcept.getConceptId()); conceptNames.put(newInvestigationConcept, newInvestigationConcept.getName().getName()); return conceptNames.get(newInvestigationConcept); }/* ww w . j a v a 2 s .co m*/ } } return null; }
From source file:com.wso2telco.ids.utils.EndpointUtil.java
/** * Gets the login page url./*w ww .ja v a 2 s . c om*/ * * @param clientId the client id * @param sessionDataKey the session data key * @param forceAuthenticate the force authenticate * @param checkAuthentication the check authentication * @param scopes the scopes * @param reqParams the req params * @return the login page url * @throws UnsupportedEncodingException the unsupported encoding exception */ public static String getLoginPageURL(String clientId, String sessionDataKey, boolean forceAuthenticate, boolean checkAuthentication, Set<String> scopes, Map<String, String[]> reqParams) throws UnsupportedEncodingException { try { String type = "oauth2"; if (scopes != null && scopes.contains("openid")) { type = "oidc"; } String commonAuthURL = CarbonUIUtil.getAdminConsoleURL("/"); commonAuthURL = commonAuthURL.replace("carbon", "commonauth"); String selfPath = "/oauth2/authorize"; AuthenticationRequest authenticationRequest = new AuthenticationRequest(); // Build the authentication request context. authenticationRequest.setCommonAuthCallerPath(selfPath); // authenticationRequest.setForceAuth(String.valueOf(forceAuthenticate)); authenticationRequest.setForceAuth(forceAuthenticate); // authenticationRequest.setPassiveAuth(String.valueOf(checkAuthentication)); authenticationRequest.setPassiveAuth(checkAuthentication); authenticationRequest.setRelyingParty(clientId); authenticationRequest.addRequestQueryParam("tenantId", new String[] { String.valueOf(OAuth2Util.getClientTenatId()) }); authenticationRequest.setRequestQueryParams(reqParams); // Build an AuthenticationRequestCacheEntry which wraps // AuthenticationRequestContext AuthenticationRequestCacheEntry authRequest = new AuthenticationRequestCacheEntry( authenticationRequest); FrameworkUtils.addAuthenticationRequestToCache(sessionDataKey, authRequest); String loginQueryParams = "?sessionDataKey=" + sessionDataKey + "&" + "type" + "=" + type; return commonAuthURL + loginQueryParams; } finally { OAuth2Util.clearClientTenantId(); } }
From source file:com.wrmsr.wava.basic.BasicLoopInfo.java
public static Set<Name> getLoopContents(Name loop, Multimap<Name, Name> inputs, Multimap<Name, Name> backEdges) { Set<Name> seen = new HashSet<>(); seen.add(loop);//w ww. ja va 2 s . com Queue<Name> queue = new LinkedList<>(); inputs.get(loop).stream().filter(n -> !n.equals(loop) && backEdges.containsEntry(loop, n)) .forEach(queue::add); queue.forEach(seen::add); while (!queue.isEmpty()) { Name cur = queue.poll(); inputs.get(cur).stream().filter(input -> !seen.contains(input)).forEach(input -> { seen.add(input); queue.add(input); }); } return seen; }
From source file:org.metaservice.core.AbstractDispatcher.java
public static List<Statement> getGeneratedStatements(RepositoryConnection resultConnection, Set<Statement> loadedStatements) throws RepositoryException { RepositoryResult<Statement> all = resultConnection.getStatements(null, null, null, true); ArrayList<Statement> allList = new ArrayList<>(); HashSet<Resource> undefined = new HashSet<>(); while (all.hasNext()) { Statement s = all.next(); if (!loadedStatements.contains(s)) { if (s.getPredicate().equals(RDFS.SUBPROPERTYOF) || s.getPredicate().equals(RDFS.SUBCLASSOF) || s.getPredicate().equals(RDF.TYPE) && s.getObject().equals(RDFS.RESOURCE) || s.getPredicate().equals(RDF.TYPE) && s.getObject().equals(OWL.THING) || s.getPredicate().equals(RDF.TYPE) && s.getObject().equals(RDF.PROPERTY)) { if (!s.getSubject().stringValue().startsWith("http://metaservice.org/d/")) { LOGGER.debug("UNDEFINED {} {} {}", s.getSubject(), s.getPredicate(), s.getObject()); undefined.add(s.getSubject()); }/* w w w .ja v a2 s. c om*/ } else { if (s.getSubject() instanceof BNode || s.getObject() instanceof BNode) { LOGGER.error("ATTENTION - BNodes are not supported by Metaservice, skipping statement"); continue; } allList.add(s); } } } if (undefined.size() != 0) { //grep for logfiles: //grep "not defi" *| sed -e 's/^.*WARN.*define://' | uniq | sort | uniq | sed -e 's/,/\n/g' | tr -d ' ' | sort | uniq LOGGER.warn("Did not define: {}", StringUtils.join(undefined, ", ")); } return allList; }
From source file:edu.cmu.cs.lti.ark.fn.evaluation.PrepareFullAnnotationXML.java
/** * Given several parallel lists of predicted frame instances, including their frame elements, create an XML file * for the full-text annotation predicted by the model. * @param predictedFELines Lines encoding predicted frames & FEs in the same format as the .sentences.frame.elements files * @param sentenceNums Global sentence number for the first sentence being predicted, so as to map FE lines to items in parses/orgLines * @param parses Lines encoding the parse for each sentence * @param origLines The original sentences, untokenized * @return/*w w w . j a v a 2s . com*/ */ public static Document createXMLDoc(List<String> predictedFELines, Range sentenceNums, List<String> parses, List<String> origLines) { final Document doc = XmlUtils.getNewDocument(); final Element corpus = doc.createElement("corpus"); addAttribute(doc, "ID", corpus, "100"); addAttribute(doc, "name", corpus, "ONE"); addAttribute(doc, "XMLCreated", corpus, new Date().toString()); final Element documents = doc.createElement("documents"); corpus.appendChild(documents); final Element document = doc.createElement("document"); addAttribute(doc, "ID", document, "1"); addAttribute(doc, "description", document, "TWO"); documents.appendChild(document); final Element paragraphs = doc.createElement("paragraphs"); document.appendChild(paragraphs); final Element paragraph = doc.createElement("paragraph"); addAttribute(doc, "ID", paragraph, "2"); addAttribute(doc, "documentOrder", paragraph, "1"); paragraphs.appendChild(paragraph); final Element sentences = doc.createElement("sentences"); // Map sentence offsets to frame annotation data points within each sentence final TIntObjectHashMap<Set<String>> predictions = new TIntObjectHashMap<Set<String>>(); for (String feLine : predictedFELines) { final int sentNum = DataPointWithFrameElements.parseFrameNameAndSentenceNum(feLine).second; if (!predictions.containsKey(sentNum)) predictions.put(sentNum, new THashSet<String>()); predictions.get(sentNum).add(feLine); } for (int sent = sentenceNums.start; sent < sentenceNums.start + sentenceNums.length(); sent++) { final String parseLine = parses.get(sent - sentenceNums.start); final Element sentence = doc.createElement("sentence"); addAttribute(doc, "ID", sentence, "" + (sent - sentenceNums.start)); final Element text = doc.createElement("text"); final String origLine = origLines.get(sent - sentenceNums.start); final Node textNode = doc.createTextNode(origLine); text.appendChild(textNode); sentence.appendChild(text); final Element tokensElt = doc.createElement("tokens"); final String[] tokens = origLine.trim().split(" "); for (int i : xrange(tokens.length)) { final String token = tokens[i]; final Element tokenElt = doc.createElement("token"); addAttribute(doc, "index", tokenElt, "" + i); final Node tokenNode = doc.createTextNode(token); tokenElt.appendChild(tokenNode); tokensElt.appendChild(tokenElt); } sentence.appendChild(tokensElt); final Element annotationSets = doc.createElement("annotationSets"); int frameIndex = 0; // index of the predicted frame within the sentence final Set<String> feLines = predictions.get(sent); if (feLines != null) { final List<DataPointWithFrameElements> dataPoints = Lists.newArrayList(); for (String feLine : feLines) { final DataPointWithFrameElements dp = new DataPointWithFrameElements(parseLine, feLine); dp.processOrgLine(origLine); dataPoints.add(dp); } final Set<String> seenTargetSpans = Sets.newHashSet(); for (DataPointWithFrameElements dp : dataPoints) { final String targetIdxsString = Arrays.toString(dp.getTargetTokenIdxs()); if (seenTargetSpans.contains(targetIdxsString)) { System.err.println("Duplicate target tokens: " + targetIdxsString + ". Skipping. Sentence id: " + sent); continue; // same target tokens should never show up twice in the same sentence } else { seenTargetSpans.add(targetIdxsString); } assert dp.rank == 1; // this doesn't work with k-best lists anymore final String frame = dp.getFrameName(); // Create the <annotationSet> Element for the predicted frame annotation, and add it under the sentence Element annotationSet = buildAnnotationSet(frame, ImmutableList.of(dp), doc, sent - sentenceNums.start, frameIndex); annotationSets.appendChild(annotationSet); frameIndex++; } } sentence.appendChild(annotationSets); sentences.appendChild(sentence); } paragraph.appendChild(sentences); doc.appendChild(corpus); return doc; }
From source file:de.micromata.genome.jpa.metainf.MetaInfoUtils.java
private static void addDepsFirst(EntityMetadata table, Set<EntityMetadata> remainsings, List<EntityMetadata> sortedTable) { if (remainsings.contains(table) == false) { return;// w w w . ja v a 2 s. c o m } remainsings.remove(table); for (EntityMetadata nt : table.getReferencedBy()) { addDepsFirst(nt, remainsings, sortedTable); } sortedTable.add(table); }
From source file:disko.DU.java
public static boolean isSubset(Set<Object> left, Set<Object> right) { for (Object x : left) if (!right.contains(x)) return false; return true;//from www. j a va 2 s . com }