private static int isNumeric ( String s ) { final char [ ] chars = s . toCharArray ( ) ; int num = 0 ; // note: this method does not account for leading zeroes as could occur in build // meta data parts. Leading zeroes are thus simply ignored when parsing the // number. for ( int i = 0 ; i < chars . length ; ++ i ) { final char c = chars [ i ] ; if ( c >= ' ' && c <= ' ' ) { num = num * DECIMAL + Character . digit ( c , DECIMAL ) ; } else { return - 1 ; } } return num ; }
Determines whether s is a positive number . If it is the number is returned otherwise the result is - 1 .