Package org.apache.http.client.entity
Class EntityBuilder
- java.lang.Object
-
- org.apache.http.client.entity.EntityBuilder
-
public class EntityBuilder extends Object
Builder forHttpEntityinstances.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 HttpEntitybuild()Creates new instance ofHttpEntitybased on the current state.EntityBuilderchunked()Makes entity chunk coded.static EntityBuildercreate()byte[]getBinary()Returns entity content as a byte array if set usingsetBinary(byte[])method.StringgetContentEncoding()Returns content encoding of the entity, if set.ContentTypegetContentType()ReturnsContentTypeof the entity, if set.FilegetFile()Returns entity content as aFileif set usingsetFile(java.io.File)method.List<NameValuePair>getParameters()Returns entity content as a parameter list if set usingsetParameters(java.util.List)orsetParameters(org.apache.http.NameValuePair...)methods.SerializablegetSerializable()Returns entity content as aSerializableif set usingsetSerializable(java.io.Serializable)method.InputStreamgetStream()Returns entity content as aInputStreamif set usingsetStream(java.io.InputStream)method.StringgetText()Returns entity content as a string if set usingsetText(String)method.EntityBuildergzipCompress()Makes entity GZIP compressed.booleanisChunked()Returnstrueif entity is to be chunk coded,falseotherwise.booleanisGzipCompress()Returnstrueif entity is to be GZIP compressed,falseotherwise.EntityBuildersetBinary(byte[] binary)Sets entity content as a byte array.EntityBuildersetContentEncoding(String contentEncoding)Sets content encoding of the entity.EntityBuildersetContentType(ContentType contentType)SetsContentTypeof the entity.EntityBuildersetFile(File file)Sets entity content as aFile.EntityBuildersetParameters(List<NameValuePair> parameters)Sets entity content as a parameter list.EntityBuildersetParameters(NameValuePair... parameters)Sets entity content as a parameter list.EntityBuildersetSerializable(Serializable serializable)Sets entity content as aSerializable.EntityBuildersetStream(InputStream stream)Sets entity content as aInputStream.EntityBuildersetText(String text)Sets entity content as a string.
-
-
-
Method Detail
-
create
public static EntityBuilder create()
-
getText
public String getText()
Returns entity content as a string if set usingsetText(String)method.
-
setText
public EntityBuilder setText(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 InputStream getStream()
Returns entity content as aInputStreamif set usingsetStream(java.io.InputStream)method.
-
setStream
public EntityBuilder setStream(InputStream stream)
Sets entity content as aInputStream. This method is mutually exclusive with:
-
getParameters
public 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(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 Serializable getSerializable()
Returns entity content as aSerializableif set usingsetSerializable(java.io.Serializable)method.
-
setSerializable
public EntityBuilder setSerializable(Serializable serializable)
Sets entity content as aSerializable. This method is mutually exclusive with:
-
getFile
public File getFile()
Returns entity content as aFileif set usingsetFile(java.io.File)method.
-
setFile
public EntityBuilder setFile(File file)
Sets entity content as aFile. This method is mutually exclusive with:
-
getContentType
public ContentType getContentType()
ReturnsContentTypeof the entity, if set.
-
setContentType
public EntityBuilder setContentType(ContentType contentType)
SetsContentTypeof the entity.
-
getContentEncoding
public String getContentEncoding()
Returns content encoding of the entity, if set.
-
setContentEncoding
public EntityBuilder setContentEncoding(String contentEncoding)
Sets content encoding of the entity.
-
isChunked
public boolean isChunked()
Returnstrueif entity is to be chunk coded,falseotherwise.
-
chunked
public EntityBuilder chunked()
Makes entity chunk coded.
-
isGzipCompress
public boolean isGzipCompress()
Returnstrueif entity is to be GZIP compressed,falseotherwise.
-
gzipCompress
public EntityBuilder gzipCompress()
Makes entity GZIP compressed.
-
build
public HttpEntity build()
Creates new instance ofHttpEntitybased on the current state.
-
-