In my previous email,





 /**
  * <pre>
  * StringUtils.lead("abc", '.', 3)  = "abc..."
  */

This should be:

 /**
  * <pre>
  * StringUtils.trail("abc", '.', 3)  = "abc..."
  */






From: "Ash .." <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]


Hi,

I would like to propose the following methods to the StringUtils and ArrayUtils classes.
They are just minor additions to the existing functionality, but I thought would be interesting,
hopefully quite useful too.



Waiting for feedback and looking forward to some development in this regard.
I would be glad to submit an implementation to the concerned people, if you feel this functionality
is include-worthy.


Thanks,
Ash






/** * 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>
  * (), {}, [], &lt;&gt;,
  * </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]



Reply via email to