public String parseString ( final boolean needQuote ) { char quot = 0 ; if ( check ( ' ' ) ) { quot = ' ' ; } else if ( check ( ' ' ) ) { quot = ' ' ; } else if ( needQuote ) { throw new JSONParseException ( s , pos ) ; } char current ; if ( quot > 0 ) { read ( quot ) ; } StringBuilder buf = new StringBuilder ( ) ; int start = pos ; while ( pos < s . length ( ) ) { current = s . charAt ( pos ) ; if ( quot > 0 ) { if ( current == quot ) { break ; } } else { if ( current == ' ' || current == ' ' ) { break ; } } if ( current == ' ' ) { pos ++ ; char x = get ( ) ; char special = 0 ; //CHECKSTYLE:OFF switch ( x ) { case ' ' : // decode unicode buf . append ( s . substring ( start , pos - 1 ) ) ; pos ++ ; int tempPos = pos ; readHex ( ) ; readHex ( ) ; readHex ( ) ; readHex ( ) ; int codePoint = Integer . parseInt ( s . substring ( tempPos , tempPos + 4 ) , 16 ) ; buf . append ( ( char ) codePoint ) ; start = pos ; continue ; case ' ' : special = ' ' ; break ; case ' ' : special = ' ' ; break ; case ' ' : special = ' ' ; break ; case ' ' : special = ' ' ; break ; case ' ' : special = ' ' ; break ; case ' ' : special = ' ' ; break ; default : break ; } //CHECKSTYLE:ON buf . append ( s . substring ( start , pos - 1 ) ) ; if ( special != 0 ) { pos ++ ; buf . append ( special ) ; } start = pos ; continue ; } pos ++ ; } buf . append ( s . substring ( start , pos ) ) ; if ( quot > 0 ) { read ( quot ) ; } return buf . toString ( ) ; }
Parses a string .