commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric Galluzzo <>
Subject Re: [lang] So, about that 2.0....
Date Thu, 31 Jul 2003 14:55:05 GMT
Note: IANAC (I am not a committer). :)

Stephen Colebourne wrote:

> We should avoid NPE and throw IAE wherever possible. Its the new 
> [lang] way.

I agree, sounds nice.

> I propose the clearest is:
>translate(*str, null, *)  = *str
>translate(*str, "", *)  = *str
>translate(*, "abc", null)  = delete chars 'abc' from string
>translate(*, "abc", "")  = delete chars 'abc' from string
>translate(*, "abc", "z")  = replace chars 'abc' with 'z'
>translate(*, "abc", "zyxwv")  = replace chars 'a' with 'z', 'b' with 'y',
>'c' with 'x', ignore 'wv'
>--> no errors
Would it make sense for the translate() function to mimic the XPath 
translate() function's behavior?  (See  That seems to be what 
StringUtils.translate() is modeled upon -- either that or the old Unix 
'tr' utility.  Following XPath's translate() function definition, all 
your examples above would remain intact except that:

translate(*, "abc", "z")

would cause 'a' to be replaced with 'z', and would delete all 
occurrences of 'b' and 'c'.

If I have no idea what I'm talking about, feel free to brush these 
comments aside with a Dogbert-style "Bah." :)

    - Eric

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message