List of usage examples for org.springframework.util StringUtils countOccurrencesOf
public static int countOccurrencesOf(String str, String sub)
From source file:org.zilverline.extractors.TestHTMLExtractor.java
public void testGetContentAsString() { try {// ww w .j ava 2 s . co m HTMLExtractor tex = new HTMLExtractor(); String html = "<HTML><BODY>here is <B>text</B> to test</BODY></HTML>"; String txt = tex.getContent(html); assertNotNull(txt); log.debug(txt); assertTrue(txt.length() > 0); assertTrue(txt.trim().startsWith("here is text")); assertTrue(StringUtils.countOccurrencesOf(txt, "test") > 0); } catch (Exception e) { fail(e.getMessage()); } }
From source file:au.org.ala.layers.util.BatchProducer.java
private static int getPointCount(String batchPath, String batchId) throws IOException { int count = 0; String dir = batchPath + File.separator + batchId + File.separator; if (new File(dir).exists()) { File f = new File(dir + "points.txt"); if (f.exists() && f.length() > 0) { count = (StringUtils.countOccurrencesOf(FileUtils.readFileToString(f), ",") + 1) / 2; }// www . ja va2s . c o m } return count; }
From source file:app.web.SeleniumPage.java
public Page clickAndWaitForLoadIfNecessary(String locator, boolean forceWaitForLoad) { String previousHtmlSource = this.getHtmlSource(); String previousLocation = this.getLocation(); boolean[] previousVisibilityArray = getVisibilityArray(); this.click(locator); boolean isNewPageLoaded = this.waitForLoadIfNecessary(forceWaitForLoad); // this.getActionStack().lastElement().getType() == Page.Action.ActionType.CLICK_NEW_PAGE || this.getActionStack().lastElement().getType() == Page.Action.ActionType.CLICK_SAME_PAGE; Page.Action action;//w w w .j a va 2 s . c o m if (isNewPageLoaded) { String currentLocation = this.getLocation(); action = currentLocation.equals(previousLocation) ? Page.Action.navigationSamePage(locator) : Page.Action.navigationNewPage(locator, currentLocation); } else { String currentHtmlSource = this.getHtmlSource(); if (!currentHtmlSource.equals(previousHtmlSource)) { // Compare the number of tags if (StringUtils.countOccurrencesOf(currentHtmlSource, "<") == StringUtils .countOccurrencesOf(previousHtmlSource, "<")) { List<String> xpathList = new ArrayList<String>(); for (int xpathIndex : compareVisibilityArray(previousVisibilityArray, this.getVisibilityArray())) { xpathList.add("(//*)[" + (xpathIndex + 1) + "]"); //array 0-based, xpath 1-based } // if (!xpathList.isEmpty()) // log.info("Test newly visible content"); // '" + getFailSafeText(xpathList.get(0)) + "'"); action = Page.Action.domUpdate(locator, xpathList.size() > 0 ? xpathList.toArray(new String[xpathList.size()]) : null); } else { String ajaxContentId = compareHtmlSourceAfterAjaxLoad(previousHtmlSource, currentHtmlSource); // log.info("Test new ajax content under id " + ajaxContentId); action = Page.Action.ajaxUpdate(locator, "//*[@id='" + ajaxContentId + "']"); } } else { action = Page.Action.noChange(locator); } } this.getActionStack().push(action); return this; }
From source file:org.jasig.ssp.util.importer.job.csv.FlatFileItemReaderNewLine.java
private Boolean isIncomplete(String line) { Integer count = StringUtils.countOccurrencesOf(line, "\""); if (count % 2 == 0) return false; return true;// w ww .j a va 2 s .c o m }
From source file:org.web4thejob.web.zbox.PropertyBox.java
private boolean isTooltipRequired(String content) { return content != null && getTooltipLimit() > 0 && (StringUtils.countOccurrencesOf(content, "<p>") > 1 || StringUtils.countOccurrencesOf(content, "<ol>") > 0 || StringUtils.countOccurrencesOf(content, "<image>") > 0 || CsvPrinter.getActualTextFromHtml(content).length() > getTooltipLimit()); }
From source file:app.web.ApplicationITCase.java
public ClickEventResult clickAndWaitIfNecessary(String locator, boolean forceWaitForLoad) { String previousHtmlSource = selenium.getHtmlSource(); String previousLocation = selenium.getLocation(); boolean[] previousVisibilityArray = getVisibilityArray(selenium); selenium.click(locator);/*from ww w .j ava2s.c o m*/ if (selenium.isConfirmationPresent()) { // consume confirmation or else next text will fail selenium.getConfirmation(); } else if (selenium.isAlertPresent()) { // consume alert or else next text will fail selenium.getAlert(); } boolean isNewPageLoaded = waitForLoadIfNecessary(forceWaitForLoad); if (isNewPageLoaded) { String currentLocation = selenium.getLocation(); return currentLocation.equals(previousLocation) ? navigationSamePage() : navigationNewPage(currentLocation); } else { String currentHtmlSource = selenium.getHtmlSource(); if (!currentHtmlSource.equals(previousHtmlSource)) { // Compare the number of tags if (StringUtils.countOccurrencesOf(currentHtmlSource, "<") == StringUtils .countOccurrencesOf(previousHtmlSource, "<")) { List<String> xpathList = new ArrayList<String>(); for (int xpathIndex : compareVisibilityArray(previousVisibilityArray, getVisibilityArray(selenium))) { xpathList.add("(//*)[" + (xpathIndex + 1) + "]"); //array 0-based, xpath 1-based } // if (!xpathList.isEmpty()) // log.info("Test newly visible content"); // '" + getFailSafeText(xpathList.get(0)) + "'"); return domUpdate(xpathList.size() > 0 ? xpathList.toArray(new String[xpathList.size()]) : null); } else { String ajaxContentId = compareHtmlSourceAfterAjaxLoad(previousHtmlSource, currentHtmlSource); // log.info("Test new ajax content under id " + ajaxContentId); return ajaxUpdate("//*[@id='" + ajaxContentId + "']"); } } else { return noChange(); } } }
From source file:fr.xebia.springframework.concurrent.ThreadPoolExecutorFactory.java
public void setPoolSize(String poolSize) { if (!StringUtils.hasText(poolSize)) { return;/*from www.j a v a 2s. co m*/ } switch (StringUtils.countOccurrencesOf(poolSize, "-")) { case 0: this.corePoolSize = Integer.parseInt(poolSize); this.maximumPoolSize = this.corePoolSize; break; case 1: String[] splittedPoolSize = StringUtils.split(poolSize, "-"); this.corePoolSize = Integer.parseInt(splittedPoolSize[0]); this.maximumPoolSize = Integer.parseInt(splittedPoolSize[1]); break; default: throw new BeanCreationException(this.beanName, "Invalid pool-size value [" + poolSize + "]: only single maximum integer " + "(e.g. \"5\") and minimum-maximum range (e.g. \"3-5\") are supported."); } }
From source file:com.geocode.service.impl.AddressServiceImpl.java
public List<String> filterLocations(List<String> locations) { List<String> fileteredLocations = new ArrayList<String>(); for (String string : locations) { if (string != null && string.matches("((?=.*\\d)(?=.*\\s)(?=.*[a-zA-Z]).{2,})") && StringUtils.countOccurrencesOf(string, " ") >= 2) fileteredLocations.add(string); }/*from w w w. jav a2 s.c o m*/ return fileteredLocations; }
From source file:app.web.Application2ITCase.java
public Action clickAndWaitIfNecessary(String locator, boolean forceWaitForLoad) { String previousHtmlSource = selenium.getHtmlSource(); String previousLocation = selenium.getLocation(); boolean[] previousVisibilityArray = getVisibilityArray(selenium); selenium.click(locator);//from www. j a v a 2 s . co m if (selenium.isConfirmationPresent()) { // consume confirmation or else next text will fail selenium.getConfirmation(); } else if (selenium.isAlertPresent()) { // consume alert or else next text will fail selenium.getAlert(); } boolean isNewPageLoaded = waitForLoadIfNecessary(forceWaitForLoad); if (isNewPageLoaded) { String currentLocation = selenium.getLocation(); return currentLocation.equals(previousLocation) ? Action.navigationSamePage(locator) : Action.navigationNewPage(locator, currentLocation); } else { String currentHtmlSource = selenium.getHtmlSource(); if (!currentHtmlSource.equals(previousHtmlSource)) { // Compare the number of tags if (StringUtils.countOccurrencesOf(currentHtmlSource, "<") == StringUtils .countOccurrencesOf(previousHtmlSource, "<")) { List<String> xpathList = new ArrayList<String>(); for (int xpathIndex : compareVisibilityArray(previousVisibilityArray, getVisibilityArray(selenium))) { xpathList.add("(//*)[" + (xpathIndex + 1) + "]"); //array 0-based, xpath 1-based } // if (!xpathList.isEmpty()) // log.info("Test newly visible content"); // '" + getFailSafeText(xpathList.get(0)) + "'"); return Action.domUpdate(locator, xpathList.size() > 0 ? xpathList.toArray(new String[xpathList.size()]) : null); } else { String ajaxContentId = compareHtmlSourceAfterAjaxLoad(previousHtmlSource, currentHtmlSource); // log.info("Test new ajax content under id " + ajaxContentId); return Action.ajaxUpdate(locator, "//*[@id='" + ajaxContentId + "']"); } } else { return Action.noChange(locator); } } }