private boolean isInsideSubFolder(String key) { int c = StringUtils.countMatches(key, Constants.SLASH); if (c > 2) { return true; } return false; }
public void append(String string) { this.delegate.append(string); this.linesCount += StringUtils.countMatches(string, LINE_BREAK); }
final int packageLevels = StringUtils.countMatches(className, '.'); final String[] output = new String[packageLevels + 1]; int endIndex = className.length() - 1;
/** * 只匹配 h5 的模板 ,如果匹配不到 h5 ,返回 null * <p> * 例如: * 需要 aa_bb_cc_dd_h5.html * 寻找的顺序是:aa_bb_cc_h5.html -> aa_bb_h5.html -> aa_h5.html * * @param template * @return */ private String matchH5Template(String template) { while (StringUtils.countMatches(template, '_') > 1) { int sLastIndex = StringUtils.lastOrdinalIndexOf(template, "_", 2); template = template.substring(0, sLastIndex) + "_h5.html"; if (htmls.contains(template)) { return template; } } return htmls.contains(template) ? template : null; }
int pathLength = StringUtils.countMatches(groupName, "/"); for (int i = 0; i < pathLength - 1; ++i) { sb.append("\t");
private boolean isJavaLangImplicit(AbstractJavaTypeNode node) { String name = node.getImage(); boolean isJavaLang = name != null && name.startsWith("java.lang."); if (isJavaLang && node.getType() != null && node.getType().getPackage() != null) { // valid would be ProcessBuilder.Redirect.PIPE but not java.lang.ProcessBuilder.Redirect.PIPE String packageName = node.getType().getPackage() // package might be null, if type is an array type... .getName(); return "java.lang".equals(packageName); } else if (isJavaLang) { // only java.lang.* is implicitly imported, but not e.g. java.lang.reflection.* return StringUtils.countMatches(name, '.') == 2; } return false; }
private int countPlaceholders(final ASTExpression node) { // zero means, no placeholders, or we could not analyze the message parameter int result = 0; try { List<Node> literals = node .findChildNodesWithXPath( "AdditiveExpression/PrimaryExpression/PrimaryPrefix/Literal[@StringLiteral='true']" + "|PrimaryExpression/PrimaryPrefix/Literal[@StringLiteral='true']"); // if there are multiple literals, we just assume, they are concatenated // together... for (Node stringLiteral : literals) { result += StringUtils.countMatches(stringLiteral.getImage(), "{}"); } } catch (JaxenException e) { LOG.log(Level.FINE, "Could not determine literals", e); } return result; } }
@Test public void testCountMatches_char() { assertEquals(0, StringUtils.countMatches(null, 'D')); assertEquals(5, StringUtils.countMatches("one long someone sentence of one", ' ')); assertEquals(6, StringUtils.countMatches("one long someone sentence of one", 'o')); assertEquals(4, StringUtils.countMatches("oooooooooooo", "ooo")); }
@Test public void testCountMatches_String() { assertEquals(0, StringUtils.countMatches(null, null)); assertEquals(0, StringUtils.countMatches("blah", null)); assertEquals(0, StringUtils.countMatches(null, "DD")); assertEquals(0, StringUtils.countMatches("x", "")); assertEquals(0, StringUtils.countMatches("", "")); assertEquals(3, StringUtils.countMatches("one long someone sentence of one", "one")); assertEquals(0, StringUtils.countMatches("one long someone sentence of one", "two")); assertEquals(4, StringUtils.countMatches("oooooooooooo", "ooo")); }
public void recordUncompressedFiles(ExtFile apkFile, Collection<String> uncompressedFilesOrExts) throws AndrolibException { try { Directory unk = apkFile.getDirectory(); Set<String> files = unk.getFiles(true); String ext; for (String file : files) { if (isAPKFileNames(file) && unk.getCompressionLevel(file) == 0 && unk.getSize(file) != 0) { if (StringUtils.countMatches(file, ".") > 1) { ext = file; } else { ext = FilenameUtils.getExtension(file); if (ext.isEmpty()) { ext = file; } } if (!uncompressedFilesOrExts.contains(ext)) { uncompressedFilesOrExts.add(ext); } } } } catch (DirectoryException ex) { throw new AndrolibException(ex); } }
|| StringUtils.countMatches(s, ':') < 2) { return false;
@Test public void testApiModes() throws IOException { String xmlStart = SERIALIZER.ruleMatchesToXml(Collections.<RuleMatch>emptyList(), "Fake", 5, START_API, LANG, Collections.<String>emptyList()); assertThat(StringUtils.countMatches(xmlStart, "<matches"), is(1)); assertThat(StringUtils.countMatches(xmlStart, "</matches>"), is(0)); String xmlMiddle = SERIALIZER.ruleMatchesToXml(Collections.<RuleMatch>emptyList(), "Fake", 5, CONTINUE_API, LANG, Collections.<String>emptyList()); assertThat(StringUtils.countMatches(xmlMiddle, "<matches"), is(0)); assertThat(StringUtils.countMatches(xmlMiddle, "</matches>"), is(0)); String xmlEnd = SERIALIZER.ruleMatchesToXml(Collections.<RuleMatch>emptyList(), "Fake", 5, END_API, LANG, Collections.<String>emptyList()); assertThat(StringUtils.countMatches(xmlEnd, "<matches"), is(0)); assertThat(StringUtils.countMatches(xmlEnd, "</matches>"), is(1)); String xml = SERIALIZER.ruleMatchesToXml(Collections.<RuleMatch>emptyList(), "Fake", 5, NORMAL_API, LANG, Collections.<String>emptyList()); assertThat(StringUtils.countMatches(xml, "<matches"), is(1)); assertThat(StringUtils.countMatches(xml, "</matches>"), is(1)); }
String jodaToken = postgresToJodaMap.get(firstMatch); if (StringUtils.countMatches(builder.subSequence(0, minPos), JODA_ESCAPE_CHARACTER) % 2 == 0) { int offset = minPos + firstMatch.getName().length(); builder.replace(minPos, offset, jodaToken);
private void printMethods(ClassNode classNode, @NotNull Pattern mthPattern) { String code = classNode.getCode().getCodeStr(); if (code == null) { return; } String[] lines = code.split(CodeWriter.NL); for (MethodNode mth : classNode.getMethods()) { if (mthPattern.matcher(mth.getName()).matches()) { int decompiledLine = mth.getDecompiledLine() - 1; StringBuilder mthCode = new StringBuilder(); int startLine = getCommentLinesCount(lines, decompiledLine); int brackets = 0; for (int i = startLine; i > 0 && i < lines.length; i++) { String line = lines[i]; mthCode.append(line).append(CodeWriter.NL); if (i >= decompiledLine) { brackets += StringUtils.countMatches(line, '{'); brackets -= StringUtils.countMatches(line, '}'); if (brackets <= 0) { break; } } } LOG.info("Print method: {}\n{}", mth.getMethodInfo().getShortId(), mthCode); } } }
String alias = null; String sourceColumn = column; int spaceOccurences = StringUtils.countMatches(column.trim(), " "); if (spaceOccurences > 0) {
if (StringUtils.countMatches(property.getName().replace(tempPrefix, ""), ".") == 1) { if (cmd.getPMap().containsKey(property.getName())) { BasicFieldMetadata md = (BasicFieldMetadata) cmd.getPMap().get(property.getName()).getMetadata();
@Test public void testLanguageAttributes() throws IOException { String xml1 = SERIALIZER.ruleMatchesToXml(Collections.<RuleMatch>emptyList(), "Fake", 5, NORMAL_API, LANG, Collections.<String>emptyList()); assertTrue(xml1.contains("shortname=\"xx-XX\"")); assertTrue(xml1.contains("name=\"Testlanguage\"")); String xml2 = SERIALIZER.ruleMatchesToXml(Collections.<RuleMatch>emptyList(), "Fake", 5, LANG, new FakeLanguage()); assertTrue(xml2.contains("shortname=\"xx-XX\"")); assertTrue(xml2.contains("name=\"Testlanguage\"")); assertTrue(xml2.contains("shortname=\"yy\"")); assertTrue(xml2.contains("name=\"FakeLanguage\"")); assertThat(StringUtils.countMatches(xml2, "<matches"), is(1)); assertThat(StringUtils.countMatches(xml2, "</matches>"), is(1)); }
@Override public StructureDefinition fetchStructureDefinition(FhirContext theContext, String theUrl) { String url = theUrl; if (url.startsWith(URL_PREFIX_STRUCTURE_DEFINITION)) { // no change } else if (url.indexOf('/') == -1) { url = URL_PREFIX_STRUCTURE_DEFINITION + url; } else if (StringUtils.countMatches(url, '/') == 1) { url = URL_PREFIX_STRUCTURE_DEFINITION_BASE + url; } return provideStructureDefinitionMap(theContext).get(url); }
runner.assertAllFlowFilesTransferred(UpdateRecord.REL_SUCCESS, 1); String content = new String(runner.getFlowFilesForRelationship(UpdateRecord.REL_SUCCESS).get(0).toByteArray()); int count = StringUtils.countMatches(content, "Mary Doe"); assertEquals(4, count); runner.removeProperty("/peoples[*]"); runner.assertAllFlowFilesTransferred(UpdateRecord.REL_SUCCESS, 1); content = new String(runner.getFlowFilesForRelationship(UpdateRecord.REL_SUCCESS).get(0).toByteArray()); count = StringUtils.countMatches(content, "Mary Doe"); assertEquals(2, count); runner.removeProperty("/peoples[1]"); runner.assertAllFlowFilesTransferred(UpdateRecord.REL_SUCCESS, 1); content = new String(runner.getFlowFilesForRelationship(UpdateRecord.REL_SUCCESS).get(0).toByteArray()); count = StringUtils.countMatches(content, "Mary Doe"); assertEquals(4, count); runner.removeProperty("/peoples[0,1..2]"); runner.assertAllFlowFilesTransferred(UpdateRecord.REL_SUCCESS, 1); content = new String(runner.getFlowFilesForRelationship(UpdateRecord.REL_SUCCESS).get(0).toByteArray()); count = StringUtils.countMatches(content, "Mary Doe"); assertEquals(4, count); runner.removeProperty("/peoples[0..-1][./name != 'Mary Doe']"); runner.assertAllFlowFilesTransferred(UpdateRecord.REL_SUCCESS, 1); content = new String(runner.getFlowFilesForRelationship(UpdateRecord.REL_SUCCESS).get(0).toByteArray()); count = StringUtils.countMatches(content, "1 nifi road"); assertEquals(13, count); runner.removeProperty("/peoples[0..-1][./name != 'Mary Doe']/addresses[*]");
@Test public void testToStringTooManyElements() { Collection<Number> test = new ArrayList<>(100); for (int i = 0; i < 100; i++) { test.add(new Integer(i)); } // the String will contain not more than exactly MAX_ARRAY_LENGTH elements String result = CollectionUtils.toString(test, 10); assertTrue(result.endsWith("[..]]")); assertEquals(9, countMatches(result, ",")); } }