Search in sources :

Example 1 with BinaryStream

use of javax.websocket.Decoder.BinaryStream in project tomcat by apache.

the class PojoMessageHandlerWholeBinary method decode.

@Override
protected Object decode(ByteBuffer message) throws DecodeException {
    for (Decoder decoder : decoders) {
        if (decoder instanceof Binary) {
            if (((Binary<?>) decoder).willDecode(message)) {
                return ((Binary<?>) decoder).decode(message);
            }
        } else {
            byte[] array = new byte[message.limit() - message.position()];
            message.get(array);
            ByteArrayInputStream bais = new ByteArrayInputStream(array);
            try {
                return ((BinaryStream<?>) decoder).decode(bais);
            } catch (IOException ioe) {
                throw new DecodeException(message, sm.getString("pojoMessageHandlerWhole.decodeIoFail"), ioe);
            }
        }
    }
    return null;
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) BinaryStream(javax.websocket.Decoder.BinaryStream) Binary(javax.websocket.Decoder.Binary) IOException(java.io.IOException) Decoder(javax.websocket.Decoder) DecodeException(javax.websocket.DecodeException)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 DecodeException (javax.websocket.DecodeException)1 Decoder (javax.websocket.Decoder)1 Binary (javax.websocket.Decoder.Binary)1 BinaryStream (javax.websocket.Decoder.BinaryStream)1