/** * Helper method to determine the file separator (forward or backward slash) used in a filename. The slash that * occurs more often is returned as the separator. * * @param filename The filename parsed to determine the file separator. * @return The file separator used within <code>filename</code>. This value is either a forward or backward slash. */ private static final String determineSeparator( String filename ) { int forwardCount = StringUtils.countMatches( filename, "/" ); int backwardCount = StringUtils.countMatches( filename, "\\" ); return forwardCount >= backwardCount ? "/" : "\\"; }
int slashCount = StringUtils.countMatches( filename, separator ) - 1; if ( slashCount <= 0 )
/** * Helper method to determine the file separator (forward or * backward slash) used in a filename. The slash that occurs more * often is returned as the separator. * * @param filename The filename parsed to determine the file * separator. * @return The file separator used within <code>filename</code>. * This value is either a forward or backward slash. */ private static final String determineSeparator( String filename ) { int forwardCount = StringUtils.countMatches( filename, "/" ); int backwardCount = StringUtils.countMatches( filename, "\\" ); return forwardCount >= backwardCount ? "/" : "\\"; }
/** * Helper method to determine the file separator (forward or * backward slash) used in a filename. The slash that occurs more * often is returned as the separator. * * @param filename The filename parsed to determine the file * separator. * @return The file separator used within <code>filename</code>. * This value is either a forward or backward slash. */ private static final String determineSeparator( String filename ) { int forwardCount = StringUtils.countMatches( filename, "/" ); int backwardCount = StringUtils.countMatches( filename, "\\" ); return forwardCount >= backwardCount ? "/" : "\\"; }
if ((line.startsWith("=") && StringUtils.countMatches(line, "=") == previousLine.length() && line.matches("^=+$")) || (line.startsWith("-") && StringUtils.countMatches(line, "-") == previousLine.length() && line.matches("^-+$"))) { return previousLine;
int slashCount = StringUtils.countMatches( filename, separator ) - 1; if ( slashCount <= 0 )
/** * Fix the separator for the 4th token in a versions. In maven this must be "-", in OSGI it's "." * * @param versionRange input range * @return modified version range */ protected String fixBuildNumberSeparator( String versionRange ) { // should not be called with a null versionRange, but a check doesn't hurt... if ( versionRange == null ) { return null; } StringBuffer newVersionRange = new StringBuffer(); Matcher matcher = VERSION_PATTERN.matcher( versionRange ); while ( matcher.find() ) { String group = matcher.group(); if ( StringUtils.countMatches( group, "." ) > 2 ) //$NON-NLS-1$ { // build number found, fix it int lastDot = group.lastIndexOf( '.' ); //$NON-NLS-1$ group = StringUtils.substring( group, 0, lastDot ) + "-" //$NON-NLS-1$ + StringUtils.substring( group, lastDot + 1, group.length() ); } matcher.appendReplacement( newVersionRange, group ); } matcher.appendTail( newVersionRange ); return newVersionRange.toString(); }
int slashCount = StringUtils.countMatches( filename, separator ) - 1; if ( slashCount <= 0 )
/** * The 4th (build) token MUST be separed with "-" and not with "." in maven. A version with 4 dots is not parsed, * and the whole string is considered a qualifier. See tests in DefaultArtifactVersion for reference. * * @param version initial version * @param forcedQualifier build number * @param stripQualifier always remove 4th token in version * @return converted version */ protected String osgiVersionToMavenVersion( String version, String forcedQualifier, boolean stripQualifier ) { if ( stripQualifier && StringUtils.countMatches( version, "." ) > 2 ) //$NON-NLS-1$ { version = StringUtils.substring( version, 0, version.lastIndexOf( '.' ) ); //$NON-NLS-1$ } else if ( StringUtils.countMatches( version, "." ) > 2 ) //$NON-NLS-1$ { int lastDot = version.lastIndexOf( '.' ); //$NON-NLS-1$ if ( StringUtils.isNotEmpty( forcedQualifier ) ) { version = StringUtils.substring( version, 0, lastDot ) + "-" + forcedQualifier; //$NON-NLS-1$ } else { version = StringUtils.substring( version, 0, lastDot ) + "-" //$NON-NLS-1$ + StringUtils.substring( version, lastDot + 1, version.length() ); } } return version; }
public static String getUpPath(final String relativePath) { if (StringUtils.isBlank(relativePath)) { return ("."); } final String normalized = relativePath.replace('\\', '/'); final int count = StringUtils.countMatches(normalized, "/"); if (count > 0) { final String path = StringUtils.repeat("../", count + 1); return StringUtils.chop(path); } else { return (".."); } }
private List<String> resolveFiles(File basedir, List<String> languages) throws IOException { String[] languagesArray=languages.toArray(new String[languages.size()]); String[] languagesPathesArray=new String[languagesArray.length]; for (int i=0; i < languagesArray.length; i++) { languagesPathesArray[i]="**/src/**/" + languagesArray[i] + "/**"; } String excludes="target"; Iterator defaultExcludes=Arrays.asList(ListScanner.DEFAULT_EXCLUDES).iterator(); while (defaultExcludes.hasNext()) { excludes+="," + defaultExcludes.next() + "/**"; } List absoluteFiles=FileUtils.getFiles(basedir, StringUtils.join(languagesPathesArray, ","), excludes); log.debug("Found " + absoluteFiles.size() + " potential archetype files"); List<String> files=new ArrayList<String>(absoluteFiles.size()); Iterator filesIterator=absoluteFiles.iterator(); while (filesIterator.hasNext()) { File file=(File) filesIterator.next(); String filePath=StringUtils.prechomp(file.getAbsolutePath(), basedir.getAbsolutePath() + File.separator); String minusSrc=StringUtils.prechomp(filePath, "src" + File.separator); for (int i=0; i < languagesArray.length; i++) { String language=languagesArray[i]; if (StringUtils.countMatches(minusSrc, File.separator + language + File.separator) > 0) { String minusLanguage=StringUtils.prechomp(minusSrc, language + File.separator); files.add(toUnixPath(minusLanguage)); } } } log.debug("Found " + files.size() + " archetype files for package resolution "); return files; }
return false; int baseDepth = StringUtils.countMatches(inputDirectory.getAbsolutePath(), File.separator); dto.markdownFile = file; dto.folderDepth = StringUtils.countMatches(file.getAbsolutePath(), File.separator) - (baseDepth + 1);
int skipUndefinedPropertyIndex=0; int maxAttempts=StringUtils.countMatches(interpolatedResult, DELIMITER) / 2;
if ( StringUtils.countMatches( minusSrc, File.separator + language + File.separator ) > 0 )
int filesLength = StringUtils.countMatches( files, "," ); int typesLength = StringUtils.countMatches( types, "," ); int classifiersLength = StringUtils.countMatches( classifiers, "," ); if ( typesLength != filesLength )
int depth = StringUtils.countMatches( StringUtils.substring( modulePath, 0, modulePath.lastIndexOf( '/' ) + 1 ), "/" );
} else if (StringUtils.countMatches(releaseBranch, gitFlowConfig.getReleaseBranchPrefix()) > 1) { throw new MojoFailureException(