Interface Decoder<T extends MessageHeader,R extends MessageHeader>
- Type Parameters:
T
- the type of message decoded by this decoderR
- the type of message that may be generated as response (seeDecoder.Result.response()
)
- All Superinterfaces:
Codec
- All Known Implementing Classes:
HttpDecoder
,HttpRequestDecoder
,HttpResponseDecoder
,WsDecoder
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic class
Decoder.Result<R extends MessageHeader>
The result from decoding.Nested classes/interfaces inherited from interface org.jdrupes.httpcodec.Codec
Codec.ProtocolSwitchResult
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptiondecode
(ByteBuffer in, Buffer out, boolean endOfInput) Decodes the next chunk of data.decoding()
Returns the type of the messages decoded by this decoder.header()
Returns the last message (header) received.setPeerEncoder
(Encoder<R, T> encoder) Sets the peer encoder.
-
Method Details
-
setPeerEncoder
Sets the peer encoder.Some decoders need to know the state of the encoder or the last encoded message.
- Parameters:
encoder
- the encoder- Returns:
- the decoder
-
decoding
Returns the type of the messages decoded by this decoder.- Returns:
- the value
-
decode
Decodes the next chunk of data.This method will never leave remaining data in the
in
buffer unless a header has been decoded completely and/or theout
buffer is full. In either case, decoding will therefore continue when the method is invoked again with the samein
buffer and another (or emptied)out
buffer. It is never necessary (though possible) to add data to an existingin
buffer.- Parameters:
in
- holds the data to be decodedout
- gets the body data (if any) written to itendOfInput
- true if there is no input left beyond the data currently in the in buffer (indicates end of body or no body at all)- Returns:
- the result
- Throws:
ProtocolException
- if the message violates the HTTP
-
header
Returns the last message (header) received.If a header is completed during a
decode(ByteBuffer, Buffer, boolean)
invocation, the result’sDecoder.Result.isHeaderCompleted()
istrue
and the header can be retrieved using this method. It remains available untildecode
is invoked for a new message (i.e. is invoked again after returning a result withCodec.Result.isUnderflow()
beingfalse
.- Returns:
- the result
-