public void setToken ( String completeToken ) { clearParameters ( ) ; id = "" ; if ( completeToken != null ) { StringBuilder builder = new StringBuilder ( ) ; char [ ] chs = completeToken . toCharArray ( ) ; String currentKey = null ; TokenParseState state = TokenParseState . PARSING_ID ; for ( char ch : chs ) { switch ( state ) { case PARSING_ID : if ( ch == ' ' ) { state = TokenParseState . PARSING_KEY ; id = builder . toString ( ) ; builder . delete ( 0 , builder . length ( ) ) ; } else { builder . append ( ch ) ; } break ; case PARSING_KEY : if ( ch == ' ' ) { state = TokenParseState . PARSING_VALUE ; currentKey = builder . toString ( ) ; if ( ! currentKey . isEmpty ( ) ) { parameters . put ( currentKey , "" ) ; builder . delete ( 0 , builder . length ( ) ) ; } } else if ( ch == ' ' ) { currentKey = builder . toString ( ) ; if ( ! currentKey . isEmpty ( ) ) { parameters . put ( currentKey , "" ) ; builder . delete ( 0 , builder . length ( ) ) ; } } else { builder . append ( ch ) ; } break ; case PARSING_VALUE : if ( ch == ' ' ) { state = TokenParseState . PARSING_COMPLEX_VALUE ; } else if ( ch == ' ' ) { state = TokenParseState . PARSING_KEY ; parameters . put ( currentKey , builder . toString ( ) ) ; builder . delete ( 0 , builder . length ( ) ) ; } else { builder . append ( ch ) ; } break ; case PARSING_COMPLEX_VALUE : if ( ch == ' ' ) { state = TokenParseState . PARSED_COMPLEX_VALUE ; parameters . put ( currentKey , builder . toString ( ) ) ; builder . delete ( 0 , builder . length ( ) ) ; } else { builder . append ( ch ) ; } break ; case PARSED_COMPLEX_VALUE : if ( ch == ' ' ) { state = TokenParseState . PARSING_KEY ; } break ; } } switch ( state ) { case PARSING_ID : id = builder . toString ( ) ; break ; case PARSING_KEY : currentKey = builder . toString ( ) ; if ( ! currentKey . isEmpty ( ) ) { parameters . put ( currentKey , "" ) ; } break ; case PARSING_COMPLEX_VALUE : case PARSING_VALUE : String value = builder . toString ( ) ; if ( ! value . isEmpty ( ) && currentKey != null ) { parameters . put ( currentKey , value ) ; } break ; default : break ; } } }
Sets the current token causing it to parse the parameters and the tokenId .