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

public Class EntityBuilder

extends Object
Class Inheritance
Imports
java.io.File, .InputStream, .Serializable, java.util.Arrays, .List, org.apache.http.HttpEntity, .NameValuePair, org.apache.http.entity.AbstractHttpEntity, .BasicHttpEntity, .ByteArrayEntity, .ContentType, .FileEntity, .InputStreamEntity, .SerializableEntity, .StringEntity

Builder for HttpEntity instances.

Several setter methods of this builder are mutually exclusive. In case of multiple invocations of the following methods only the last one will have effect:

Since
4.3

Field Summary

Modifier and TypeField and Description
private byte[]
private boolean
private String
private ContentType
private File
private boolean
private List<NameValuePair>
private Serializable
private InputStream
private String

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public HttpEntity
build()

Creates new instance of HttpEntity based on the current state.

public EntityBuilder
chunked()

Makes entity chunk coded.

private void
public static EntityBuilder
public byte[]
getBinary()

Returns entity content as a byte array if set using setBinary(byte[]) method.

public String
getContentEncoding()

Returns content encoding of the entity, if set.

private ContentType
public ContentType
getContentType()

Returns ContentType of the entity, if set.

public File
getFile()

Returns entity content as a File if set using setFile(java.io.File) method.

public List<NameValuePair>
getParameters()

Returns entity content as a parameter list if set using setParameters(java.util.List) or setParameters(org.apache.http.NameValuePair...) methods.

public Serializable
getSerializable()

Returns entity content as a Serializable if set using setSerializable(java.io.Serializable) method.

public InputStream
getStream()

Returns entity content as a InputStream if set using setStream(java.io.InputStream) method.

public String
getText()

Returns entity content as a string if set using setText(String) method.

public EntityBuilder
gzipCompress()

Makes entity GZIP compressed.

public boolean
isChunked()

Returns true if entity is to be chunk coded, false otherwise.

public boolean
isGzipCompress()

Returns true if entity is to be GZIP compressed, false otherwise.

public EntityBuilder
setBinary(final byte[] binary)

Sets entity content as a byte array.

public EntityBuilder
setContentEncoding(final String contentEncoding)

Sets content encoding of the entity.

public EntityBuilder
setContentType(final ContentType contentType)

Sets ContentType of the entity.

public EntityBuilder
setFile(final File file)

Sets entity content as a File.

public EntityBuilder
setParameters(final List<NameValuePair> parameters)

Sets entity content as a parameter list.

public EntityBuilder
setParameters(final NameValuePair... parameters)

Sets entity content as a parameter list.

public EntityBuilder
setSerializable(final Serializable serializable)

Sets entity content as a Serializable.

public EntityBuilder
setStream(final InputStream stream)

Sets entity content as a InputStream.

public EntityBuilder
setText(final String text)

Sets entity content as a string.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

binaryback to summary
private byte[] binary
chunkedback to summary
private boolean chunked
contentEncodingback to summary
private String contentEncoding
contentTypeback to summary
private ContentType contentType
fileback to summary
private File file
gzipCompressback to summary
private boolean gzipCompress
parametersback to summary
private List<NameValuePair> parameters
serializableback to summary
private Serializable serializable
streamback to summary
private InputStream stream
textback to summary
private String text

Constructor Detail

EntityBuilderback to summary
pack-priv EntityBuilder()

Method Detail

buildback to summary
public HttpEntity build()

Creates new instance of HttpEntity based on the current state.

chunkedback to summary
public EntityBuilder chunked()

Makes entity chunk coded.

clearContentback to summary
private void clearContent()
createback to summary
public static EntityBuilder create()
getBinaryback to summary
public byte[] getBinary()

Returns entity content as a byte array if set using setBinary(byte[]) method.

getContentEncodingback to summary
public String getContentEncoding()

Returns content encoding of the entity, if set.

getContentOrDefaultback to summary
private ContentType getContentOrDefault(final ContentType def)
getContentTypeback to summary
public ContentType getContentType()

Returns ContentType of the entity, if set.

getFileback to summary
public File getFile()

Returns entity content as a File if set using setFile(java.io.File) method.

getParametersback to summary
public List<NameValuePair> getParameters()

Returns entity content as a parameter list if set using setParameters(java.util.List) or setParameters(org.apache.http.NameValuePair...) methods.

getSerializableback to summary
public Serializable getSerializable()

Returns entity content as a Serializable if set using setSerializable(java.io.Serializable) method.

getStreamback to summary
public InputStream getStream()

Returns entity content as a InputStream if set using setStream(java.io.InputStream) method.

getTextback to summary
public String getText()

Returns entity content as a string if set using setText(String) method.

gzipCompressback to summary
public EntityBuilder gzipCompress()

Makes entity GZIP compressed.

isChunkedback to summary
public boolean isChunked()

Returns true if entity is to be chunk coded, false otherwise.

isGzipCompressback to summary
public boolean isGzipCompress()

Returns true if entity is to be GZIP compressed, false otherwise.

setBinaryback to summary
public EntityBuilder setBinary(final byte[] binary)

Sets entity content as a byte array. This method is mutually exclusive with:

setContentEncodingback to summary
public EntityBuilder setContentEncoding(final String contentEncoding)

Sets content encoding of the entity.

setContentTypeback to summary
public EntityBuilder setContentType(final ContentType contentType)

Sets ContentType of the entity.

setFileback to summary
public EntityBuilder setFile(final File file)

Sets entity content as a File. This method is mutually exclusive with:

setParametersback to summary
public EntityBuilder setParameters(final List<NameValuePair> parameters)

Sets entity content as a parameter list. This method is mutually exclusive with:

setParametersback to summary
public EntityBuilder setParameters(final NameValuePair... parameters)

Sets entity content as a parameter list. This method is mutually exclusive with:

setSerializableback to summary
public EntityBuilder setSerializable(final Serializable serializable)

Sets entity content as a Serializable. This method is mutually exclusive with:

setStreamback to summary
public EntityBuilder setStream(final InputStream stream)

Sets entity content as a InputStream. This method is mutually exclusive with:

setTextback to summary
public EntityBuilder setText(final String text)

Sets entity content as a string. This method is mutually exclusive with: