[ https://issues.apache.org/jira/browse/LANG-673?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13084065#comment-13084065 ]
Frederik Naujoks edited comment on LANG-673 at 8/12/11 12:23 PM: ----------------------------------------------------------------- Hi, the WordUtils.abbreviate method operated on words, whereas the StringUtils.abbreviate method ignores "words". >From the commons.lang 2.4 javadoc >(http://commons.apache.org/lang/api-2.4/org/apache/commons/lang/WordUtils.html#abbreviate%28java.lang.String,%20int,%20int,%20java.lang.String%29) {quote} Abbreviates a string 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 to the end of the String. The upper limit can be specified to forcibly abbreviate a String. {quote} StringUtils.abbreviate will cut the supplied String at the given limits. In my usecase that behavior is not desirable, I do need the WordUtils.abbreviate functionality. Both abbreviate methods are useful, depending on the usecase. Please re-add the WordUtils.abbreviate method or supply a method with the old behavior elsewhere. EDIT: If a method with the WordUtils.abbreviate behavior is located elsewhere please note that in the migration guide. Thanks, Frederik was (Author: fnaujoks): Hi, the WordUtils.abbreviate method operated on words, whereas the StringUtils.abbreviate method ignores "words". >From the commons.lang 2.4 javadoc >(http://commons.apache.org/lang/api-2.4/org/apache/commons/lang/WordUtils.html#abbreviate%28java.lang.String,%20int,%20int,%20java.lang.String%29) {quote} Abbreviates a string 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 to the end of the String. The upper limit can be specified to forcibly abbreviate a String. {quote} StringUtils.abbreviate will cut the supplied String at the given limits. In my usecase that behavior is not desirable, I do need the WordUtils.abbreviate functionality. Both abbreviate methods are useful, depending on the usecase. Please re-add the WordUtils.abbreviate method or supply a method with the old behavior elsewhere. Thanks, Frederik > WordUtils.abbreviate() throws undocumented StringIndexOutOfBoundsException > (ACTION: Method Removed) > --------------------------------------------------------------------------------------------------- > > Key: LANG-673 > URL: https://issues.apache.org/jira/browse/LANG-673 > Project: Commons Lang > Issue Type: Improvement > Affects Versions: 2.5 > Reporter: Paul Benedict > Fix For: 3.0 > > > The javadoc does not indicate that the string must already be long enough to > abbreviate; yet it really does or an Exception is thrown. For example, if you > try to abbreviate a string of length 10 at 40 characters, this will fail. I > believe this should be allowed... just without any abbreviation. -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira