org.apache.mina.filter.codec |
Filter implementations that helps you to implement complex protocols
via 'codec' concept.
|
Java Source File Name | Type | Comment |
AbstractProtocolDecoderOutput.java | Class | A
ProtocolDecoderOutput based on queue. |
AbstractProtocolEncoderOutput.java | Class | A
ProtocolEncoderOutput based on queue. |
CumulativeProtocolDecoder.java | Class | A
ProtocolDecoder that cumulates the content of received
buffers to a cumulative buffer to help users implement decoders.
If the received
IoBuffer is only a part of a message.
decoders should cumulate received buffers to make a message complete or
to postpone decoding until more buffers arrive.
Here is an example decoder that decodes CRLF terminated lines into
Command objects:
public class CrLfTerminatedCommandLineDecoder
extends CumulativeProtocolDecoder {
private Command parseCommand(IoBuffer in) {
// Convert the bytes in the specified buffer to a
// Command object.
...
}
protected boolean doDecode(
IoSession session, IoBuffer in, ProtocolDecoderOutput out)
throws Exception {
// Remember the initial position.
int start = in.position();
// Now find the first CRLF in the buffer.
byte previous = 0;
while (in.hasRemaining()) {
byte current = in.get();
if (previous == '\r' && current == '\n') {
// Remember the current position and limit.
int position = in.position();
int limit = in.limit();
try {
in.position(start);
in.limit(position);
// The bytes between in.position() and in.limit()
// now contain a full CRLF terminated line.
out.write(parseCommand(in.slice()));
} finally {
// Set the position to point right after the
// detected line and set the limit to the old
// one.
in.position(position);
in.limit(limit);
}
// Decoded one line; CumulativeProtocolDecoder will
// call me again until I return false. |
CumulativeProtocolDecoderTest.java | Class | Tests
CumulativeProtocolDecoder . |
ProtocolCodecException.java | Class | An exception that is thrown when
ProtocolEncoder or
ProtocolDecoder cannot understand or failed to validate
data to process. |
ProtocolCodecFactory.java | Interface | Provides
ProtocolEncoder and
ProtocolDecoder which translates
binary or protocol specific data into message object and vice versa. |
ProtocolCodecFilter.java | Class | An
IoFilter which translates binary or protocol specific data into
message object and vice versa using
ProtocolCodecFactory ,
ProtocolEncoder , or
ProtocolDecoder . |
ProtocolCodecSession.java | Class | A virtual
IoSession that provides
ProtocolEncoderOutput and
ProtocolDecoderOutput . |
ProtocolDecoder.java | Interface | Decodes binary or protocol-specific data into higher-level message objects. |
ProtocolDecoderAdapter.java | Class | An abstract
ProtocolDecoder implementation for those who don't need
ProtocolDecoder.finishDecode(IoSessionProtocolDecoderOutput) nor
ProtocolDecoder.dispose(IoSession) method. |
ProtocolDecoderException.java | Class | An exception that is thrown when
ProtocolDecoder cannot understand or failed to validate the specified
IoBuffer content. |
ProtocolDecoderOutput.java | Interface | Callback for
ProtocolDecoder to generate decoded messages. |
ProtocolEncoder.java | Interface | Encodes higher-level message objects into binary or protocol-specific data. |
ProtocolEncoderAdapter.java | Class | An abstract
ProtocolEncoder implementation for those who don't have any
resources to dispose. |
ProtocolEncoderException.java | Class | An exception that is thrown when
ProtocolEncoder cannot understand or failed to validate the specified message object. |
ProtocolEncoderOutput.java | Interface | Callback for
ProtocolEncoder to generate encoded messages such as
IoBuffer s. |
RecoverableProtocolDecoderException.java | Class | A special exception that tells the
ProtocolDecoder can keep
decoding even after this exception is thrown. |
SynchronizedProtocolDecoder.java | Class | A
ProtocolDecoder implementation which decorates an existing decoder
to be thread-safe. |
SynchronizedProtocolEncoder.java | Class | A
ProtocolEncoder implementation which decorates an existing encoder
to be thread-safe. |