List of usage examples for org.apache.commons.lang StringUtils countMatches
public static int countMatches(String str, String sub)
Counts how many times the substring appears in the larger String.
From source file:net.sourceforge.seqware.pipeline.plugins.FileLinkerTest.java
@Test public void checkRepeatedFileImportFail() { String path = FileLinkerTest.class.getResource("file_linker_test2.txt").getPath(); launchPlugin("--workflow-accession", "4", "--file-list-file", path); launchPlugin("--workflow-accession", "4", "--file-list-file", path); String s = getOut();/* w ww. j a v a 2s . co m*/ Assert.assertTrue("should be no file imports possible", s.contains("SWID") && StringUtils.countMatches(s, "Ignored file") == 4); }
From source file:net.ssehub.easy.instantiation.rt.core.model.confModel.IDecisionVariableIdentifier.java
@Override protected boolean isNestedVariable(String id) { return null != id && StringUtils.countMatches(id, SEPARATOR) > 1; }
From source file:net.ymate.platform.webmvc.impl.DefaultInterceptorRuleProcessor.java
public PairObject<IView, ResponseCache> processRequest(IWebMvc owner, IRequestContext requestContext) throws Exception { String _mapping = requestContext.getRequestMapping(); InterceptorRuleMeta _ruleMeta = __interceptorRules.get(_mapping); IView _view = null;/*from www .j a v a2s. c o m*/ if (_ruleMeta == null) { while (StringUtils.countMatches(_mapping, "/") > 1) { _mapping = StringUtils.substringBeforeLast(_mapping, "/"); _ruleMeta = __interceptorRules.get(_mapping); if (_ruleMeta != null && _ruleMeta.isMatchAll()) { break; } } } ResponseCache _responseCache = null; if (_ruleMeta != null) { _responseCache = _ruleMeta.getResponseCache(); InterceptContext _context = new InterceptContext(IInterceptor.Direction.BEFORE, owner.getOwner(), null, null, null, _ruleMeta.getContextParams()); // for (Class<? extends IInterceptor> _interceptClass : _ruleMeta.getBeforeIntercepts()) { IInterceptor _interceptor = _interceptClass.newInstance(); // ??? Object _result = _interceptor.intercept(_context); if (_result != null) { _view = (IView) _result; break; } } } return new PairObject<IView, ResponseCache>(_view, _responseCache); }
From source file:ninja.text.TextImpl.java
@Override public int countMatches(CharSequence pattern) { return StringUtils.countMatches(data.toString(), pattern.toString()); }
From source file:nl.nn.adapterframework.extensions.esb.EsbSoapWrapperPipe.java
public static boolean isEsbDestinationWithoutServiceContext(String destination) { int dotCount = StringUtils.countMatches(destination, "."); if (dotCount < 8) { return true; }/*from www .jav a 2 s. co m*/ return false; }
From source file:nl.nn.adapterframework.extensions.esb.EsbSoapWrapperPipe.java
public static boolean isEsbNamespaceWithoutServiceContext(String namespace) { int slashCount = StringUtils.countMatches(namespace, "/"); if (slashCount < 9) { return true; }// w ww .j a v a 2 s .c o m return false; }
From source file:nl.nn.adapterframework.extensions.svn.SvnUtils.java
public static String getLogReport(String urlString) throws DomBuilderException, XPathExpressionException, ConfigurationException, SenderException, TimeOutException { String head = getHeadHtml(urlString); String etag = XmlUtils.evaluateXPathNodeSetFirstElement(head, "headers/header[lower-case(@name)='etag']"); if (etag != null) { if (StringUtils.countMatches(etag, "\"") >= 2) { String s = StringUtils.substringAfter(etag, "\""); String s2 = StringUtils.substringBefore(s, "\""); String s3 = StringUtils.substringBefore(s2, "/"); String s4 = StringUtils.substringAfter(s2, "/"); return getReportHtml(urlString, s3, s4); }//from ww w.j a v a 2s . c o m } return null; }
From source file:nl.nn.adapterframework.pipes.CreateRestViewPipe.java
public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException { HttpServletRequest httpServletRequest = (HttpServletRequest) session.get("restListenerServletRequest"); String requestURL = httpServletRequest.getRequestURL().toString(); String servletPath = httpServletRequest.getServletPath(); String uri = StringUtils.substringAfter(requestURL, servletPath); int countSrcPrefix = StringUtils.countMatches(uri, "/"); String srcPrefix = StringUtils.repeat("../", countSrcPrefix); session.put(SRCPREFIX, srcPrefix);/*from w w w .ja v a2 s . com*/ log.debug(getLogPrefix(session) + "stored [" + srcPrefix + "] in pipeLineSession under key [" + SRCPREFIX + "]"); PipeRunResult prr = super.doPipe(input, session); String result = (String) prr.getResult(); log.debug("transforming page [" + result + "] to view"); String newResult = null; ServletContext servletContext = (ServletContext) session.get("restListenerServletContext"); try { Map parameters = retrieveParameters(httpServletRequest, servletContext, srcPrefix); newResult = XmlUtils.getAdapterSite(result, parameters); } catch (Exception e) { throw new PipeRunException(this, getLogPrefix(session) + " Exception on transforming page to view", e); } session.put(CONTENTTYPE, getContentType()); log.debug(getLogPrefix(session) + "stored [" + getContentType() + "] in pipeLineSession under key [" + CONTENTTYPE + "]"); return new PipeRunResult(getForward(), newResult); }
From source file:nl.uva.expose.LM.main.java
public static HashMap<Integer, String> csvCreator(HashMap<Integer, String> lines, LanguageModel LM, String cName) {/*w w w.j av a 2 s. c o m*/ // String header = lines.get(0); if (cNum == 0) { header = cName + ", "; } else { header += ",," + cName + ", "; } lines.put(0, header); // Integer lineNum = 1; for (Entry<String, Double> e : LM.getSorted()) { // LM.getNormalizedLM().entrySet()) { // LM.getNormalizedTopK(50)) { String line = lines.get(lineNum); if (cNum == 0) { line = "\"" + e.getKey() + "\"" + ":" + e.getValue(); } else { int occurance = StringUtils.countMatches(line, ":"); for (int i = 0; i < cNum - occurance; i++) { if (line == null) { line = ":"; } else { line += ",,:"; } } line += ",," + "\"" + e.getKey() + "\"" + ":" + e.getValue(); } lines.put(lineNum, line); lineNum++; } cNum++; return lines; }
From source file:nl.uva.sne.extractors.TF.java
@Override public Map<String, Double> sort(Map<String, Double> termDictionaray, String dirPath) throws IOException, InterruptedException { Map<String, Double> newTermDictionaray = new HashMap<>(); File dir = new File(dirPath); File[] docs = dir.listFiles(); int count = 0; for (String term : termDictionaray.keySet()) { count++;//ww w. j av a 2 s. c om if (count % 100 == 0) { Logger.getLogger(IDFSort.class.getName()).log(Level.INFO, "{0}: {1} of {2}", new Object[] { term, count, termDictionaray.size() }); } double tf = 0; for (File f : docs) { // Logger.getLogger(TF.class.getName()).log(Level.INFO, "{0}: {1} of {2}", new Object[]{f.getName(), count, docs.length}); if (FilenameUtils.getExtension(f.getName()).endsWith("txt")) { count++; String line; StringBuilder sb = new StringBuilder(); try (BufferedReader br = new BufferedReader(new FileReader(f))) { while ((line = br.readLine()) != null) { sb.append(line); } } tf += StringUtils.countMatches(sb.toString(), term); } } newTermDictionaray.put(term, tf); } return newTermDictionaray; }