commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ash" <>
Subject Re: [lang] new functionality in StringUtils and ArrayUtils - proposal 01
Date Mon, 24 Nov 2003 23:01:53 GMT

All the concepts (flank, enclose, single quote, double quote) are rather
trivial, or, let's say, they're simple append functions. However, they still
do represent special cases of appending, and albeit simple, may merit
inclusion to the StringUtils class considering that the class is largely a
compendium of similar simple functions: If you can chomp a String, you can
even flank it?

> flank/singleQuote/doubleQuote/enclose
> This has some potential as a StringUtils addition. Perhaps just focussing
> the enclose method name, with
>  enclose(str, encloseWith)
>  enclose(str, before, after)
> Similar to string appending though so is it justified?

> lead/trail
> Very little gain over string appending - just null checking. But then
> what StringUtils often is. These two could become one though:
>   concat(str1, str2)

But lead and trail represent specific semantics, concat would do, but it's
different semantically, isn't it?

>  ArrayUtils.toString with alternate delimiter
> I can't see the use case for this, and if it exists then ToStringBuilder
> already handles it.

This is from an array user's perspective. A coder who simply wanted to print
an array and go on with his code would say "why should I do a StringBuilder,
I just want a direct toString(arr, ",\n\t"), that's it!"
Of course, this could be a simple delegation to a StringBuilder
implementation, but if an array-oriented view can be justified, it can
perhaps be said that there is a use for this.

>  ArrayUtils.toString(Object arr, int startIndex, int endIndex)
> Possible, but how often is this needed?

One could use the subarray along with the existing toString. Feedback from
others might throw more light on its need.

>  ArrayUtils.subarray(arr, startIndex, endIndex)
> Looks good +1. Just need to determine whether the end points are inclusive
> or exclusive (suggest copying List API)

The String.substring(startIndex, endIndex) can be suggested to be a good
model to emulate, for the inclusiveness aspect.

> To proceded with ArrayUtils.subarray (gets you started), submit a CVS
> against the latest CVS with the new addition and suitable tests.

I'll send this across presently.


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

View raw message