@Test public void parseLongMax() { boolean ok = true; long l = 0; l = CharScanner.parseLong( ("" + Long.MAX_VALUE).toCharArray() ); ok &= l == Long.MAX_VALUE || die( "l", l, "MAX", Long.MAX_VALUE); }
public static long parseLong(char[] digitChars, int offset, int to) { long num; boolean negative=false; char c = digitChars[ offset ]; if (c == '-') { offset++; negative=true; } c = digitChars[ offset ]; num = (c - '0'); offset++; long digit; for (; offset < to; offset++) { c = digitChars [offset]; digit = ( c - '0' ); num = ( num * 10 ) + digit; } return negative ? num * -1 : num; }
CharScanner { public static long parseLong(char[] digitChars, int offset, int to) { long num; boolean negative=false; char c = digitChars[ offset ]; if (c == '-') { offset++; negative=true; } c = digitChars[ offset ]; num = (c - '0'); offset++; long digit; for (; offset < to; offset++) { c = digitChars [offset]; digit = ( c - '0' ); num = ( num * 10 ) + digit; } return negative ? num * -1 : num; } }
CharScanner { public static long parseLong(char[] digitChars, int offset, int to) { long num; boolean negative=false; char c = digitChars[ offset ]; if (c == '-') { offset++; negative=true; } c = digitChars[ offset ]; num = (c - '0'); offset++; long digit; for (; offset < to; offset++) { c = digitChars [offset]; digit = ( c - '0' ); num = ( num * 10 ) + digit; } return negative ? num * -1 : num; }  }
CharScanner { public static long parseLong(char[] digitChars, int offset, int to) { long num; boolean negative=false; char c = digitChars[ offset ]; if (c == '-') { offset++; negative=true; } c = digitChars[ offset ]; num = (c - '0'); offset++; long digit; for (; offset < to; offset++) { c = digitChars [offset]; digit = ( c - '0' ); num = ( num * 10 ) + digit; } return negative ? num * -1 : num; }  static boolean isDigit( int c ); static boolean isDecimalDigit( int c ); static boolean isDecimalChar( int currentChar ); static boolean hasDecimalChar( char[] chars, boolean negative ); static boolean isDigits( final char[] inputArray ); static boolean isDigits( final char[] inputArray, int offset, int len); static char[][] splitExact( final char[] inputArray,
                                       final char split, final int resultsArrayLength ); static char[][] splitExact( final char[] inputArray,
                                       final int resultsArrayLength, char... delims ); static char[][] splitLines( final char[] inputArray); static char[][] split( final char[] inputArray,
                                  final char split ); static char[][] splitFrom( final char[] inputArray,
                                  final char split, int from ); static char[][] split( final char[] inputArray,
                                  final char split, final int limit ); static char[][] splitFromStartWithLimit( final char[] inputArray,
                                  final char split, final int start,
                                  final int limit ); static char[][] splitByChars( final char[] inputArray,
                                         final char... delims ); static char[][] splitByCharsFromToDelims( final char[] inputArray, int from, int to,
                                                     final char... delims ); static char[][] splitByCharsNoneEmpty( final char[] inputArray,
                                                  final char... delims ); static char[][] splitByCharsNoneEmpty( final char[] inputArray, int from, int to,
                                                  final char... delims ); static char[][] compact( char[][] array ); static boolean isLong( char[] digitChars ); static boolean isLong( char[] digitChars, int offset, int len ); static boolean isInteger( char[] digitChars ); static boolean isInteger( char[] digitChars, int offset, int len); static int parseInt( char[] digitChars ); static int parseInt(char[] digitChars, int offset, int to); static int parseIntFromToIgnoreDot( char[] digitChars, int offset, int to ); static long parseLongFromToIgnoreDot( char[] digitChars, int offset, int to ); static long parseLong(char[] digitChars, int offset, int to); static long parseLong( char[] digitChars ); static Number parseJsonNumber( char[] buffer ); static Number parseJsonNumber( char[] buffer, int from, int to ); static final boolean isNumberDigit(int c); static boolean isDelimiter( int c ); static Number parseJsonNumber( char[] buffer, int from, int max, int size[] ); static float parseFloat( char[] buffer, int from, int to ); static float parseFloat( char[] buffer ); static double parseDouble( char[] buffer ); static double parseDouble( char[] buffer, int from, int to ); static int skipWhiteSpace( char [] array); static int skipWhiteSpace( char [] array, int index ); static int skipWhiteSpace( char [] array, int index, final int length ); static char[] readNumber( char[] array, int idx ); static char[] readNumber( char[] array, int idx, final int len ); static int skipWhiteSpaceFast( char [] array ); static int skipWhiteSpaceFast( char [] array, int index ); static String errorDetails( String message, char[] array, int index, int ch ); static String debugCharDescription( int c ); static final boolean isDoubleQuote( int c ); static final boolean isEscape( int c ); static boolean hasEscapeChar(char []array, int index, int[] indexHolder); static int findEndQuote(final char[] array,  int index); static char[][] splitComma(char[] inputArray); static char[][] splitBySpace( char[] inputArray); static char[][] splitByChar(int splitChar, char[] inputArray); static int findChar(char c, char[] line); static int findWhiteSpace(char[] line); static int findWhiteSpace( int start, char[] line); static int findChar(char c, int startIndex, char[] line); static int findString(String matchString, int startIndex, char[] line); static int findString(String matchString, char[] line); static int findChars(char[] matchChars, char[] line); static boolean matchChars(char[] matchChars, int startIndex, char[] line); static int findChars(char[] matchChars, int startIndex, char[] line); static char[][] splitByPipe(char[] inputArray); }
CharScanner { public static long parseLong(char[] digitChars, int offset, int to) { long num; boolean negative=false; char c = digitChars[ offset ]; if (c == '-') { offset++; negative=true; } c = digitChars[ offset ]; num = (c - '0'); offset++; long digit; for (; offset < to; offset++) { c = digitChars [offset]; digit = ( c - '0' ); num = ( num * 10 ) + digit; } return negative ? num * -1 : num; }  static boolean isDigit( int c ); static boolean isDecimalDigit( int c ); static boolean isDecimalChar( int currentChar ); static boolean hasDecimalChar( char[] chars, boolean negative ); static boolean isDigits( final char[] inputArray ); static boolean isDigits( final char[] inputArray, int offset, int len); static char[][] splitExact( final char[] inputArray,
                                       final char split, final int resultsArrayLength ); static char[][] splitExact( final char[] inputArray,
                                       final int resultsArrayLength, char... delims ); static char[][] splitLines( final char[] inputArray); static char[][] split( final char[] inputArray,
                                  final char split ); static char[][] splitFrom( final char[] inputArray,
                                  final char split, int from ); static char[][] split( final char[] inputArray,
                                  final char split, final int limit ); static char[][] splitFromStartWithLimit( final char[] inputArray,
                                  final char split, final int start,
                                  final int limit ); static char[][] splitByChars( final char[] inputArray,
                                         final char... delims ); static char[][] splitByCharsFromToDelims( final char[] inputArray, int from, int to,
                                                     final char... delims ); static char[][] splitByCharsNoneEmpty( final char[] inputArray,
                                                  final char... delims ); static char[][] splitByCharsNoneEmpty( final char[] inputArray, int from, int to,
                                                  final char... delims ); static char[][] compact( char[][] array ); static boolean isLong( char[] digitChars ); static boolean isLong( char[] digitChars, int offset, int len ); static boolean isInteger( char[] digitChars ); static boolean isInteger( char[] digitChars, int offset, int len); static int parseInt( char[] digitChars ); static int parseInt(char[] digitChars, int offset, int to); static int parseIntFromToIgnoreDot( char[] digitChars, int offset, int to ); static long parseLongFromToIgnoreDot( char[] digitChars, int offset, int to ); static long parseLong(char[] digitChars, int offset, int to); static long parseLong( char[] digitChars ); static Number parseJsonNumber( char[] buffer ); static Number parseJsonNumber( char[] buffer, int from, int to ); static final boolean isNumberDigit(int c); static boolean isDelimiter( int c ); static Number parseJsonNumber( char[] buffer, int from, int max, int size[] ); static float parseFloat( char[] buffer, int from, int to ); static float parseFloat( char[] buffer ); static double parseDouble( char[] buffer ); static double parseDouble( char[] buffer, int from, int to ); static int skipWhiteSpace( char [] array); static int skipWhiteSpace( char [] array, int index ); static int skipWhiteSpace( char [] array, int index, final int length ); static char[] readNumber( char[] array, int idx ); static char[] readNumber( char[] array, int idx, final int len ); static int skipWhiteSpaceFast( char [] array ); static int skipWhiteSpaceFast( char [] array, int index ); static String errorDetails( String message, char[] array, int index, int ch ); static String debugCharDescription( int c ); static final boolean isDoubleQuote( int c ); static final boolean isEscape( int c ); static boolean hasEscapeChar(char []array, int index, int[] indexHolder); static int findEndQuote(final char[] array,  int index); static char[][] splitComma(char[] inputArray); static char[][] splitBySpace( char[] inputArray); static char[][] splitByChar(int splitChar, char[] inputArray); static int findChar(char c, char[] line); static int findWhiteSpace(char[] line); static int findWhiteSpace( int start, char[] line); static int findChar(char c, int startIndex, char[] line); static int findString(String matchString, int startIndex, char[] line); static int findString(String matchString, char[] line); static int findChars(char[] matchChars, char[] line); static boolean matchChars(char[] matchChars, int startIndex, char[] line); static int findChars(char[] matchChars, int startIndex, char[] line); static char[][] splitByPipe(char[] inputArray); static int NEWLINE; static int CARRIAGE_RETURN; }