@NotThreadSafe public class EntityBuilder extends java.lang.Object
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:
Constructor and Description |
---|
EntityBuilder() |
Modifier and Type | Method and Description |
---|---|
HttpEntity |
build()
Creates new instance of
HttpEntity based on the current state. |
EntityBuilder |
chunked()
Makes entity chunk coded.
|
static EntityBuilder |
create() |
byte[] |
getBinary()
Returns entity content as a byte array if set using
setBinary(byte[]) method. |
java.lang.String |
getContentEncoding()
Returns content encoding of the entity, if set.
|
ContentType |
getContentType()
Returns
ContentType of the entity, if set. |
java.io.File |
getFile()
Returns entity content as a
File if set using
setFile(java.io.File) method. |
java.util.List<NameValuePair> |
getParameters()
Returns entity content as a parameter list if set using
setParameters(java.util.List) or
setParameters(org.apache.http.NameValuePair...) methods. |
java.io.Serializable |
getSerializable()
Returns entity content as a
Serializable if set using
setSerializable(java.io.Serializable) method. |
java.io.InputStream |
getStream()
Returns entity content as a
InputStream if set using
setStream(java.io.InputStream) method. |
java.lang.String |
getText()
Returns entity content as a string if set using
setText(String) method. |
EntityBuilder |
gzipCompress()
Makes entity GZIP compressed.
|
boolean |
isChunked()
Returns
true if entity is to be chunk coded, false otherwise. |
boolean |
isGzipCompress()
Returns
true if entity is to be GZIP compressed, false otherwise. |
EntityBuilder |
setBinary(byte[] binary)
Sets entity content as a byte array.
|
EntityBuilder |
setContentEncoding(java.lang.String contentEncoding)
Sets content encoding of the entity.
|
EntityBuilder |
setContentType(ContentType contentType)
Sets
ContentType of the entity. |
EntityBuilder |
setFile(java.io.File file)
Sets entity content as a
File . |
EntityBuilder |
setParameters(java.util.List<NameValuePair> parameters)
Sets entity content as a parameter list.
|
EntityBuilder |
setParameters(NameValuePair... parameters)
Sets entity content as a parameter list.
|
EntityBuilder |
setSerializable(java.io.Serializable serializable)
Sets entity content as a
Serializable . |
EntityBuilder |
setStream(java.io.InputStream stream)
Sets entity content as a
InputStream . |
EntityBuilder |
setText(java.lang.String text)
Sets entity content as a string.
|
public static EntityBuilder create()
public java.lang.String getText()
setText(String)
method.public EntityBuilder setText(java.lang.String text)
setBinary(byte[])
,
setStream(java.io.InputStream)
,
setSerializable(java.io.Serializable)
,
setParameters(java.util.List)
,
setParameters(org.apache.http.NameValuePair...)
setFile(java.io.File)
methods.public byte[] getBinary()
setBinary(byte[])
method.public EntityBuilder setBinary(byte[] binary)
setText(String)
,
setStream(java.io.InputStream)
,
setSerializable(java.io.Serializable)
,
setParameters(java.util.List)
,
setParameters(org.apache.http.NameValuePair...)
setFile(java.io.File)
methods.public java.io.InputStream getStream()
InputStream
if set using
setStream(java.io.InputStream)
method.public EntityBuilder setStream(java.io.InputStream stream)
InputStream
. This method is mutually exclusive with
setText(String)
,
setBinary(byte[])
,
setSerializable(java.io.Serializable)
,
setParameters(java.util.List)
,
setParameters(org.apache.http.NameValuePair...)
setFile(java.io.File)
methods.public java.util.List<NameValuePair> getParameters()
setParameters(java.util.List)
or
setParameters(org.apache.http.NameValuePair...)
methods.public EntityBuilder setParameters(java.util.List<NameValuePair> parameters)
setText(String)
,
setBinary(byte[])
,
setStream(java.io.InputStream)
,
setSerializable(java.io.Serializable)
,
setFile(java.io.File)
methods.public EntityBuilder setParameters(NameValuePair... parameters)
setText(String)
,
setBinary(byte[])
,
setStream(java.io.InputStream)
,
setSerializable(java.io.Serializable)
,
setFile(java.io.File)
methods.public java.io.Serializable getSerializable()
Serializable
if set using
setSerializable(java.io.Serializable)
method.public EntityBuilder setSerializable(java.io.Serializable serializable)
Serializable
. This method is mutually exclusive with
setText(String)
,
setBinary(byte[])
,
setStream(java.io.InputStream)
,
setParameters(java.util.List)
,
setParameters(org.apache.http.NameValuePair...)
setFile(java.io.File)
methods.public java.io.File getFile()
File
if set using
setFile(java.io.File)
method.public EntityBuilder setFile(java.io.File file)
File
. This method is mutually exclusive with
setText(String)
,
setBinary(byte[])
,
setStream(java.io.InputStream)
,
setParameters(java.util.List)
,
setParameters(org.apache.http.NameValuePair...)
setSerializable(java.io.Serializable)
methods.public ContentType getContentType()
ContentType
of the entity, if set.public EntityBuilder setContentType(ContentType contentType)
ContentType
of the entity.public java.lang.String getContentEncoding()
public EntityBuilder setContentEncoding(java.lang.String contentEncoding)
public boolean isChunked()
true
if entity is to be chunk coded, false
otherwise.public EntityBuilder chunked()
public boolean isGzipCompress()
true
if entity is to be GZIP compressed, false
otherwise.public EntityBuilder gzipCompress()
public HttpEntity build()
HttpEntity
based on the current state.