List of usage examples for java.util ArrayList contains
public boolean contains(Object o)
From source file:com.evolveum.midpoint.common.policy.ValuePolicyGenerator.java
/** * Count cardinality//w w w . j ava 2 s . c o m */ private static HashMap<Integer, ArrayList<String>> cardinalityCounter( HashMap<StringLimitType, ArrayList<String>> lims, ArrayList<String> password, Boolean skipMatchedLims, boolean uniquenessReached, OperationResult op) { HashMap<String, Integer> counter = new HashMap<String, Integer>(); for (StringLimitType l : lims.keySet()) { int counterKey = 1; ArrayList<String> chars = lims.get(l); int i = 0; if (null != password) { i = charIntersectionCounter(lims.get(l), password); } // If max is exceed then error unable to continue if (l.getMaxOccurs() != null && i > l.getMaxOccurs()) { OperationResult o = new OperationResult("Limitation check :" + l.getDescription()); o.recordFatalError("Exceeded maximal value for this limitation. " + i + ">" + l.getMaxOccurs()); op.addSubresult(o); return null; // if max is all ready reached or skip enabled for minimal skip // counting } else if (l.getMaxOccurs() != null && i == l.getMaxOccurs()) { continue; // other cases minimum is not reached } else if ((l.getMinOccurs() == null || i >= l.getMinOccurs()) && !skipMatchedLims) { continue; } for (String s : chars) { if (null == password || !password.contains(s) || uniquenessReached) { // if (null == counter.get(s)) { counter.put(s, counterKey); // } else { // counter.put(s, counter.get(s) + 1); // } } } counterKey++; } // If need to remove disabled chars (already reached limitations) if (null != password) { for (StringLimitType l : lims.keySet()) { int i = charIntersectionCounter(lims.get(l), password); if (l.getMaxOccurs() != null && i > l.getMaxOccurs()) { OperationResult o = new OperationResult("Limitation check :" + l.getDescription()); o.recordFatalError("Exceeded maximal value for this limitation. " + i + ">" + l.getMaxOccurs()); op.addSubresult(o); return null; } else if (l.getMaxOccurs() != null && i == l.getMaxOccurs()) { // limitation matched remove all used chars LOGGER.trace("Skip " + l.getDescription()); for (String charToRemove : lims.get(l)) { counter.remove(charToRemove); } } } } // Transpone to better format HashMap<Integer, ArrayList<String>> ret = new HashMap<Integer, ArrayList<String>>(); for (String s : counter.keySet()) { // if not there initialize if (null == ret.get(counter.get(s))) { ret.put(counter.get(s), new ArrayList<String>()); } ret.get(counter.get(s)).add(s); } return ret; }
From source file:it.iit.genomics.cru.simsearch.bundle.utils.AnnotationsFromTrack.java
public Collection<String> getAnnotationsByNumberOfOverlap() { ArrayList<Integer> counts = new ArrayList<>(); counts.addAll(annotationsMappedCount.values()); Collections.sort(counts);//w w w . j av a2 s .co m Collections.reverse(counts); ArrayList<String> sortedAnnotations = new ArrayList<>(); for (Integer count : counts) { for (String annotation : getAnnotations()) { if (annotationsMappedCount.get(annotation).equals(count) && false == sortedAnnotations.contains(annotation)) { sortedAnnotations.add(annotation); } } } return sortedAnnotations; }
From source file:gda.device.scannable.component.UnitsComponent.java
/** * Sets the hardware unit to hardwareUnitString. If a user unit has not been explicitly set then the user unit is * also set to hardwareUnitString. If the user unit has been explicitly set and the new hardware unit would * invalidate this then a DeviceException is thrown. * <p>/* ww w . jav a 2s . co m*/ * Based on this string, this method will build a list of acceptable user-units. Afterwards, the acceptable units * list can be added to via the addAcceptableUnits method if the defaults do not cover enough. * <p> * * @param hardwareUnitString * The hardwareUnitString to use. * @throws DeviceException */ public void setHardwareUnitString(String hardwareUnitString) throws DeviceException { if (userUnitHasBeenExplicitelySet) { // Check the new hardware unit is compatible final ArrayList<Unit<? extends Quantity>> compatibleUnits = generateCompatibleUnits(hardwareUnitString); if (!compatibleUnits.contains(userUnit)) { throw new DeviceException("The hardware unit could not be set to '" + hardwareUnitString + "' because this is incompatible" + " with the explicitely set user unit '" + userUnit.toString() + "'"); } } actuallySetHardwareUnitString(hardwareUnitString); hardwareUnitHasBeenExplicitelySet = true; if (!userUnitHasBeenExplicitelySet) { try { actuallySetUserUnits(hardwareUnitString); } catch (DeviceException e) { throw new Error("Error in setHardwareUnitString for " + hardwareUnitString, e); } } }
From source file:it.iit.genomics.cru.simsearch.bundle.utils.AnnotationsFromTrack.java
public Collection<String> getAnnotationsByPvalueIncreasing() { ArrayList<Double> probabilities = new ArrayList<>(); probabilities.addAll(pValues.values()); Collections.sort(probabilities); ArrayList<String> sortedAnnotations = new ArrayList<>(); for (Double probability : probabilities) { for (String annotation : getAnnotations()) { if (pValues.get(annotation).equals(probability) && false == sortedAnnotations.contains(annotation)) { sortedAnnotations.add(annotation); }// w w w . j a va 2 s. com } } return sortedAnnotations; }
From source file:org.apache.servicemix.wsn.jms.JmsSubscription.java
public void onMessage(String message) { // System.out.println("onMessaged1"); String text = message;/*w w w .j av a 2 s .c o m*/ //(super.subscriberAddress != null) && (!super.subscriberAddress.equals("http://localhost:12345/only/register/use")) if (true) { try { // System.out.println("onMessaged2"); // if( httpPost==null ) // httpPost = new HttpPost(super.subscriberAddress); // System.out.println("TextMessage:"+text); int start = text.indexOf("TopicExpression/Simple\">") + 24; int end = text.indexOf("</wsnt:Topic>"); String topicName = text.substring(start, end); //flag == if (true) { // System.out.println("onMessaged3"); //? String[] topicPath = topicName.split(":"); WSNTopicObject current = WsnProcessImpl.topicTree; int flag = 0; for (int i = 0; i < topicPath.length - 1; i++) { // System.out.println("current.getTopicentry().getTopicName():"+current.getTopicentry().getTopicName()+" topicPath[i]"+topicPath[i]); if (current.getTopicentry().getTopicName().equals(topicPath[i])) { for (int counter = 0; counter < current.getChildrens().size(); counter++) { // System.out.println("---:"+current.getChildrens().get(counter).getTopicentry().getTopicName()); if (current.getChildrens().get(counter).getTopicentry().getTopicName() .equals(topicPath[i + 1])) { current = current.getChildrens().get(counter); flag++; break; } } } else { System.out.println("notify faild! there is not this topic in the topic tree!"); } } //???????? if (flag == topicPath.length - 1) { System.out.println("match success!"); ArrayList<String> sendedaddr = new ArrayList<String>(); while (current != null) { for (int i = 0; i < current.getSubscribeAddress().size(); i++) { if (sendedaddr.contains(current.getSubscribeAddress().get(i))) continue; sendedaddr.add(current.getSubscribeAddress().get(i)); JmsSubscription.diliverToWebservice.doPush(current.getSubscribeAddress().get(i), text, JmsSubscription.asyClient, new HttpPost(current.getSubscribeAddress().get(i)), this); } current = current.getParent(); } } else { System.out.println("notify faild! there is not this topic"); } } // infoTemp.clear(); ArrayList<String> infoTemp = new ArrayList<String>(); /** * ???? * ? * ??? */ if (text.length() > 3000) { breakPackage(text, infoTemp); // Thread.sleep(0); } else { infoTemp.add(text); } System.out.println("infoTemp:" + infoTemp.size()); for (int q = 0; q < infoTemp.size(); q++) { // System.out.println("JMS-message: " + infoTemp.get(q)); NotifyObserver notifyObserver = new NotifyObserver(); notifyObserver.addObserver(RtMgr.getInstance()); ObserveMutiThread om = new ObserveMutiThread(infoTemp.get(q), notifyObserver); om.run(); if (infoTemp.size() > 1) Thread.sleep(5); } } catch (Exception e) { e.printStackTrace(); log.warn("Error notifying consumer", e); } } }
From source file:gov.nih.nci.rembrandt.web.ajax.DynamicReportGenerator.java
public void generateDynamicReport(String key, Map<String, String> params) { String html = new String(); HttpSession session = ExecutionContext.get().getSession(false); PresentationTierCache ptc = ApplicationFactory.getPresentationTierCache(); BusinessTierCache btc = ApplicationFactory.getBusinessTierCache(); HttpServletRequest request = ExecutionContext.get().getHttpServletRequest(); // HttpServletResponse response = ExecutionContext.get().getHttpServletResponse(); //lets hold a list of xml generating jobs, so we dont keep kicking off the same job ArrayList jobs = session.getAttribute("xmlJobs") != null ? (ArrayList) session.getAttribute("xmlJobs") : new ArrayList(); //only generate XML if its not already cached...leave off for debug if (ptc.getNonPersistableObjectFromSessionCache(session.getId(), key) == null && !jobs.contains(key)) { Object o = btc.getObjectFromSessionCache(session.getId(), key); Finding finding = (Finding) o;/*from w ww. j a v a 2 s. c o m*/ //generate the XML and cached it ReportGeneratorHelper.generateReportXML(finding); if (!jobs.contains(key)) jobs.add(key); session.setAttribute("xmlJobs", jobs); } Object ob = ptc.getNonPersistableObjectFromSessionCache(session.getId(), key); if (ob != null && ob instanceof FindingReportBean) { try { FindingReportBean frb = (FindingReportBean) ob; Document reportXML = (Document) frb.getXmlDoc(); html = ReportGeneratorHelper.renderReport(params, reportXML, "cc_report.xsl"); jobs.remove(key); session.setAttribute("xmlJobs", jobs); } catch (Exception e) { html = "Error Generating the report."; StringWriter stack = new StringWriter(); e.printStackTrace(new PrintWriter(stack)); html = stack.toString(); } } else { html = "Error generating the report"; } //out the XHTML in the session for reference in presentation...could store in Prescache session.setAttribute(key + "_xhtml", html); return; }
From source file:com.jzboy.couchdb.DatabaseDocReadTest.java
@Test public void testQueryView() throws Exception { List<NameValuePair> params = new ArrayList<NameValuePair>() { {// ww w. j ava 2s. co m add(new BasicNameValuePair("include_docs", "true")); } }; ArrayList<Document> results = instance.queryView(designDocName, viewName, params); ArrayList<String> expDocIds = new ArrayList<String>(); for (Map.Entry<String, String> entry : docs.entrySet()) { if (entry.getValue().contains("\"show\":true")) { expDocIds.add(entry.getKey()); } } assertEquals("queryView didn't return the expected number of docs", expDocIds.size(), results.size()); for (Document doc : results) { assertTrue("queryView didn't return a document that should have been", expDocIds.contains(doc.getId())); assertTrue("Doc returned by queryView has no key", doc.hasKey()); String str = docs.get(doc.getId()); JsonNode exp = JsonUtils.createParser(str).readValueAsTree(); assertEquals("JSON contents of doc returned by queryView didn't match the original", exp, doc.getJson()); } }
From source file:com.bayontechnologies.bi.pentaho.plugin.openflashchart.OpenFlashChartComponent.java
protected boolean executeAction() { //get the input datas IPentahoResultSet data = (IPentahoResultSet) getInputValue(CHART_DATA_PROP); String chartTemplateString = getInputStringValue(CHART_TEMPLATE_STRING); Integer chartWidth = null;//from w w w . j av a 2s .c o m IPentahoSession userSession = this.getSession(); String input1 = getInputStringValue(CHART_WIDTH); if (null == input1) { chartWidth = new Integer(this.width); } else { chartWidth = Integer.valueOf(input1); } Integer chartHeight = null; String input2 = getInputStringValue(CHART_HEIGHT); if (null == input2) { chartHeight = new Integer(this.height); } else { chartHeight = Integer.valueOf(input2); } IActionResource fileResource = null; String ofcURL = getInputStringValue(OFC_URL); if (ofcURL == null || "".equals(ofcURL)) { ofcURL = "/pentaho-style/images/open-flash-chart.swf"; } if (chartTemplateString == null || chartTemplateString.equals("")) { fileResource = this.getResource(CHART_TEMPLATE); try { chartTemplateString = PentahoSystem.getSolutionRepository(userSession) .getResourceAsString(fileResource); } catch (IOException e) { error(e.getLocalizedMessage()); return false; } } //parse the chart Template String and get the parsed tokens map = parseString(chartTemplateString); chartTemplateString = replaceChartDefParams(chartTemplateString, data); //replace the custom variables ArrayList<String> customs = map.get("customs"); Set inputNames = this.getInputNames(); for (Iterator iterator = inputNames.iterator(); iterator.hasNext();) { String name = (String) iterator.next(); if (customs.contains(name)) { Object value = this.getInputValue(name); chartTemplateString = replaceLongStr(chartTemplateString, "{" + name + "}", "" + value); } } log.debug("chartTemplateString after replacing:" + chartTemplateString); String solutionName = this.getSolutionName(); //uuid String uuid = "openFlashChart-" + UUIDUtil.getUUIDAsString(); IContentRepository repository = ContentRepository.getInstance(userSession); IContentLocation cl = null; cl = repository.getContentLocationByPath(LOCATION_DIR_PATH); if (cl == null) cl = repository.newContentLocation(LOCATION_DIR_PATH, solutionName, solutionName, this.getId(), true); //Fix me, to create a new contentitem every time is not a good choice. //Maybe we can remove the older and create a new one. But I can't find the solution right now. :( IContentItem citem = cl.newContentItem(uuid, uuid, this.getActionTitle(), "txt", "text/plain", "", IContentItem.WRITEMODE_OVERWRITE); try { //get the outputstream and write the content into the repository. OutputStream os = citem.getOutputStream(this.getActionName()); os.write(chartTemplateString.getBytes(LocaleHelper.getSystemEncoding())); os.close(); } catch (IOException e) { error(e.getLocalizedMessage()); return false; } //replace the parameters in the flashFragment String flashContent = replace(flashFragment, citem.getId(), chartWidth, chartHeight, ofcURL); log.debug("html_fragment=" + flashContent); Set outputNames = this.getOutputNames(); if (outputNames.contains("html_fragment")) { this.setOutputValue("html_fragment", flashContent); } if (outputNames.contains("content_url")) { this.setOutputValue("content_url", this.getTmpContentURL(citem.getId())); } return true; }
From source file:Main.java
@SuppressLint("UseSparseArrays") public static ArrayList<String> extractor(Notification notification) { ArrayList<String> notifText = new ArrayList<String>(); RemoteViews views = notification.contentView; @SuppressWarnings("rawtypes") Class secretClass = views.getClass(); try {/*www.ja va 2s . c om*/ Field outerFields[] = secretClass.getDeclaredFields(); for (int i = 0; i < outerFields.length; i++) { if (!outerFields[i].getName().equals("mActions")) continue; outerFields[i].setAccessible(true); @SuppressWarnings("unchecked") ArrayList<Object> actions = (ArrayList<Object>) outerFields[i].get(views); for (Object action : actions) { Field innerFields[] = action.getClass().getDeclaredFields(); Object value = null; Integer type = null; @SuppressWarnings("unused") Integer viewId = null; for (Field field : innerFields) { field.setAccessible(true); if (field.getName().equals("value")) { value = field.get(action); } else if (field.getName().equals("type")) { type = field.getInt(action); } else if (field.getName().equals("viewId")) { viewId = field.getInt(action); } } if (type != null && (type == 9 || type == 10) && value != null) { // System.out.println("Type: " + Integer.toString(type) // + " Value: " + value.toString()); if (!notifText.contains(value.toString())) notifText.add(value.toString()); } } } } catch (Exception e) { e.printStackTrace(); } return notifText; }
From source file:MSUmpire.SeqUtility.FastaParser.java
public void AddFirstMetDroppedPep(String Sequence, int missedcleave, int minlength, int maxlength, ArrayList<String> TheoPeptides) { if (String.valueOf(Sequence.charAt(0)).equals("M")) { int mc = 0; for (int i = 1; i < Sequence.length(); i++) { if (String.valueOf(Sequence.charAt(i)).equals("K") || String.valueOf(Sequence.charAt(i)).equals("R")) { mc++;/*from ww w . ja v a2 s. co m*/ if (mc > missedcleave) { return; } String pep = Sequence.substring(1, i + 1); if (pep.length() >= minlength && pep.length() <= maxlength && !TheoPeptides.contains(pep)) { TheoPeptides.add(pep); } } } } }