Class MessageStreamDecoderAdapter
- java.lang.Object
-
- com.biglybt.pifimpl.local.messaging.MessageStreamDecoderAdapter
-
- All Implemented Interfaces:
MessageStreamDecoder
public class MessageStreamDecoderAdapter extends java.lang.Object implements MessageStreamDecoder
-
-
Field Summary
Fields Modifier and Type Field Description private MessageStreamDecoder
plug_decoder
-
Constructor Summary
Constructors Constructor Description MessageStreamDecoderAdapter(MessageStreamDecoder plug_decoder)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.nio.ByteBuffer
destroy()
Destroy this decoder, i.e.int
getDataBytesDecoded()
Get the number of (piece) data bytes decoded from the transport, from the last decode op.int
getPercentDoneOfCurrentMessage()
Get the percentage of the current message that has already been received (read from the transport).int
getProtocolBytesDecoded()
Get the number of protocol (overhead) bytes decoded from the transport, from the last decode op.void
pauseDecoding()
Pause message decoding.int
performStreamDecode(Transport transport, int max_bytes)
Decode message stream from the given transport.Message[]
removeDecodedMessages()
Get the messages decoded from the transport, if any, from the last decode op.void
resumeDecoding()
Resume message decoding.
-
-
-
Field Detail
-
plug_decoder
private final MessageStreamDecoder plug_decoder
-
-
Constructor Detail
-
MessageStreamDecoderAdapter
public MessageStreamDecoderAdapter(MessageStreamDecoder plug_decoder)
-
-
Method Detail
-
performStreamDecode
public int performStreamDecode(Transport transport, int max_bytes) throws java.io.IOException
Description copied from interface:MessageStreamDecoder
Decode message stream from the given transport.- Specified by:
performStreamDecode
in interfaceMessageStreamDecoder
- Parameters:
transport
- to decode frommax_bytes
- to decode/read from the stream- Returns:
- number of bytes decoded
- Throws:
java.io.IOException
- on decoding error
-
getPercentDoneOfCurrentMessage
public int getPercentDoneOfCurrentMessage()
Description copied from interface:MessageStreamDecoder
Get the percentage of the current message that has already been received (read from the transport).- Specified by:
getPercentDoneOfCurrentMessage
in interfaceMessageStreamDecoder
- Returns:
- percentage complete (0-99), or -1 if no message is currently being received
-
removeDecodedMessages
public Message[] removeDecodedMessages()
Description copied from interface:MessageStreamDecoder
Get the messages decoded from the transport, if any, from the last decode op.- Specified by:
removeDecodedMessages
in interfaceMessageStreamDecoder
- Returns:
- decoded messages, or null if no new complete messages were decoded
-
getProtocolBytesDecoded
public int getProtocolBytesDecoded()
Description copied from interface:MessageStreamDecoder
Get the number of protocol (overhead) bytes decoded from the transport, from the last decode op.- Specified by:
getProtocolBytesDecoded
in interfaceMessageStreamDecoder
- Returns:
- number of protocol bytes recevied
-
getDataBytesDecoded
public int getDataBytesDecoded()
Description copied from interface:MessageStreamDecoder
Get the number of (piece) data bytes decoded from the transport, from the last decode op.- Specified by:
getDataBytesDecoded
in interfaceMessageStreamDecoder
- Returns:
- number of data bytes received
-
pauseDecoding
public void pauseDecoding()
Description copied from interface:MessageStreamDecoder
Pause message decoding.- Specified by:
pauseDecoding
in interfaceMessageStreamDecoder
-
resumeDecoding
public void resumeDecoding()
Description copied from interface:MessageStreamDecoder
Resume message decoding.- Specified by:
resumeDecoding
in interfaceMessageStreamDecoder
-
destroy
public java.nio.ByteBuffer destroy()
Description copied from interface:MessageStreamDecoder
Destroy this decoder, i.e. perform cleanup.- Specified by:
destroy
in interfaceMessageStreamDecoder
- Returns:
- any bytes already-read and still remaining within the decoder
-
-