question: private CoderResult switchDecoder ( short lastByte , CharBuffer cb ) { CoderResult cr = CoderResult . UNDERFLOW ; CharsetDecoder decoder = null ; boolean high = false ; byte [ ] escSequence ; byte [ ] encoding = null ; if ( lastByte != 0 ) { queue . write ( lastByte ) ; } escSequence = queue . toByteArray ( ) ; queue . reset ( ) ; if ( state == CHARSET_NONSTANDARD ) { encoding = encodingQueue . toByteArray ( ) ; encodingQueue . reset ( ) ; decoder = CompoundTextSupport . getNonStandardDecoder ( escSequence , encoding ) ; } else { decoder = CompoundTextSupport . getStandardDecoder ( escSequence ) ; high = CompoundTextSupport . getHighBit ( escSequence ) ; } if ( decoder != null ) { initDecoder ( decoder ) ; } else if ( unmappableCharacterAction ( ) == CodingErrorAction . REPORT ) { int badInputLength = 1 ; if ( encoding != null ) { badInputLength = encoding . length ; } else if ( escSequence . length > 0 ) { badInputLength = escSequence . length ; } return CoderResult . unmappableForLength ( badInputLength ) ; } if ( state == CHARSET_NLIIF || state == CHARSET_NLIF || state == CHARSET_LIIF || state == CHARSET_LIF ) { if ( lastDecoder == glDecoder ) { cr = flushDecoder ( glDecoder , cb ) ; } glDecoder = lastDecoder = decoder ; glHigh = high ; state = NORMAL_BYTES ; } else if ( state == CHARSET_NRIIF || state == CHARSET_NRIF || state == CHARSET_RIIF || state == CHARSET_RIF ) { if ( lastDecoder == grDecoder ) { cr = flushDecoder ( grDecoder , cb ) ; } grDecoder = lastDecoder = decoder ; grHigh = high ; state = NORMAL_BYTES ; } else if ( state == CHARSET_NONSTANDARD ) { if ( lastDecoder != null ) { cr = flushDecoder ( lastDecoder , cb ) ; lastDecoder = null ; } nonStandardDecoder = decoder ; state = NONSTANDARD_BYTES ; } else { error ( ERR_ILLSTATE ) ; } return cr ; }
target:  Preconditions: 1. 'queue' contains ControlSequence.escSequence 2. 'encodingQueue' contains ControlSequence.encoding