Package org.apache.http.client.entity
Class EntityBuilder
- java.lang.Object
-
- org.apache.http.client.entity.EntityBuilder
-
public class EntityBuilder extends java.lang.Object
Builder forHttpEntity
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
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description HttpEntity
build()
Creates new instance ofHttpEntity
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 usingsetBinary(byte[])
method.java.lang.String
getContentEncoding()
Returns content encoding of the entity, if set.ContentType
getContentType()
ReturnsContentType
of the entity, if set.java.io.File
getFile()
Returns entity content as aFile
if set usingsetFile(java.io.File)
method.java.util.List<NameValuePair>
getParameters()
Returns entity content as a parameter list if set usingsetParameters(java.util.List)
orsetParameters(org.apache.http.NameValuePair...)
methods.java.io.Serializable
getSerializable()
Returns entity content as aSerializable
if set usingsetSerializable(java.io.Serializable)
method.java.io.InputStream
getStream()
Returns entity content as aInputStream
if set usingsetStream(java.io.InputStream)
method.java.lang.String
getText()
Returns entity content as a string if set usingsetText(String)
method.EntityBuilder
gzipCompress()
Makes entity GZIP compressed.boolean
isChunked()
Returnstrue
if entity is to be chunk coded,false
otherwise.boolean
isGzipCompress()
Returnstrue
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)
SetsContentType
of the entity.EntityBuilder
setFile(java.io.File file)
Sets entity content as aFile
.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 aSerializable
.EntityBuilder
setStream(java.io.InputStream stream)
Sets entity content as aInputStream
.EntityBuilder
setText(java.lang.String text)
Sets entity content as a string.
-
-
-
Method Detail
-
create
public static EntityBuilder create()
-
getText
public java.lang.String getText()
Returns entity content as a string if set usingsetText(String)
method.
-
setText
public EntityBuilder setText(java.lang.String text)
Sets entity content as a string. This method is mutually exclusive with:
-
getBinary
public byte[] getBinary()
Returns entity content as a byte array if set usingsetBinary(byte[])
method.
-
setBinary
public EntityBuilder setBinary(byte[] binary)
Sets entity content as a byte array. This method is mutually exclusive with:
-
getStream
public java.io.InputStream getStream()
Returns entity content as aInputStream
if set usingsetStream(java.io.InputStream)
method.
-
setStream
public EntityBuilder setStream(java.io.InputStream stream)
Sets entity content as aInputStream
. This method is mutually exclusive with:
-
getParameters
public java.util.List<NameValuePair> getParameters()
Returns entity content as a parameter list if set usingsetParameters(java.util.List)
orsetParameters(org.apache.http.NameValuePair...)
methods.
-
setParameters
public EntityBuilder setParameters(java.util.List<NameValuePair> parameters)
Sets entity content as a parameter list. This method is mutually exclusive with:
-
setParameters
public EntityBuilder setParameters(NameValuePair... parameters)
Sets entity content as a parameter list. This method is mutually exclusive with:
-
getSerializable
public java.io.Serializable getSerializable()
Returns entity content as aSerializable
if set usingsetSerializable(java.io.Serializable)
method.
-
setSerializable
public EntityBuilder setSerializable(java.io.Serializable serializable)
Sets entity content as aSerializable
. This method is mutually exclusive with:
-
getFile
public java.io.File getFile()
Returns entity content as aFile
if set usingsetFile(java.io.File)
method.
-
setFile
public EntityBuilder setFile(java.io.File file)
Sets entity content as aFile
. This method is mutually exclusive with:
-
getContentType
public ContentType getContentType()
ReturnsContentType
of the entity, if set.
-
setContentType
public EntityBuilder setContentType(ContentType contentType)
SetsContentType
of the entity.
-
getContentEncoding
public java.lang.String getContentEncoding()
Returns content encoding of the entity, if set.
-
setContentEncoding
public EntityBuilder setContentEncoding(java.lang.String contentEncoding)
Sets content encoding of the entity.
-
isChunked
public boolean isChunked()
Returnstrue
if entity is to be chunk coded,false
otherwise.
-
chunked
public EntityBuilder chunked()
Makes entity chunk coded.
-
isGzipCompress
public boolean isGzipCompress()
Returnstrue
if entity is to be GZIP compressed,false
otherwise.
-
gzipCompress
public EntityBuilder gzipCompress()
Makes entity GZIP compressed.
-
build
public HttpEntity build()
Creates new instance ofHttpEntity
based on the current state.
-
-