public String formatSignature() { StringBuilder paramsTypes = new StringBuilder(); for (Entry.Param param : inputs) { paramsTypes.append(param.type.getCanonicalName()).append(","); } return format("%s(%s)", name, stripEnd(paramsTypes.toString(), ",")); }
public String formatSignature() { StringBuilder paramsTypes = new StringBuilder(); for (Param param : inputs) { paramsTypes.append(param.type.getCanonicalName()).append(","); } return format("%s(%s)", name, stripEnd(paramsTypes.toString(), ",")); }
private Optional<CliCmdExecutor> getCliCommand(final String line) { final List<String> parts = splitByUnquotedWhitespace(StringUtils.stripEnd(line, ";")); if (parts.isEmpty()) { return Optional.empty(); } final String reconstructed = parts.stream() .collect(Collectors.joining(" ")); final String asLowerCase = reconstructed.toLowerCase(); return cliSpecificCommands.entrySet().stream() .filter(e -> asLowerCase.startsWith(e.getKey())) .map(e -> CliCmdExecutor.of(e.getValue(), parts)) .findFirst(); }
return stripEnd(str, stripChars);
private String filterEmptyLine(String content) { final StringBuilder sb = new StringBuilder(); Scanner scanner = null; try { scanner = new Scanner(content); while (scanner.hasNextLine()) { String line = scanner.nextLine(); if (line != null) { //清理一行后面多余的空格 line = StringUtils.stripEnd(line, " "); if (line.isEmpty()) { line = " "; } } sb.append(line).append('\n'); } } finally { if (null != scanner) { scanner.close(); } } return sb.toString(); // return content; }
private static String stripIndentation(String description) { if (description == null || description.isEmpty()) { return ""; } String stripped = StringUtils.stripStart(description, "\n\r"); stripped = StringUtils.stripEnd(stripped, "\n\r "); int indentation = 0; int strLen = stripped.length(); while (Character.isWhitespace(stripped.charAt(indentation)) && indentation < strLen) { indentation++; } String[] lines = stripped.split("\\n"); String prefix = StringUtils.repeat(' ', indentation); StringBuilder result = new StringBuilder(stripped.length()); if (StringUtils.isNotEmpty(prefix)) { for (int i = 0; i < lines.length; i++) { String line = lines[i]; if (i > 0) { result.append(StringUtils.LF); } result.append(StringUtils.removeStart(line, prefix)); } } else { result.append(stripped); } return result.toString(); }
@Test public void testStripEnd_StringString() { // null stripEnd assertNull(StringUtils.stripEnd(null, null)); assertEquals("", StringUtils.stripEnd("", null)); assertEquals("", StringUtils.stripEnd(" ", null)); assertEquals(" abc", StringUtils.stripEnd(" abc ", null)); assertEquals(StringUtilsTest.WHITESPACE + StringUtilsTest.NON_WHITESPACE, StringUtils.stripEnd(StringUtilsTest.WHITESPACE + StringUtilsTest.NON_WHITESPACE + StringUtilsTest.WHITESPACE, null)); // "" stripEnd assertNull(StringUtils.stripEnd(null, "")); assertEquals("", StringUtils.stripEnd("", "")); assertEquals(" ", StringUtils.stripEnd(" ", "")); assertEquals(" abc ", StringUtils.stripEnd(" abc ", "")); assertEquals(StringUtilsTest.WHITESPACE, StringUtils.stripEnd(StringUtilsTest.WHITESPACE, "")); // " " stripEnd assertNull(StringUtils.stripEnd(null, " ")); assertEquals("", StringUtils.stripEnd("", " ")); assertEquals("", StringUtils.stripEnd(" ", " ")); assertEquals(" abc", StringUtils.stripEnd(" abc ", " ")); // "ab" stripEnd assertNull(StringUtils.stripEnd(null, "ab")); assertEquals("", StringUtils.stripEnd("", "ab")); assertEquals(" ", StringUtils.stripEnd(" ", "ab")); assertEquals(" abc ", StringUtils.stripEnd(" abc ", "ab")); assertEquals("abc", StringUtils.stripEnd("abcabab", "ab")); assertEquals(StringUtilsTest.WHITESPACE, StringUtils.stripEnd(StringUtilsTest.WHITESPACE, "")); }
String val = lastText.getValue(); if (val!=null) { lastText.setValue(StringUtils.stripEnd(val, null));
/** * Ensures that the given path has exactly one trailing * {@link File#separator} * * @param path the path to modify (can't be <code>null</code>) * @return the normalised path * @since 1.2.0 */ public static String ensureTrailingSeparator(final String path) { Validate.notNull(path); return StringUtils.stripEnd(path, File.separator) + File.separatorChar; }
/** * Returns the part of the given path that represents a directory, in other * words the given path if it's already a directory, or the parent directory * if it's a file. * * @param fileIdentifier the path to parse (required) * @return see above * @since 1.2.0 */ public static String getFirstDirectory(String fileIdentifier) { fileIdentifier = StringUtils.stripEnd(fileIdentifier, File.separator); if (new File(fileIdentifier).isDirectory()) { return fileIdentifier; } return backOneDirectory(fileIdentifier); }
private String getModuleName(final String pomDirectory) { final String normalisedRootPath = FileUtils.ensureTrailingSeparator(projectRootDirectory); final String normalisedPomDirectory = FileUtils.ensureTrailingSeparator(pomDirectory); final String moduleDirectory = StringUtils.removeStart(normalisedPomDirectory, normalisedRootPath); return FilenameUtils.getBaseName(StringUtils.stripEnd(moduleDirectory, SEPARATOR)); }
results.add(new Completion(StringUtils.stripEnd(translated, null).concat(value) .concat(" "))); } else if (methodTarget.getRemainingBuffer().endsWith(" -") || methodTarget.getRemainingBuffer().length() == 1) { results.add(new Completion(StringUtils.stripEnd(translated, null).concat("-") .concat(value).concat(" "))); } else { results.add(new Completion(StringUtils.stripEnd(translated, null).concat(value) .concat(" "))); } else if (methodTarget.getRemainingBuffer().endsWith(" -") || methodTarget.getRemainingBuffer().length() == 1) { results.add(new Completion(StringUtils.stripEnd(translated, null).concat("-") .concat(value).concat(" "))); } else { results.add(new Completion(StringUtils.stripEnd(translated, null).concat(parameter) .concat(" "))); } else if (methodTarget.getRemainingBuffer().endsWith(" -") || methodTarget.getRemainingBuffer().length() == 1) { results.add(new Completion(StringUtils.stripEnd(translated, null).concat("-") .concat(parameter).concat(" "))); } else {
reducedPath = StringUtils.stripEnd(reducedPath, File.separator);
@Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append(commit.getHash()).append(": "); for (Range range: ranges) builder.append(range).append(", "); return StringUtils.stripEnd(builder.toString(), ", "); }
@Override public String convert(org.springframework.data.geo.Point source) { Assert.notNull(source, "Source must not be null!"); String formattedString = StringUtils.stripEnd(String.format(java.util.Locale.ENGLISH, "%f", source.getX()), "0") + "," + StringUtils.stripEnd(String.format(java.util.Locale.ENGLISH, "%f", source.getY()), "0"); if (source instanceof Point) { formattedString += (((Point) source).getZ() != null ? ("," + StringUtils.stripEnd(String.format(java.util.Locale.ENGLISH, "%f", ((Point) source).getZ()), "0")) : ""); } return formattedString.replaceAll("\\.,", "\\.0,").replaceFirst("\\.$", ".0"); }
private String matcherKey(String name) { String key = rootPath + name; if (!name.equals("*") && !name.matches(Parser$.MODULE$.FieldRegex().toString())) { key = StringUtils.stripEnd(rootPath, ".") + "['" + name + "']"; } return key; }
/** * Gets the self-link for collections in the database * * @return the collections link. */ public String getCollectionsLink() { return String.format("%s/%s", StringUtils.stripEnd(super.getSelfLink(), "/"), super.getString(Constants.Properties.COLLECTIONS_LINK)); }
public String output() { if (isLeftTrim() && isRightTrim()) { return trim(); } else if (isLeftTrim()) { return StringUtils.stripStart(content, null); } else if (isRightTrim()) { return StringUtils.stripEnd(content, null); } return content; }