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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description 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 usingdecode(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 toinputRequired()
returned true.- Parameters:
buf
- a byte array containing data from the streamoffset
- the start offset in the datalength
- the number of bytes
-
getNext
byte[] getNext()
Get the next datagram. This method should only be called after a call toinputRequired()
returned false. Otherwise the result is undefined.- Returns:
- a byte array containing the datagram
-
-