Here is my submission of the ArrayUtils.subarray() with the changes suggested by Stephen.
Eagerly waiting for feedback and more. Ash ----- Original Message ----- From: "Stephen Colebourne" <[EMAIL PROTECTED]> To: "Jakarta Commons Developers List" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Monday, November 24, 2003 5:47 AM Subject: Re: [lang] new functionality in StringUtils and ArrayUtils - proposal 01 > So many new concepts.....;-) > > flank/singleQuote/doubleQuote/enclose > This has some potential as a StringUtils addition. Perhaps just focussing on > 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 thats > what StringUtils often is. These two could become one though: > concat(str1, str2) > > ArrayUtils.toString with alternate delimiter > I can't see the use case for this, and if it exists then ToStringBuilder > already handles it. > > ArrayUtils.toString(Object arr, int startIndex, int endIndex) > Possible, but how often is this needed? > > ArrayUtils.subarray(arr, startIndex, endIndex) > Looks good +1. Just need to determine whether the end points are inclusive > or exclusive (suggest copying List API) > > > To proceded with ArrayUtils.subarray (gets you started), submit a CVS patch > against the latest CVS with the new addition and suitable tests. > > Stephen > > > From: "Ash .." <[EMAIL PROTECTED]> > > /** > > * Flanks the given string with the flank String or char. > > * <pre> > > * StringUtils.flank(null, *) = null > > * StringUtils.flank("", *) = * > > * StringUtils.flank("abc", null) = abc > > * StringUtils.flank("abc", "x") = xabcx > > * StringUtils.flank("abc", "xy") = xyabcxy // xy...xy > > * </pre> > > */ > > StringUtils.flank(String flankee, String flank) > > StringUtils.flank(String flankee, char flank) > > > > > > Some special cases of flanking are quotes. > > > > /** > > * <pre> > > * StringUtils.singleQuote("Now is the time...") = 'Now is the time...' > > * </pre> > > */ > > StringUtils.singleQuote(String quotee) > > > > /** > > * <pre> > > * StringUtils.doubleQuote("Now is the time...") = "Now is the time..." > > * </pre> > > */ > > StringUtils.doubleQuote(String quotee) > > > > > > > > /** > > * Enclose the string with a pair of symmetrical characters > > * given one of the pair. Such pairs are > > * > > * <tt> > > * (), {}, [], <>, > > * </tt> > > * > > * When the encloser is not from a recognized pair, > > * the method resorts to flank-like appending, with the order > > * for the afterpart reversed. > > * > > * <pre> > > * StringUtils.enclose("abc", "[") = "[abc]" > > * StringUtils.enclose("abc", "[[") = "[[abc]]" > > * StringUtils.enclose("abc", "x") = xabcx > > * StringUtils.enclose("abc", "xy") = xyabcyx // xy..yx > > * </pre> > > * > > * @param enclosee the String to be enclosed > > * @param either of such pairs of strings as given above > > */ > > StringUtils.enclose(String enclosee, String encloser) > > > > > > > > /** > > * <pre> > > * StringUtils.lead("abc", "zz") = "zzabc" > > * </pre> > > */ > > StringUtils.lead(String leadee, String leadStr) > > StringUtils.lead(String leadee, String leadChar) > > > > /** > > * <pre> > > * StringUtils.lead("abc", '.', 3) = "abc..." > > */ > > StringUtils.lead(String leadee, char leadStr, int repeatCount) > > StringUtils.lead(String leadee, String leadStr, int repeatCount) > > > > /** > > * <pre> > > * StringUtils.trail("abc", "zz") = "abczz" > > * </pre> > > */ > > StringUtils.trail(String trailee, String trailStr) > > StringUtils.trail(String trailee, char trailChar) > > StringUtils.trail(String trailee, String trailStr, int repeatCount) > > StringUtils.trail(String trailee, char trailChar, int repeatCount) > > > > > > > > /** > > * The concept of naught. > > * True if the String is null or "null". > > * <pre> > > * StringUtils.isNaught("abc") = false > > * StringUtils.isNaught(null) = true > > * StringUtils.isNaught("null") = true > > * </pre> > > */ > > StringUtils.isNaught(String str) > > > > > > > > // ArrayUtils methods > > > > /** > > * Similar to the existing <code>toString</code> but > > * using delimiter given. > > */ > > ArrayUtils.toString(Object array, String delimiter) > > ArrayUtils.toString(Object array, char delimiter) > > > > /** > > * A <code>toString</code> that emits only a given part > > * of the array. > > */ > > ArrayUtils.toString(Object arr, int startIndex, int endIndex) > > > > > > > > /** > > * Obtain a new array of the given size, with the elements > > * present between startIndex (inclusive) and endIndex (exclusive). > > */ > > ArrayUtils.subarray(arr, startIndex, endIndex) > > > > > > > > > > --------------- > > > > > > > > > > >The concept of a "naught" String. > > > > > >A String is naught if it is either 'null' or is the literal "null". > > > > > >I have often encountered this situation in my JSP project where a > > >particular > > >parameter is passed in > > >as x=null, and I need to insert code everytime saying if(x == null || > > >x.equals("null")) > > > > _________________________________________________________________ > > It's fast, it's easy and it's free. Get MSN Messenger today! > > http://www.msn.co.uk/messenger > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > >
ArrayUtils.subarrayObject.1.1.zip
Description: Zip compressed data
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]