protected String parseStringContent ( final char quote ) { final int startNdx = ndx ; // roll-out until the end of the string or the escape char while ( true ) { final char c = input [ ndx ] ; if ( c == quote ) { // no escapes found, just use existing string ndx ++ ; return new String ( input , startNdx , ndx - 1 - startNdx ) ; } if ( c == ' ' ) { break ; } ndx ++ ; } // escapes found, proceed differently textLen = ndx - startNdx ; growEmpty ( ) ; // for (int i = startNdx, j = 0; j < textLen; i++, j++) { // text[j] = input[i]; // } System . arraycopy ( input , startNdx , text , 0 , textLen ) ; // escape char, process everything until the end while ( true ) { char c = input [ ndx ] ; if ( c == quote ) { // done ndx ++ ; final String str = new String ( text , 0 , textLen ) ; textLen = 0 ; return str ; } if ( c == ' ' ) { // escape char found ndx ++ ; c = input [ ndx ] ; switch ( c ) { case ' ' : c = ' ' ; break ; case ' ' : c = ' ' ; break ; case ' ' : c = ' ' ; break ; case ' ' : c = ' ' ; break ; case ' ' : c = ' ' ; break ; case ' ' : c = ' ' ; break ; case ' ' : c = ' ' ; break ; case ' ' : c = ' ' ; break ; case ' ' : ndx ++ ; c = parseUnicode ( ) ; break ; default : if ( looseMode ) { if ( c != ' ' ) { c = ' ' ; ndx -- ; } } else { syntaxError ( "Invalid escape char: " + c ) ; } } } text [ textLen ] = c ; textLen ++ ; growAndCopy ( ) ; ndx ++ ; } }
Parses string content once when starting quote has been consumed .