Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.http.entity
Class HttpEntityWrapper  view HttpEntityWrapper download HttpEntityWrapper.java

java.lang.Object
  extended byorg.apache.http.entity.HttpEntityWrapper
All Implemented Interfaces:
org.apache.http.HttpEntity
Direct Known Subclasses:
BufferedHttpEntity

public class HttpEntityWrapper
extends java.lang.Object
implements org.apache.http.HttpEntity

Base class for wrapping entities. Keeps a wrappedEntity 55 and delegates all calls to it. Implementations of wrapping entities can derive from this class and need to override only those methods that should not be delegated to the wrapped entity.

Since:
4.0
Version:
$Revision: 374920 $

Field Summary
protected  org.apache.http.HttpEntity wrappedEntity
          The wrapped entity.
 
Constructor Summary
HttpEntityWrapper(org.apache.http.HttpEntity wrapped)
          Creates a new entity wrapper.
 
Method Summary
 void consumeContent()
          Consumes the remaining content of a streamed entity.
 java.io.InputStream getContent()
          Creates a new InputStream object of the entity.
 org.apache.http.Header getContentEncoding()
          Obtains the Content-Encoding header, if known.
 long getContentLength()
          Tells the length of the content, if known.
 org.apache.http.Header getContentType()
          Obtains the Content-Type header, if known.
 boolean isChunked()
          Tells about chunked encoding for this entity.
 boolean isRepeatable()
          Tells if the entity is capable to produce its data more than once.
 boolean isStreaming()
          Tells whether this entity depends on an underlying stream.
 void writeTo(java.io.OutputStream outstream)
          Writes the entity content to the output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

wrappedEntity

protected org.apache.http.HttpEntity wrappedEntity
The wrapped entity.

Constructor Detail

HttpEntityWrapper

public HttpEntityWrapper(org.apache.http.HttpEntity wrapped)
Creates a new entity wrapper.

Method Detail

isRepeatable

public boolean isRepeatable()
Description copied from interface: org.apache.http.HttpEntity
Tells if the entity is capable to produce its data more than once. A repeatable entity's getContent() and writeTo(OutputStream) methods can be called more than once whereas a non-repeatable entity's can not.

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

isChunked

public boolean isChunked()
Description copied from interface: org.apache.http.HttpEntity
Tells about chunked encoding for this entity. The primary purpose of this method is to indicate whether chunked encoding should be used when the entity is sent. For entities that are received, it can also indicate whether the entity was received with chunked encoding.
The behavior of wrapping entities is implementation dependent, but should respect the primary purpose.

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

getContentLength

public long getContentLength()
Description copied from interface: org.apache.http.HttpEntity
Tells the length of the content, if known.

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

getContentType

public org.apache.http.Header getContentType()
Description copied from interface: org.apache.http.HttpEntity
Obtains the Content-Type header, if known. This is the header that should be used when sending the entity, or the one that was received with the entity. It can include a charset attribute.

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

getContentEncoding

public org.apache.http.Header getContentEncoding()
Description copied from interface: org.apache.http.HttpEntity
Obtains the Content-Encoding header, if known. This is the header that should be used when sending the entity, or the one that was received with the entity. Wrapping entities that modify the content encoding should adjust this header accordingly.

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

getContent

public java.io.InputStream getContent()
                               throws java.io.IOException
Description copied from interface: org.apache.http.HttpEntity
Creates a new InputStream object of the entity. It is a programming error to return the same InputStream object more than once. Entities that are not repeatable 55 will throw an exception if this method is called multiple times.

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

writeTo

public void writeTo(java.io.OutputStream outstream)
             throws java.io.IOException
Description copied from interface: org.apache.http.HttpEntity
Writes the entity content to the output stream.

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

isStreaming

public boolean isStreaming()
Description copied from interface: org.apache.http.HttpEntity
Tells whether this entity depends on an underlying stream. Streamed entities should return true until the content has been consumed, false afterwards. Self-contained entities should return false. Wrapping entities should delegate this call to the wrapped entity.
The content of a streamed entity is consumed when the stream returned by getContent 55 has been read to EOF, or after consumeContent 55 has been called. If a streamed entity can not detect whether the stream has been read to EOF, it should return true until consumeContent 55 is called.

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

consumeContent

public void consumeContent()
                    throws java.io.IOException
Description copied from interface: org.apache.http.HttpEntity
Consumes the remaining content of a streamed entity. This method is called to indicate that the content of this entity is no longer required. Streamed entities should dispose of the remaining content, if any. Self-contained entities can release allocated resources, but are not required to do anything. Wrapping entities should delegate this call to the wrapped entity.
This method is of particular importance for entities being received from a connection. The entity needs to be consumed completely in order to re-use the connection with keep-alive.

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