org.apache.synapse.transport.pipe
Interface ProtocolDecoder


public interface ProtocolDecoder

Datagram stream decoder.

Objects implementing this interface are created by Protocol objects. They are used to decompose a stream into individual datagrams.


Method Summary
 void decode(byte[] buf, int offset, int length)
          Decode data from the stream.
 byte[] getNext()
          Get the next datagram.
 boolean inputRequired()
          Check whether the decoder requires more input.
 

Method Detail

inputRequired

boolean inputRequired()
Check whether the decoder requires more input.

Returns:
true if a datagram is ready to be retrieved using getNext(), false if no datagram is available and the caller should provide more input using decode(byte[], int, int)

decode

void decode(byte[] buf,
            int offset,
            int length)
Decode data from the stream. This method should be called after a call to inputRequired() returned true.

Parameters:
buf - a byte array containing data from the stream
offset - the start offset in the data
length - the number of bytes

getNext

byte[] getNext()
Get the next datagram. This method should only be called after a call to inputRequired() returned false. Otherwise the result is undefined.

Returns:
a byte array containing the datagram


Copyright © 2005-2012 Apache Software Foundation. All Rights Reserved.