Hello [lang],
Reference: http://nagoya.apache.org/bugzilla/show_bug.cgi?id=25454
Here is the pickle:
CharSetUtils.translate(String,String,String) is deprecated in favor of
StringUtils.replaceChars(String,String,String) but their behaviors are
different.
The choices as I see them are (compatibility issues noted are with lang /2.0/):
(1) Make StringUtils.replaceChars exactly like CharSetUtils.translate. Pro: Backwards compatible with the Javadoc in CharSetUtils.translate.
Con: Not Backwards compatible with the current StringUtils.replaceChars.
(2) Do (1) and add a new function ("replaceChars2" for the sake of this description) in StringUtils to do what replaceChars does now. Pro: Backwards compatible with the Javadoc in CharSetUtils.translate. Pro: Backwards compatible with the current StringUtils.replaceChars, it has not changed. Con: StringUtils now has 2 functions, replaceChars and "replaceChars2", do we need both?
(3) Point the Javadoc for the deprecated CharSetUtils.translate to a new StringUtils function replaceChars2. Pro: Backwards compatible with the current StringUtils.replaceChars, it has not changed. Con: Well... in theory, calls sites that have followed the deprecated instructions now will now be "incorrect" and will have to be changed again.
(4) "un-deprecate" CharSetUtils.translate(String,String,String) and say that both methods do different jobs.
Opinions please?
Thanks,
Gary
The rationale for deprecating CharSetUtils.translate() and the intended behavior of StringUtils.replaceChars() can be found here:
http://nagoya.apache.org/eyebrowse/[EMAIL PROTECTED]&msgId=785148
The example in the bug report looks like a bug to me, which should be fixed. I doubt seriously that anyone is relying on the following kind of bugged behavior:
StringUtils.replaceChars("abc", "abc", "cba") = "aba"
This results from the string being modified and re-searched in a loop over the search characters (so multiple "translations" may be applied, depending on the order of characters in the search string).
As long as the search and replace character strings have the same length, StringUtils.replaceChars() *should* produce the same results as CharSetUtils.translate().
I suggest, therefore
(5) Fix the bug in StringUtils.replaceChars() and improve the javadoc for this method.
Phil
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
