Package org.glassfish.tyrus.core.coder
Class NoOpByteArrayCoder
- java.lang.Object
-
- org.glassfish.tyrus.core.coder.CoderAdapter
-
- org.glassfish.tyrus.core.coder.NoOpByteArrayCoder
-
- All Implemented Interfaces:
Decoder
,Decoder.Binary<byte[]>
,Encoder
,Encoder.Binary<byte[]>
public class NoOpByteArrayCoder extends CoderAdapter implements Decoder.Binary<byte[]>, Encoder.Binary<byte[]>
- Author:
- Pavel Bucek
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface jakarta.websocket.Decoder
Decoder.Binary<T>, Decoder.BinaryStream<T>, Decoder.Text<T>, Decoder.TextStream<T>
-
Nested classes/interfaces inherited from interface jakarta.websocket.Encoder
Encoder.Binary<T>, Encoder.BinaryStream<T>, Encoder.Text<T>, Encoder.TextStream<T>
-
-
Constructor Summary
Constructors Constructor Description NoOpByteArrayCoder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]
decode(java.nio.ByteBuffer bytes)
Decode the given bytes into an object of type T.java.nio.ByteBuffer
encode(byte[] object)
Encode the given object into a byte array.boolean
willDecode(java.nio.ByteBuffer bytes)
Answer whether the given bytes can be decoded into an object of type T.-
Methods inherited from class org.glassfish.tyrus.core.coder.CoderAdapter
destroy, init
-
-
-
-
Method Detail
-
encode
public java.nio.ByteBuffer encode(byte[] object) throws EncodeException
Description copied from interface:Encoder.Binary
Encode the given object into a byte array.- Specified by:
encode
in interfaceEncoder.Binary<byte[]>
- Parameters:
object
- the object being encoded.- Returns:
- the binary data.
- Throws:
EncodeException
- The provided object could not be encoded to a byte buffer
-
willDecode
public boolean willDecode(java.nio.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 interfaceDecoder.Binary<byte[]>
- Parameters:
bytes
- the bytes to be decoded.- Returns:
- whether or not the bytes can be decoded by this decoder.
-
decode
public byte[] decode(java.nio.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 interfaceDecoder.Binary<byte[]>
- Parameters:
bytes
- the bytes to be decoded.- Returns:
- the decoded object.
- Throws:
DecodeException
- If the provided bytes cannot be decoded to type T
-
-