Polished
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/8c48da28 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/8c48da28 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/8c48da28 Branch: refs/heads/master Commit: 8c48da28c09c75045e977e7df9472503d2793429 Parents: 9006450 Author: Claus Ibsen <[email protected]> Authored: Tue Dec 13 12:54:23 2016 +0100 Committer: Claus Ibsen <[email protected]> Committed: Tue Dec 13 13:08:09 2016 +0100 ---------------------------------------------------------------------- .../org/apache/camel/util/MessageHelper.java | 2 +- .../org/apache/camel/util/StringHelper.java | 38 ++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/8c48da28/camel-core/src/main/java/org/apache/camel/util/MessageHelper.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/util/MessageHelper.java b/camel-core/src/main/java/org/apache/camel/util/MessageHelper.java index 524d246..3e7042b 100644 --- a/camel-core/src/main/java/org/apache/camel/util/MessageHelper.java +++ b/camel-core/src/main/java/org/apache/camel/util/MessageHelper.java @@ -573,7 +573,7 @@ public final class MessageHelper { // the sanitizeUri takes a very long time for very long string and the format cuts this to // 78 characters, anyway. Cut this to 100 characters. This will give enough space for removing // characters in the sanitizeUri method and will be reasonably fast - label = URISupport.sanitizeUri(StringHelper.limitLenght(history.getNode().getLabel(), 100)); + label = URISupport.sanitizeUri(StringHelper.limitLength(history.getNode().getLabel(), 100)); elapsed = history.getElapsed(); sb.append(String.format(MESSAGE_HISTORY_OUTPUT, routeId, id, label, elapsed)); http://git-wip-us.apache.org/repos/asf/camel/blob/8c48da28/camel-core/src/main/java/org/apache/camel/util/StringHelper.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/util/StringHelper.java b/camel-core/src/main/java/org/apache/camel/util/StringHelper.java index 6e0f3de..084bea0 100644 --- a/camel-core/src/main/java/org/apache/camel/util/StringHelper.java +++ b/camel-core/src/main/java/org/apache/camel/util/StringHelper.java @@ -78,14 +78,33 @@ public final class StringHelper { * @param s the string * @param maxLength the maximum length of the returned string * @return s if the length of s is less than maxLength or the first maxLength characters of s + * @deprecated use {@link #limitLength(String, int)} */ + @Deprecated public static String limitLenght(String s, int maxLength) { + return limitLength(s, maxLength); + } + + /** + * Limits the length of a string + * + * @param s the string + * @param maxLength the maximum length of the returned string + * @return s if the length of s is less than maxLength or the first maxLength characters of s + */ + public static String limitLength(String s, int maxLength) { if (ObjectHelper.isEmpty(s)) { return s; } return s.length() <= maxLength ? s : s.substring(0, maxLength); } + /** + * Removes all quotes (single and double) from the string + * + * @param s the string + * @return the string without quotes (single and double) + */ public static String removeQuotes(String s) { if (ObjectHelper.isEmpty(s)) { return s; @@ -96,6 +115,12 @@ public final class StringHelper { return s; } + /** + * Removes all leading and ending quotes (single and double) from the string + * + * @param s the string + * @return the string without leading and ending quotes (single and double) + */ public static String removeLeadingAndEndingQuotes(String s) { if (ObjectHelper.isEmpty(s)) { return s; @@ -113,6 +138,12 @@ public final class StringHelper { return s; } + /** + * Whether the string starts and ends with either single or double quotes. + * + * @param s the string + * @return <tt>true</tt> if the string starts and ends with either single or double quotes. + */ public static boolean isQuoted(String s) { if (ObjectHelper.isEmpty(s)) { return false; @@ -308,6 +339,7 @@ public final class StringHelper { return value; } + // TODO: add javadoc public static String[] splitOnCharacter(String value, String needle, int count) { String rc[] = new String[count]; rc[0] = value; @@ -342,6 +374,12 @@ public final class StringHelper { return text; } + /** + * Capitalize the string (upper case first character) + * + * @param text the string + * @return the string capitalized (upper case first character) + */ public static String capitalize(String text) { if (text == null) { return null;
