@Test public void testCleanWhitespace() { assertEquals(" \t Blah blah \n blah \n blah blah.", sut.cleanWhitespace(" \t \r\n \t Blah blah \n blah \n blah blah. \n \n ")); }
public String cleanWhitespace(final String input) { if (input.isEmpty()) { return input; } int startIndex = 0, lastSeenLinebreakInLeadingWhitespace = -1, endIndex = input.length(); while (startIndex < endIndex) { char c = input.charAt(startIndex); if (!Character.isWhitespace(c)) { break; } if (c != '\t' && Character.getType(c) == Character.CONTROL) { lastSeenLinebreakInLeadingWhitespace = startIndex; } startIndex++; } startIndex = lastSeenLinebreakInLeadingWhitespace + 1; while (startIndex < endIndex && Character.isWhitespace(input.charAt(endIndex - 1))) { endIndex--; } return input.substring(startIndex, endIndex); }
NotificationMessageBuilderHelper { public String cleanWhitespace(final String input) { if (input.isEmpty()) { return input; } int startIndex = 0, lastSeenLinebreakInLeadingWhitespace = -1, endIndex = input.length(); while (startIndex < endIndex) { char c = input.charAt(startIndex); if (!Character.isWhitespace(c)) { break; } if (c != '\t' && Character.getType(c) == Character.CONTROL) { lastSeenLinebreakInLeadingWhitespace = startIndex; } startIndex++; } startIndex = lastSeenLinebreakInLeadingWhitespace + 1; while (startIndex < endIndex && Character.isWhitespace(input.charAt(endIndex - 1))) { endIndex--; } return input.substring(startIndex, endIndex); } }
NotificationMessageBuilderHelper { public String cleanWhitespace(final String input) { if (input.isEmpty()) { return input; } int startIndex = 0, lastSeenLinebreakInLeadingWhitespace = -1, endIndex = input.length(); while (startIndex < endIndex) { char c = input.charAt(startIndex); if (!Character.isWhitespace(c)) { break; } if (c != '\t' && Character.getType(c) == Character.CONTROL) { lastSeenLinebreakInLeadingWhitespace = startIndex; } startIndex++; } startIndex = lastSeenLinebreakInLeadingWhitespace + 1; while (startIndex < endIndex && Character.isWhitespace(input.charAt(endIndex - 1))) { endIndex--; } return input.substring(startIndex, endIndex); } NotificationMessageBuilderHelper(final String inBaseUrl); }
NotificationMessageBuilderHelper { public String cleanWhitespace(final String input) { if (input.isEmpty()) { return input; } int startIndex = 0, lastSeenLinebreakInLeadingWhitespace = -1, endIndex = input.length(); while (startIndex < endIndex) { char c = input.charAt(startIndex); if (!Character.isWhitespace(c)) { break; } if (c != '\t' && Character.getType(c) == Character.CONTROL) { lastSeenLinebreakInLeadingWhitespace = startIndex; } startIndex++; } startIndex = lastSeenLinebreakInLeadingWhitespace + 1; while (startIndex < endIndex && Character.isWhitespace(input.charAt(endIndex - 1))) { endIndex--; } return input.substring(startIndex, endIndex); } NotificationMessageBuilderHelper(final String inBaseUrl); String resolveActivityBody(final ActivityDTO activity, final Context context); String cleanWhitespace(final String input); String resolveMarkdownForText(final String input); String resolveMarkdownForHtml(final String input); }
NotificationMessageBuilderHelper { public String cleanWhitespace(final String input) { if (input.isEmpty()) { return input; } int startIndex = 0, lastSeenLinebreakInLeadingWhitespace = -1, endIndex = input.length(); while (startIndex < endIndex) { char c = input.charAt(startIndex); if (!Character.isWhitespace(c)) { break; } if (c != '\t' && Character.getType(c) == Character.CONTROL) { lastSeenLinebreakInLeadingWhitespace = startIndex; } startIndex++; } startIndex = lastSeenLinebreakInLeadingWhitespace + 1; while (startIndex < endIndex && Character.isWhitespace(input.charAt(endIndex - 1))) { endIndex--; } return input.substring(startIndex, endIndex); } NotificationMessageBuilderHelper(final String inBaseUrl); String resolveActivityBody(final ActivityDTO activity, final Context context); String cleanWhitespace(final String input); String resolveMarkdownForText(final String input); String resolveMarkdownForHtml(final String input);  }