private static void extract ( String s , int start , ExtractFloatResult result ) { // Now looking for ' ', ',', '.' or '-' from the start. int currentIndex = start ; boolean foundSeparator = false ; result . mEndWithNegOrDot = false ; boolean secondDot = false ; boolean isExponential = false ; for ( ; currentIndex < s . length ( ) ; currentIndex ++ ) { boolean isPrevExponential = isExponential ; isExponential = false ; char currentChar = s . charAt ( currentIndex ) ; switch ( currentChar ) { case ' ' : case ' ' : foundSeparator = true ; break ; case ' ' : // The negative sign following a 'e' or 'E' is not a separator. if ( currentIndex != start && ! isPrevExponential ) { foundSeparator = true ; result . mEndWithNegOrDot = true ; } break ; case ' ' : if ( ! secondDot ) { secondDot = true ; } else { // This is the second dot, and it is considered as a separator. foundSeparator = true ; result . mEndWithNegOrDot = true ; } break ; case ' ' : case ' ' : isExponential = true ; break ; } if ( foundSeparator ) { break ; } } // When there is nothing found, then we put the end position to the end // of the string. result . mEndPosition = currentIndex ; }
Calculate the position of the next comma or space or negative sign