List of usage examples for java.util HashSet contains
public boolean contains(Object o)
From source file:com.sec.ose.osi.sdk.protexsdk.bom.BOMReportAPIWrapper.java
public static ArrayList<IdentifiedFilesRow> getIdentifiedFilesFromBOMReport(String projectName, UIResponseObserver observer) {/* w w w . j a va 2s. co m*/ log.debug("createIdentifiedFilewRowList"); String msgHead = "Creating Identified Files Sheet: - " + projectName + "\n"; observer.setMessageHeader(msgHead); // get Identified Files String pMessage = msgHead + " > Getting [Identified Files] information from server.\n"; observer.pushMessage(pMessage); ReportEntityList identifiedFilesEntList = ReportAPIWrapper.getIdentifiedFiles(projectName, observer, true); if (identifiedFilesEntList == null) return null; if (identifiedFilesEntList.size() == 0) return null; // get Compare Code Matches pMessage = msgHead + " > Getting [Compare Code Matches] information from server.\n"; observer.pushMessage(pMessage); ReportEntityList compareCodeMatches = ReportAPIWrapper.getCompareCodeMatches(projectName, observer, true); if (compareCodeMatches == null) return null; if (compareCodeMatches.size() == 0) return null; log.debug("create IdentifiedFilesRow"); HashSet<String> duplicateCheckSet = new HashSet<String>(); ArrayList<IdentifiedFilesRow> IdentifiedFilesRowList = new ArrayList<IdentifiedFilesRow>( identifiedFilesEntList.size()); for (ReportEntity entity : identifiedFilesEntList) { String filePath = entity.getValue(ReportInfo.IDENTIFIED_FILES.FILE_FOLDER_NAME); String componentName = entity.getValue(ReportInfo.IDENTIFIED_FILES.COMPONENT); String componentVersion = entity.getValue(ReportInfo.IDENTIFIED_FILES.VERSION); String fileComment = entity.getValue(ReportInfo.IDENTIFIED_FILES.COMMENT); String fileLicense = parseFileLicense(entity.getValue(ReportInfo.IDENTIFIED_FILES.LICENSE)); String discoveryType = entity.getValue(ReportInfo.IDENTIFIED_FILES.DISCOVERY_TYPE); if (componentName.equals("") && componentVersion.equals("") && fileLicense.equals("")) { continue; } String duplicateCheck = filePath + componentName + fileLicense; if (duplicateCheckSet.contains(duplicateCheck) == true) { continue; } duplicateCheckSet.add(duplicateCheck); IdentifiedFilesRowList.add(new IdentifiedFilesRow(projectName, filePath, componentName, fileLicense, discoveryType, fileComment)); } log.debug("update code match info"); HashMap<String, CodeMatchEnt> codeMatchInfoMap = new HashMap<String, CodeMatchEnt>( compareCodeMatches.size()); for (ReportEntity entity : compareCodeMatches) { String fullPath = entity.getValue(ReportInfo.COMPARE_CODE_MATCHES.FULL_PATH); String codeMatchCnt = entity.getValue(ReportInfo.COMPARE_CODE_MATCHES.CODE_MATCH_COUNT); String url = entity.getValue(ReportInfo.COMPARE_CODE_MATCHES.COMPARE_CODE_MATCHES_LINK); url = url.replaceFirst("127.0.0.1", LoginSessionEnt.getInstance().getProtexServerIP()); codeMatchInfoMap.put(fullPath, new CodeMatchEnt(fullPath, codeMatchCnt, url)); } for (IdentifiedFilesRow fileEnt : IdentifiedFilesRowList) { CodeMatchEnt codeMatchEnt = codeMatchInfoMap.get(fileEnt.getFullPath()); if (CODE_MATCH.equals(fileEnt.getDiscoveryType())) { fileEnt.setUrl(codeMatchEnt.url); fileEnt.setCodeMatchCnt(codeMatchEnt.codeMatchCnt); } } String msg = IdentifiedFilesRowList.size() + " files are loaded."; observer.pushMessage(msg); log.debug(msg); log.debug("start Garbage collector in BOMReportAPIWrapper"); System.gc(); log.debug("finish Garbage collector in BOMReportAPIWrapper"); return IdentifiedFilesRowList; }
From source file:org.mumod.util.ImageManager.java
public void cleanup(HashSet<String> keepers) { String[] files = mContext.fileList(); HashSet<String> hashedUrls = new HashSet<String>(); for (String imageUrl : keepers) { hashedUrls.add(getMd5(imageUrl)); }//from w ww. j a va 2 s . c om for (String file : files) { if (!hashedUrls.contains(file)) { if (MustardApplication.DEBUG) Log.i(TAG, "Deleting unused file: " + file); mContext.deleteFile(file); } } }
From source file:com.edmunds.zookeeper.treewatcher.ZooKeeperTreeState.java
private List<ZooKeeperTreeNode> getDeletedChildren(ZooKeeperTreeNode parent, Collection<String> children) { final List<ZooKeeperTreeNode> deletedChildren = Lists.newArrayList(); final HashSet<String> childrenSet = Sets.newHashSet(children); for (ZooKeeperTreeNode child : parent.getChildren().values()) { if (!childrenSet.contains(child.getName())) { deletedChildren.add(child);/* www. jav a 2s. c o m*/ } } return deletedChildren; }
From source file:com.cyclopsgroup.tornado.hibernate.HqlLargeList.java
/** * Overwrite or implement method iterate() * * @see com.cyclopsgroup.waterview.LargeList#iterate(int, int, com.cyclopsgroup.waterview.LargeList.Sorting[]) *///from w ww .java2s .co m public Iterator iterate(int startPosition, int maxRecords, Sorting[] sortings) throws Exception { if (StringUtils.isEmpty(hql)) { throw new IllegalStateException("query is still emtpy"); } Session s = hibernate.getSession(dataSource); StringBuffer sb = new StringBuffer(hql); boolean first = true; for (int i = 0; i < sortings.length; i++) { Sorting sorting = sortings[i]; if (first) { sb.append(" ORDER BY "); first = false; } else { sb.append(", "); } sb.append(sorting.getName()); if (sorting.isDescending()) { sb.append(" DESC"); } } Query q = s.createQuery(sb.toString()); HashSet parameterNames = new HashSet(); CollectionUtils.addAll(parameterNames, q.getNamedParameters()); for (Iterator i = parameters.values().iterator(); i.hasNext();) { Parameter p = (Parameter) i.next(); if (parameterNames.contains(p.getName())) { q.setParameter(p.getName(), p.getValue(), p.getType()); } } q.setFirstResult(startPosition); if (maxRecords > 0) { q.setMaxResults(maxRecords); } return q.iterate(); }
From source file:org.bpmscript.correlation.CorrelationSupportTest.java
/** * Test method for {@link org.bpmscript.correlation.CorrelationSupport#getHash(byte[])}. * @throws Exception //from w ww. java2 s . c om */ public void testGetHash() throws Exception { CorrelationSupport correlationSupport = new CorrelationSupport(); HashSet<String> hashes = new HashSet<String>(); for (int i = 0; i < 10000; i++) { Object[] values = new Object[3]; values[0] = i; values[1] = "test " + i; values[2] = "randomblahblah"; String hash = correlationSupport.getHash(correlationSupport.getBytes(values)); if (hashes.contains(hash)) { fail("Duplicate hash found"); } hashes.add(hash); } }
From source file:com.facebook.tsdb.tsdash.server.model.Metric.java
public HashMap<String, HashSet<String>> getTagsSet() { HashMap<String, HashSet<String>> tagsSet = new HashMap<String, HashSet<String>>(); for (TagsArray rowTags : timeSeries.keySet()) { for (Tag tag : rowTags.asArray()) { if (!tagsSet.containsKey(tag.key)) { tagsSet.put(tag.key, new HashSet<String>()); }//from w w w.ja va2 s. c om HashSet<String> values = tagsSet.get(tag.key); if (!tag.valueID.isNull() && !values.contains(tag.value)) { values.add(tag.value); } } } return tagsSet; }
From source file:edu.harvard.i2b2.patientMapping.serviceClient.IMQueryClient.java
public static String getlldString(ArrayList<TimelineRow> tlrows, String patientRefId, int minPatient, int maxPatient, boolean bDisplayAll, boolean writeFile, boolean displayDemographics, MainComposite explorer) {/* w w w . ja v a 2 s .com*/ try { HashSet<String> conceptPaths = new HashSet<String>(); // HashSet<String> providerPaths = new HashSet<String>(); // HashSet<String> visitPaths = new HashSet<String>(); ArrayList<PDOItem> items = new ArrayList<PDOItem>(); for (int i = 0; i < tlrows.size(); i++) { for (int j = 0; j < tlrows.get(i).pdoItems.size(); j++) { PDOItem pdoItem = tlrows.get(i).pdoItems.get(j); String path = pdoItem.fullPath; if (conceptPaths.contains(path)) { //continue; } conceptPaths.add(path); // for(int k=0; k<pdoItem.valDisplayProperties.size(); k++) // { items.add(pdoItem); // } } } PDORequestMessageModel pdoFactory = new PDORequestMessageModel(); String pid = null; if (patientRefId.equalsIgnoreCase("All")) { pid = "-1"; } else { pid = patientRefId; } String xmlStr = pdoFactory.requestXmlMessage(items, pid, new Integer(minPatient), new Integer(maxPatient), false); // explorer.lastRequestMessage(xmlStr); String result = null;// sendPDOQueryRequestREST(xmlStr); if (System.getProperty("webServiceMethod").equals("SOAP")) { result = IMQueryClient.sendPDOQueryRequestSOAP(xmlStr); } else { result = IMQueryClient.sendSetKeyQueryRequestREST(xmlStr); } if (result == null || result.equalsIgnoreCase("memory error")) { return result; } // explorer.lastResponseMessage(result); return new PatientMappingFactory().generateTimelineData(result, tlrows, writeFile, bDisplayAll, displayDemographics, explorer); } /* * catch(org.apache.axis2.AxisFault e) { e.printStackTrace(); * java.awt.EventQueue.invokeLater(new Runnable() { public void run() { * JOptionPane.showMessageDialog(null, * "Trouble with connection to the remote server, " + * "this is often a network error, please try again", "Network Error", * JOptionPane.INFORMATION_MESSAGE); } }); * * return null; } */ catch (Exception e) { e.printStackTrace(); return null; } }
From source file:org.callistasoftware.netcare.core.job.SystemAlarmJob.java
private void activities(Date endDate) { List<ScheduledActivityEntity> sal = saRepo.findByScheduledTimeLessThanAndReportedTimeIsNull(endDate); log.info("Alarm activity job: {} activities over due ({})", sal.size(), endDate); List<AlarmEntity> al = new LinkedList<AlarmEntity>(); List<ScheduledActivityEntity> saSave = new LinkedList<ScheduledActivityEntity>(); HashSet<Long> patients = new HashSet<Long>(); for (ScheduledActivityEntity sae : sal) { PatientEntity patient = sae.getActivityDefinitionEntity().getHealthPlan().getForPatient(); if (!patients.contains(patient.getId())) { AlarmEntity ae = AlarmEntity.newEntity(AlarmCause.UNREPORTED_ACTIVITY, patient, sae.getActivityDefinitionEntity().getHealthPlan().getCareUnit().getHsaId(), sae.getId()); ae.setInfo(sae.getActivityDefinitionEntity().getHealthPlan().getName()); al.add(ae);/*www. j a v a 2 s .c om*/ patients.add(patient.getId()); } sae.setStatus(ScheduledActivityStatus.CLOSED); sae.setReportedTime(new Date()); sae.setNote("Stngd per automatik."); saSave.add(sae); } log.info("Alarm activity job: {} new activity alarms!", al.size()); if (al.size() > 0) { alRepo.save(al); } if (saSave.size() > 0) { saRepo.save(saSave); } }
From source file:azkaban.web.pages.FlowExecutionServlet.java
private void traverseFlow(HashSet<String> visitedJobs, HashSet<String> disabledJobs, ExecutableFlow flow) { String name = flow.getName(); // Pretty much mark visited nodes and prevent unnecessary traversals. if (visitedJobs.contains(name)) { return;//from ww w . j a va 2 s .c o m } flow.reset(); if (flow instanceof IndividualJobExecutableFlow && disabledJobs.contains(name)) { IndividualJobExecutableFlow individualJob = (IndividualJobExecutableFlow) flow; individualJob.setStatus(Status.IGNORED); System.out.println("ignore " + name); visitedJobs.add(name); } else { if (flow instanceof ComposedExecutableFlow) { ExecutableFlow innerFlow = ((ComposedExecutableFlow) flow).getDepender(); traverseFlow(visitedJobs, disabledJobs, innerFlow); } else if (flow instanceof MultipleDependencyExecutableFlow) { traverseFlow(visitedJobs, disabledJobs, ((MultipleDependencyExecutableFlow) flow).getActualFlow()); } else if (flow instanceof WrappingExecutableFlow) { traverseFlow(visitedJobs, disabledJobs, ((WrappingExecutableFlow) flow).getDelegateFlow()); } for (ExecutableFlow childFlow : flow.getChildren()) { traverseFlow(visitedJobs, disabledJobs, childFlow); } } }
From source file:com.tremolosecurity.proxy.ProxyRequest.java
@Override public Enumeration getParameterNames() { HashSet<String> paramListLocal = new HashSet<String>(); paramListLocal.addAll(this.paramList); for (NVP p : this.queryString) { if (!paramListLocal.contains(p.getName())) { paramListLocal.add(p.getName()); }/*from www .ja v a 2 s . com*/ } return new IteratorEnumeration(paramListLocal.iterator()); }