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
-
-
Field Summary
Fields Modifier and Type Field Description private byte[]
binary
private boolean
chunked
private java.lang.String
contentEncoding
private org.apache.http.entity.ContentType
contentType
private java.io.File
file
private boolean
gzipCompress
private java.util.List<org.apache.http.NameValuePair>
parameters
private java.io.Serializable
serializable
private java.io.InputStream
stream
private java.lang.String
text
-
Constructor Summary
Constructors Constructor Description EntityBuilder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apache.http.HttpEntity
build()
Creates new instance ofHttpEntity
based on the current state.EntityBuilder
chunked()
Makes entity chunk coded.private void
clearContent()
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.private org.apache.http.entity.ContentType
getContentOrDefault(org.apache.http.entity.ContentType def)
org.apache.http.entity.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<org.apache.http.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(org.apache.http.entity.ContentType contentType)
SetsContentType
of the entity.EntityBuilder
setFile(java.io.File file)
Sets entity content as aFile
.EntityBuilder
setParameters(java.util.List<org.apache.http.NameValuePair> parameters)
Sets entity content as a parameter list.EntityBuilder
setParameters(org.apache.http.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.
-
-
-
Field Detail
-
text
private java.lang.String text
-
binary
private byte[] binary
-
stream
private java.io.InputStream stream
-
parameters
private java.util.List<org.apache.http.NameValuePair> parameters
-
serializable
private java.io.Serializable serializable
-
file
private java.io.File file
-
contentType
private org.apache.http.entity.ContentType contentType
-
contentEncoding
private java.lang.String contentEncoding
-
chunked
private boolean chunked
-
gzipCompress
private boolean gzipCompress
-
-
Method Detail
-
create
public static EntityBuilder create()
-
clearContent
private void clearContent()
-
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<org.apache.http.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<org.apache.http.NameValuePair> parameters)
Sets entity content as a parameter list. This method is mutually exclusive with:
-
setParameters
public EntityBuilder setParameters(org.apache.http.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 org.apache.http.entity.ContentType getContentType()
ReturnsContentType
of the entity, if set.
-
setContentType
public EntityBuilder setContentType(org.apache.http.entity.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.
-
getContentOrDefault
private org.apache.http.entity.ContentType getContentOrDefault(org.apache.http.entity.ContentType def)
-
build
public org.apache.http.HttpEntity build()
Creates new instance ofHttpEntity
based on the current state.
-
-