LimeWire Consolidated API

org.limewire.http.entity
Class AbstractProducingNHttpEntity

java.lang.Object
  extended by org.apache.http.entity.AbstractHttpEntity
      extended by org.limewire.http.entity.AbstractProducingNHttpEntity
All Implemented Interfaces:
org.apache.http.HttpEntity, org.apache.http.nio.entity.ProducingNHttpEntity
Direct Known Subclasses:
BrowseRequestHandler.BrowseResponseEntity, FileResponseEntity, THEXResponseEntity

public abstract class AbstractProducingNHttpEntity
extends org.apache.http.entity.AbstractHttpEntity
implements org.apache.http.nio.entity.ProducingNHttpEntity

Abstract implementation of ProducingNHttpEntity that adds support for timing out the transfer if it takes too long.


Field Summary
 
Fields inherited from class org.apache.http.entity.AbstractHttpEntity
chunked, contentEncoding, contentType
 
Constructor Summary
AbstractProducingNHttpEntity()
           
 
Method Summary
protected  void activateTimeout()
           
protected  void deactivateTimeout()
           
 InputStream getContent()
          Throws UnsupportedOperationException.
abstract  long getContentLength()
           
abstract  void initialize(org.apache.http.nio.ContentEncoder contentEncoder, org.apache.http.nio.IOControl ioctrl)
          Invoked before the first call to writeContent(ContentEncoder, IOControl).
 boolean isRepeatable()
          Throws UnsupportedOperationException.
 boolean isStreaming()
          Throws UnsupportedOperationException.
 void produceContent(org.apache.http.nio.ContentEncoder encoder, org.apache.http.nio.IOControl ioctrl)
           
abstract  void timeout()
          Invoked when the transfer times out.
abstract  boolean writeContent(org.apache.http.nio.ContentEncoder contentEncoder, org.apache.http.nio.IOControl ioctrl)
          Sub-classes need to implement this and and write data to the ContentEncoder.
 void writeTo(OutputStream outstream)
          Throws UnsupportedOperationException.
 
Methods inherited from class org.apache.http.entity.AbstractHttpEntity
consumeContent, getContentEncoding, getContentType, isChunked, setChunked, setContentEncoding, setContentEncoding, setContentType, setContentType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.http.nio.entity.ProducingNHttpEntity
finish
 
Methods inherited from interface org.apache.http.HttpEntity
consumeContent, getContentEncoding, getContentType, isChunked
 

Constructor Detail

AbstractProducingNHttpEntity

public AbstractProducingNHttpEntity()
Method Detail

activateTimeout

protected void activateTimeout()

deactivateTimeout

protected void deactivateTimeout()

getContent

public InputStream getContent()
                       throws IOException,
                              IllegalStateException
Throws UnsupportedOperationException.

Specified by:
getContent in interface org.apache.http.HttpEntity
Throws:
IOException
IllegalStateException

getContentLength

public abstract long getContentLength()
Specified by:
getContentLength in interface org.apache.http.HttpEntity

isRepeatable

public boolean isRepeatable()
Throws UnsupportedOperationException.

Specified by:
isRepeatable in interface org.apache.http.HttpEntity

isStreaming

public boolean isStreaming()
Throws UnsupportedOperationException.

Specified by:
isStreaming in interface org.apache.http.HttpEntity

writeTo

public void writeTo(OutputStream outstream)
             throws IOException
Throws UnsupportedOperationException.

Specified by:
writeTo in interface org.apache.http.HttpEntity
Throws:
IOException

produceContent

public final void produceContent(org.apache.http.nio.ContentEncoder encoder,
                                 org.apache.http.nio.IOControl ioctrl)
                          throws IOException
Specified by:
produceContent in interface org.apache.http.nio.entity.ProducingNHttpEntity
Throws:
IOException

writeContent

public abstract boolean writeContent(org.apache.http.nio.ContentEncoder contentEncoder,
                                     org.apache.http.nio.IOControl ioctrl)
                              throws IOException
Sub-classes need to implement this and and write data to the ContentEncoder.

Returns:
true, if more data is expected; false, if the transfer is complete
Throws:
IOException - indicates an I/O error which will abort the connection

initialize

public abstract void initialize(org.apache.http.nio.ContentEncoder contentEncoder,
                                org.apache.http.nio.IOControl ioctrl)
                         throws IOException
Invoked before the first call to writeContent(ContentEncoder, IOControl).

Throws:
IOException - indicates an I/O error which will abort the connection

timeout

public abstract void timeout()
Invoked when the transfer times out. Needs to close the underlying connection.


LimeWire Consolidated API

Copyright © 2009. All Rights Reserved.