commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Downey <>
Subject Re: StringUtils.containsOnly
Date Wed, 25 Sep 2002 12:28:43 GMT
On Wednesday 25 September 2002 01:32 am, Daniel Rall wrote:
> Henri Yandell <> writes:
> > I've submitted Frederik's patch with the new method. Only odd boundary
> > case I can see is that:
> >
> > containsOnly("", anything but null) returns true.
> This seems okay to me.  A string object could contain the specified
> characters (but doesn't).
I think it depends on what the regex being checked is. I know it's not a 
regex, really, but it's a useful way of thinking. Let's assume the set we're 
looking at is "ab". So is the regex [ab]* or is it [ab]+? My experience is 
that most people write the first, but mean the second. 

> > containsOnly(null, anything) returns false.
> I could follow this on the grounds that a null string couldn't
> possibly contain any characters, so should fail.  Still, I find the
> semantics confusing, since the same argument could be applied to the
> previous case as well.

This should probably throw a NPE. It's not meaningful to ask if null contains 
a character. 

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

View raw message