Top Description Fields Constructors Methods
org.apache.http.entity

public Class EntityTemplate

extends AbstractHttpEntity
Class Inheritance
Imports
java.io.ByteArrayInputStream, .ByteArrayOutputStream, .IOException, .InputStream, .OutputStream, org.apache.http.util.Args

Entity that delegates the process of content generation to a ContentProducer.
Since
4.0

Field Summary

Modifier and TypeField and Description
private final ContentProducer
Inherited from org.apache.http.entity.AbstractHttpEntity:
chunkedcontentEncodingcontentTypeOUTPUT_BUFFER_SIZE

Constructor Summary

AccessConstructor and Description
public
EntityTemplate(final ContentProducer contentproducer)

Method Summary

Modifier and TypeMethod and Description
public InputStream
getContent()

Implements org.apache.http.HttpEntity.getContent.

Returns a content stream of the entity.
public long
getContentLength()

Implements org.apache.http.HttpEntity.getContentLength.

Tells the length of the content, if known.
public boolean
isRepeatable()

Implements org.apache.http.HttpEntity.isRepeatable.

Tells if the entity is capable of producing its data more than once.
public boolean
isStreaming()

Implements org.apache.http.HttpEntity.isStreaming.

Tells whether this entity depends on an underlying stream.
public void
writeTo(final OutputStream
the output stream to write entity content to
outStream
)

Implements org.apache.http.HttpEntity.writeTo.

Writes the entity content out to the output stream.
Inherited from org.apache.http.entity.AbstractHttpEntity:
consumeContentgetContentEncodinggetContentTypeisChunkedsetChunkedsetContentEncodingsetContentEncodingsetContentTypesetContentTypetoString

Field Detail

contentproducerback to summary
private final ContentProducer contentproducer

Constructor Detail

EntityTemplateback to summary
public EntityTemplate(final ContentProducer contentproducer)

Method Detail

getContentback to summary
public InputStream getContent() throws IOException

Implements org.apache.http.HttpEntity.getContent.

Doc from org.apache.http.HttpEntity.getContent.

Returns a content stream of the entity. Repeatable entities are expected to create a new instance of InputStream for each invocation of this method and therefore can be consumed multiple times. Entities that are not repeatable are expected to return the same InputStream instance and therefore may not be consumed more than once.

Important Note

Please note all entity implementations must ensure that all allocated resources are properly deallocated after the InputStream#close() method is invoked.

Returns:InputStream

content stream of the entity.

Annotations
@Override
Exceptions
IOException:
if the stream could not be created
getContentLengthback to summary
public long getContentLength()

Implements org.apache.http.HttpEntity.getContentLength.

Doc from org.apache.http.HttpEntity.getContentLength.

Tells the length of the content, if known.

Returns:long

the number of bytes of the content, or a negative number if unknown. If the content length is known but exceeds Long.MAX_VALUE, a negative number is returned.

Annotations
@Override
isRepeatableback to summary
public boolean isRepeatable()

Implements org.apache.http.HttpEntity.isRepeatable.

Doc from org.apache.http.HttpEntity.isRepeatable.

Tells if the entity is capable of producing 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.

Returns:boolean

true if the entity is repeatable, false otherwise.

Annotations
@Override
isStreamingback to summary
public boolean isStreaming()

Implements org.apache.http.HttpEntity.isStreaming.

Doc from org.apache.http.HttpEntity.isStreaming.

Tells whether this entity depends on an underlying stream. Streamed entities that read data directly from the socket should return true. Self-contained entities should return false. Wrapping entities should delegate this call to the wrapped entity.

Returns:boolean

true if the entity content is streamed, false otherwise

Annotations
@Override
writeToback to summary
public void writeTo(final OutputStream outStream) throws IOException

Implements org.apache.http.HttpEntity.writeTo.

Doc from org.apache.http.HttpEntity.writeTo.

Writes the entity content out to the output stream.

Important Note

Please note all entity implementations must ensure that all allocated resources are properly deallocated when this method returns.

Parameters
outStream:OutputStream

the output stream to write entity content to

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs