Interface MessageDecoder
- All Known Implementing Classes:
MessageDecoderAdapter
public interface MessageDecoder
Decodes a certain type of messages.
We didn't provide any dispose method for MessageDecoder
because it can give you performance penalty in case you have a lot of
message types to handle.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final MessageDecoderResultRepresents a result fromdecodable(IoSession, IoBuffer)anddecode(IoSession, IoBuffer, ProtocolDecoderOutput).static final MessageDecoderResultRepresents a result fromdecodable(IoSession, IoBuffer)anddecode(IoSession, IoBuffer, ProtocolDecoderOutput).static final MessageDecoderResultRepresents a result fromdecodable(IoSession, IoBuffer)anddecode(IoSession, IoBuffer, ProtocolDecoderOutput). -
Method Summary
Modifier and TypeMethodDescriptionChecks the specified buffer is decodable by this decoder.decode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) Decodes binary or protocol-specific content into higher-level message objects.voidfinishDecode(IoSession session, ProtocolDecoderOutput out) Invoked when the specifiedsessionis closed while this decoder was parsing the data.
-
Field Details
-
OK
Represents a result fromdecodable(IoSession, IoBuffer)anddecode(IoSession, IoBuffer, ProtocolDecoderOutput). Please refer to each method's documentation for detailed explanation. -
NEED_DATA
Represents a result fromdecodable(IoSession, IoBuffer)anddecode(IoSession, IoBuffer, ProtocolDecoderOutput). Please refer to each method's documentation for detailed explanation. -
NOT_OK
Represents a result fromdecodable(IoSession, IoBuffer)anddecode(IoSession, IoBuffer, ProtocolDecoderOutput). Please refer to each method's documentation for detailed explanation.
-
-
Method Details
-
decodable
Checks the specified buffer is decodable by this decoder.- Parameters:
session- The current sessionin- The buffer containing the data to decode- Returns:
OKif this decoder can decode the specified buffer.NOT_OKif this decoder cannot decode the specified buffer.NEED_DATAif more data is required to determine if the specified buffer is decodable (OK) or not decodableNOT_OK.
-
decode
MessageDecoderResult decode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws Exception Decodes binary or protocol-specific content into higher-level message objects. MINA invokesdecode(IoSession, IoBuffer, ProtocolDecoderOutput)method with read data, and then the decoder implementation puts decoded messages intoProtocolDecoderOutput.- Parameters:
session- The current sessionin- The buffer containing the data to decodeout- The instance ofProtocolDecoderOutputthat will receive the decoded messages- Returns:
OKif you finished decoding messages successfully.NEED_DATAif you need more data to finish decoding current message.NOT_OKif you cannot decode current message due to protocol specification violation.- Throws:
Exception- if the read data violated protocol specification
-
finishDecode
Invoked when the specifiedsessionis closed while this decoder was parsing the data. This method is useful when you deal with the protocol which doesn't specify the length of a message such as HTTP response withoutcontent-lengthheader. Implement this method to process the remaining data thatdecode(IoSession, IoBuffer, ProtocolDecoderOutput)method didn't process completely.- Parameters:
session- The current sessionout- The instance ofProtocolDecoderOutputthat contains the decoded messages- Throws:
Exception- if the read data violated protocol specification
-