added samples in javadoc
Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/83b36622 Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/83b36622 Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/83b36622 Branch: refs/heads/master Commit: 83b366223209f2c8908ffadc888b2f45f181c827 Parents: e9cafb5 Author: Amey Jadiye <ameyjad...@gmail.com> Authored: Fri May 5 01:09:48 2017 +0530 Committer: Amey Jadiye <ameyjad...@gmail.com> Committed: Fri May 5 01:09:48 2017 +0530 ---------------------------------------------------------------------- .../java/org/apache/commons/text/WordUtils.java | 24 +++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-text/blob/83b36622/src/main/java/org/apache/commons/text/WordUtils.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/text/WordUtils.java b/src/main/java/org/apache/commons/text/WordUtils.java index 1023354..3409d7c 100644 --- a/src/main/java/org/apache/commons/text/WordUtils.java +++ b/src/main/java/org/apache/commons/text/WordUtils.java @@ -741,7 +741,7 @@ public class WordUtils { //----------------------------------------------------------------------- /** - * Abbreviates a string nicely. + * Abbreviates the words nicely. * * This method searches for the first space after the lower limit and abbreviates * the String there. It will also append any String passed as a parameter @@ -758,9 +758,31 @@ public class WordUtils { * This is appended ONLY if the string was indeed abbreviated. * The append does not count towards the lower or upper limits. * @return the abbreviated String. + * + * <pre> + * + * WordUtils.abbreviate("Now is the time for all good men", 0, 40, null)); = "Now" + * WordUtils.abbreviate("Now is the time for all good men", 10, 40, null)); = "Now is the" + * WordUtils.abbreviate("Now is the time for all good men", 20, 40, null)); = "Now is the time for all" + * WordUtils.abbreviate("Now is the time for all good men", 0, 40, "")); = "Now" + * WordUtils.abbreviate("Now is the time for all good men", 10, 40, "")); = "Now is the" + * WordUtils.abbreviate("Now is the time for all good men", 20, 40, "")); = "Now is the time for all" + * WordUtils.abbreviate("Now is the time for all good men", 0, 40, " ...")); = "Now ..." + * WordUtils.abbreviate("Now is the time for all good men", 10, 40, " ...")); = "Now is the ..." + * WordUtils.abbreviate("Now is the time for all good men", 20, 40, " ...")); = "Now is the time for all ..." + * WordUtils.abbreviate("Now is the time for all good men", 0, -1, "")); = "Now" + * WordUtils.abbreviate("Now is the time for all good men", 10, -1, "")); = "Now is the" + * WordUtils.abbreviate("Now is the time for all good men", 20, -1, "")); = "Now is the time for all" + * WordUtils.abbreviate("Now is the time for all good men", 50, -1, "")); = "Now is the time for all good men" + * WordUtils.abbreviate("Now is the time for all good men", 1000, -1, "")); = "Now is the time for all good men" + * WordUtils.abbreviate("Now is the time for all good men", 9, -10, null)); = IllegalArgumentException + * WordUtils.abbreviate("Now is the time for all good men", 10, 5, null)); = IllegalArgumentException + * + * </pre> */ public static String abbreviate(String str, int lower, int upper, String appendToEnd) { + if (StringUtils.isEmpty(str)) { return str; }