commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rand McNeely" <rand_mcne...@yahoo.com>
Subject RE: [lang] Numbers.isNumber vs Numbers.createNumber
Date Fri, 05 Jul 2002 14:29:27 GMT
I thought about that and that would definitely be the simplest (and most
reliable) approach but if a developer was coding

if (Numbers.isNumber(val)) {
	num = Numbers.createNumber(val);
}

and then later looked at the isNumber code, he would probably be a
little peeved.  This wouldn't be too bad if isNumber cached the return
value of createNumber later anticipating the call to createNumber but do
we want to include this kind of logic in such a low level API?

> -----Original Message-----
> From: Jonathan Carlson [mailto:joncrlsn2@yahoo.com]
> Sent: Friday, July 05, 2002 9:24 AM
> To: 'Jakarta Commons Developers List'
> Subject: Re: [lang] Numbers.isNumber vs Numbers.createNumber
> 
> Why not just have #isNumber call #createNumber and return
> false if an exception is thrown and true otherwise?
> 
> Jonathan
> 
> --- Rand McNeely <rand_mcneely@yahoo.com> wrote:
> > I'd like to modify Numbers.isNumber(String) so that it
> > will return true
> > iff Numbers.createNumber(String) wouldn't throw a
> > NumberFormatException.
> >
> > This is going to be a pain to ensure that it is 100%
> > reliable as there
> > are so many different number formats Integer, Long,
> > BigInteger, Float,
> > Double, and BigDecimal can handle but I think it's
> > important for
> > consistency.
> >
> > Also, what is the value added in createInteger, etc?  Is
> > it simply to
> > give a uniform way of creating the wrapper types instead
> > of sometimes
> > needing to call XXX.valueOf(String) and sometimes new
> > XXX(String)?  If
> > they are important to the Class, I think we need to
> > modify them to
> > handle cases like "1234L" (as createNumber does).
> >
> >
> >
> >
> > --
> > To unsubscribe, e-mail:
> > <mailto:commons-dev-unsubscribe@jakarta.apache.org>
> > For additional commands, e-mail:
> > <mailto:commons-dev-help@jakarta.apache.org>
> >
> 
> 
> =====
> Jonathan Carlson
> joncrlsn@users.sf.net
> Minneapolis, Minnesota
> 
> __________________________________________________
> Do You Yahoo!?
> Sign up for SBC Yahoo! Dial - First Month Free
> http://sbc.yahoo.com
> 
> --
> To unsubscribe, e-mail:   <mailto:commons-dev-
> unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:commons-dev-
> help@jakarta.apache.org>


--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message