com.aelitis.azureus.core.networkmanager.impl.http
Class HTTPMessageDecoder

java.lang.Object
  extended by com.aelitis.azureus.core.networkmanager.impl.http.HTTPMessageDecoder
All Implemented Interfaces:
MessageStreamDecoder

public class HTTPMessageDecoder
extends java.lang.Object
implements MessageStreamDecoder


Constructor Summary
HTTPMessageDecoder()
           
HTTPMessageDecoder(java.lang.String pre_read_header)
           
 
Method Summary
protected  void addMessage(Message message)
           
 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.
protected  int getQueueSize()
           
 void pauseDecoding()
          Pause message decoding.
protected  void pauseInternally()
           
 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.
 void setConnection(HTTPNetworkConnection _http_connection)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HTTPMessageDecoder

public HTTPMessageDecoder()

HTTPMessageDecoder

public HTTPMessageDecoder(java.lang.String pre_read_header)
Method Detail

setConnection

public void setConnection(HTTPNetworkConnection _http_connection)

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 interface MessageStreamDecoder
Parameters:
transport - to decode from
max_bytes - to decode/read from the stream
Returns:
number of bytes decoded
Throws:
java.io.IOException - on decoding error

addMessage

protected void addMessage(Message message)

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 interface MessageStreamDecoder
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 interface MessageStreamDecoder
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 interface MessageStreamDecoder
Returns:
number of data bytes received

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 interface MessageStreamDecoder
Returns:
percentage complete (0-99), or -1 if no message is currently being received

pauseInternally

protected void pauseInternally()

pauseDecoding

public void pauseDecoding()
Description copied from interface: MessageStreamDecoder
Pause message decoding.

Specified by:
pauseDecoding in interface MessageStreamDecoder

resumeDecoding

public void resumeDecoding()
Description copied from interface: MessageStreamDecoder
Resume message decoding.

Specified by:
resumeDecoding in interface MessageStreamDecoder

getQueueSize

protected int getQueueSize()

destroy

public java.nio.ByteBuffer destroy()
Description copied from interface: MessageStreamDecoder
Destroy this decoder, i.e. perform cleanup.

Specified by:
destroy in interface MessageStreamDecoder
Returns:
any bytes already-read and still remaining within the decoder