commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Chaffee / Purple Technology <>
Subject Re: [lang] Adding Purple to StringUtils
Date Wed, 05 Mar 2003 21:12:59 GMT
On Wed, Mar 05, 2003 at 01:52:42PM -0500, Henri Yandell wrote:
> > * String strdiffVerbose(String expected, String actual)
> >
> > Compare two strings, and return a verbose description of how
> > they differ. Shows a window around the location to provide
> > context.
> >
> > E.g. strdiffVerbose("i am a robot", "i am a machine") might return a
> > string containing
> >
> > strings differ at character 7
> > Expected: a robot
> >   Actual: a machine
> >
> > This was developed in order to provide some sanity to JUnit's
> > assertEquals display.
> Nay. It's not a 'util' but an applicatin on top of the utils.

I concur.  

I was thinking about how to separate model from view, and it occured
to me that maybe it should return a StringDiff object, containing
accessors for

	String expected
	String actual
	int differenceStartsAtCharacter
	String windowedExpected
	String windowedActual
	String verboseString

In any case, we can table it for now.

Ooh, just had another thought: maybe abbreviate() should have a
variant where it makes a window -- give it the start and the desired
width, and it puts ellipses at the start and/or at the end as
appropriate.  And/or one where it puts the ellipses at the start

> > * String rtrim(String orig)
> > * String ltrim(String orig)
> >
> > Trim the whitespace off the right or left side of a String
> > only. (Probably rename trimRight and trimLeft.)
> stripStart and stripEnd I believe.

Again, I don't yet concur with your strip/trim distinction, but it's
not that big a deal.

> map( StringUtils.strip, array )
> though the above has a touch of max logic to it. I think it is silly for
> us to add these. [quick note to implement 'map' in Java].

Quick note to add function pointers to Java :-)

> > * htmlescape(String)     (should rename: escapeHtml)
> > * htmlunescape(String)   (should rename: unescapeHtml)
> Definitely not going to get in StringUtils. It is a very useful function
> though.

Can you suggest where in Commons it might belong?  This is the one I
really want to get into a wider distribution.

> > * pluralize
> >
> > turn String s into a plural English noun (doing the right thing with
> > "story" -> "stories" and "mess" -> "messes")
> Does it handle all english though? ie) It will fail on pluralising abacus
> etc.

No, it doesn't do proper stemming.  I put it in when writing a code
generator that needed a way to get names for functions dealing with
collections.  I don't think I've used it since.  Not a high priority,
though it's just sooo cute! :-)

> > * toUnderscore
> >
> > Converts camelCaseVersusC to camel_case_versus_c
> >
> > I'd love to get some ideas on a better name for this.  Also, it'd be
> > nice to have a full, symmetrical set of camelCase vs. under_score
> > vs. CONSTANT_NAMING vs. "separate words" naming style converters.
> Hmm. Probably a bit specific for StringUtils. Do people often need this?

This was another code generator utility.  Not a high priority, but I
think it fits in with the capitali[zs]e family.

Alex Chaffee                     
Purple Technology - Code and Consulting
jGuru - Java News and FAQs       
Gamelan - the Original Java site 
Stinky - Art and Angst           

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

View raw message