Class InputStreamDecoder

java.lang.Object
org.glassfish.tyrus.core.coder.CoderAdapter
org.glassfish.tyrus.core.coder.InputStreamDecoder
All Implemented Interfaces:
Decoder, Decoder.Binary<InputStream>

public class InputStreamDecoder extends CoderAdapter implements Decoder.Binary<InputStream>
Built in Decoder for InputStream.
Author:
Pavel Bucek
  • Constructor Details

    • InputStreamDecoder

      public InputStreamDecoder()
  • Method Details

    • willDecode

      public boolean willDecode(ByteBuffer bytes)
      Description copied from interface: Decoder.Binary
      Answer whether the given bytes can be decoded into an object of type T.

      It is not safe for other threads to use the ByteBuffer until this method completes. When the method completes, the buffer will be in the same state as it was at the start of the method call.

      Specified by:
      willDecode in interface Decoder.Binary<InputStream>
      Parameters:
      bytes - the bytes to be decoded.
      Returns:
      whether or not the bytes can be decoded by this decoder.
    • decode

      public InputStream decode(ByteBuffer bytes) throws DecodeException
      Description copied from interface: Decoder.Binary
      Decode the given bytes into an object of type T.

      It is not safe for other threads to use the ByteBuffer until the decoding of the given bytes is complete. If the decoding completes successfully, the buffer's limit will be unchanged and the buffer's position will be equal to the limit. If the decoding does not complete successfully, the state of the buffer is undefined.

      Specified by:
      decode in interface Decoder.Binary<InputStream>
      Parameters:
      bytes - the bytes to be decoded.
      Returns:
      the decoded object.
      Throws:
      DecodeException - If the provided bytes cannot be decoded to type T