GitHub user thiagoh opened a pull request:

    https://github.com/apache/commons-lang/pull/24

    Adding to StringUtils truncate method and test cases

    Adding the following methods from `StringUtils`:
    * `public static String truncate(final String str, final int maxWidth)`
    * `public static String truncate(final String str, int offset, final int 
maxWidth)`
    
    For example 
    ```
    StringUtils.truncate("abcdefg", 4) = "abcd"
    StringUtils.truncate("abcdefg", 6) = "abcdef"
    StringUtils.truncate("abcdefg", 7) = "abcdefg"
    StringUtils.truncate("abcdefg", 8) = "abcdefg"
    
    StringUtils.truncate("abcdefghijklmno", -1, 10) = "abcdefghij"
    StringUtils.truncate("abcdefghijklmno", 0, 10) = "abcdefghij"
    StringUtils.truncate("abcdefghijklmno", Integer.MIN_VALUE, 10) = 
"abcdefghij"
    StringUtils.truncate("abcdefghijklmno", Integer.MIN_VALUE, 
Integer.MAX_VALUE) = "abcdefghijklmno"
    StringUtils.truncate("abcdefghijklmno", 0, Integer.MAX_VALUE) = 
"abcdefghijklmno"
    StringUtils.truncate("abcdefghijklmno", 1, 10) = "bcdefghijk"
    StringUtils.truncate("abcdefghijklmno", 2, 10) = "cdefghijkl"
    StringUtils.truncate("abcdefghijklmno", 3, 10) = "defghijklm"
    StringUtils.truncate("abcdefghijklmno", 4, 10) = "efghijklmn"
    StringUtils.truncate("abcdefghijklmno", 5, 10) = "fghijklmno"
    StringUtils.truncate("abcdefghijklmno", 5, 5) = "fghij"
    StringUtils.truncate("abcdefghijklmno", 5, 3) = "fgh"
    StringUtils.truncate("abcdefghijklmno", 10, 3) = "klm"
    StringUtils.truncate("abcdefghijklmno", 10, Integer.MAX_VALUE) = "klmno"
    StringUtils.truncate("abcdefghijklmno", 13, 1) = "n"
    StringUtils.truncate("abcdefghijklmno", 13, Integer.MAX_VALUE) = "no"
    StringUtils.truncate("abcdefghijklmno", 14, 1) = "o"
    StringUtils.truncate("abcdefghijklmno", 14, Integer.MAX_VALUE) = "o"
    ```


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/thiagoh/commons-lang branch-1

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/commons-lang/pull/24.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #24
    
----
commit 08314e45e8f64c46faa02d476960b77957a47cad
Author: thiagoh <thia...@gmail.com>
Date:   2014-05-13T19:21:47Z

    StringUtils add truncate method

commit 2c1fd5b97abc971ff385261cdb4870eb4e23da6e
Author: thiagoh <thia...@gmail.com>
Date:   2014-05-13T19:26:54Z

    javadoc

commit 74d473ef5c033514c0f93e383d9623bc11f6f234
Author: thiagoh <thia...@gmail.com>
Date:   2014-05-13T19:30:35Z

    javadoc ordering

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to