/** * Check if the given byte is UTF-8 data. * * @param b * @throws IOException */ public void checkUTF8(int b) throws UnsupportedEncodingException { byte type = TYPES[b & 0xFF]; codep = state != UTF8_ACCEPT ? b & 0x3f | codep << 6 : 0xff >> type & b; state = STATES[state + type]; if (state == UTF8_REJECT) { throw WebSocketMessages.MESSAGES.invalidTextFrameEncoding(); } }
/** * Should be called to mark the UTF8Checker as complete. After that it MUST not been used anymore */ public void complete() throws UnsupportedEncodingException { if (state != UTF8_ACCEPT) { throw WebSocketMessages.MESSAGES.invalidTextFrameEncoding(); } }