You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Benedikt Ritter <br...@apache.org> on 2014/09/09 21:33:06 UTC

Re: svn commit: r1609898 - in /commons/proper/lang/trunk/src: main/java/org/apache/commons/lang3/math/NumberUtils.java test/java/org/apache/commons/lang3/math/NumberUtilsTest.java

Thanks! I've implemented the suggested improvement in revision 1623872.

2014-08-30 19:28 GMT+02:00 sebb <se...@gmail.com>:

> On 12 July 2014 10:48,  <br...@apache.org> wrote:
> > Author: britter
> > Date: Sat Jul 12 09:48:13 2014
> > New Revision: 1609898
> >
> > URL: http://svn.apache.org/r1609898
> > Log:
> > LANG-1016: NumberUtils#isParsable method(s). Apply Juan PabloSantos
> Rodríguez patch for handling negative numbers.
> >
> > Modified:
> >
>  commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/math/NumberUtils.java
> >
>  commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
> >
> > Modified:
> commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/math/NumberUtils.java
> > URL:
> http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/math/NumberUtils.java?rev=1609898&r1=1609897&r2=1609898&view=diff
> >
> ==============================================================================
> > ---
> commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/math/NumberUtils.java
> (original)
> > +++
> commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/math/NumberUtils.java
> Sat Jul 12 09:48:13 2014
> > @@ -1488,7 +1488,11 @@ public class NumberUtils {
> >          if( StringUtils.endsWith( str, "." ) ) {
> >              return false;
> >          }
> > -        return isDigits( StringUtils.replaceOnce( str, ".",
> StringUtils.EMPTY ) );
> > +        if( StringUtils.startsWith( str, "-" ) ) {
> > +            return isDigits( StringUtils.replaceOnce(
> StringUtils.substring( str, 1 ), ".", StringUtils.EMPTY ) );
>
> Could use the simpler str.substring(1) because str cannot be null here.
>
> > +        } else {
> > +            return isDigits( StringUtils.replaceOnce( str, ".",
> StringUtils.EMPTY ) );
> > +        }
> >      }
> >
> >  }
> >
> > Modified:
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
> > URL:
> http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java?rev=1609898&r1=1609897&r2=1609898&view=diff
> >
> ==============================================================================
> > ---
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
> (original)
> > +++
> commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
> Sat Jul 12 09:48:13 2014
> > @@ -1268,7 +1268,12 @@ public class NumberUtilsTest {
> >          assertFalse( NumberUtils.isParsable("64L") );
> >          assertTrue( NumberUtils.isParsable("64.2") );
> >          assertTrue( NumberUtils.isParsable("64") );
> > -        assertTrue(NumberUtils.isParsable("018"));
> > +        assertTrue( NumberUtils.isParsable("018") );
> > +        assertTrue( NumberUtils.isParsable(".18") );
> > +        assertTrue( NumberUtils.isParsable("-65") );
> > +        assertTrue( NumberUtils.isParsable("-018") );
> > +        assertTrue( NumberUtils.isParsable("-018.2") );
> > +        assertTrue( NumberUtils.isParsable("-.236") );
> >      }
> >
> >      private boolean checkCreateNumber(final String val) {
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>


-- 
http://people.apache.org/~britter/
http://www.systemoutprintln.de/
http://twitter.com/BenediktRitter
http://github.com/britter