Package org.apache.http.client.entity
Class EntityBuilder
- java.lang.Object
-
- org.apache.http.client.entity.EntityBuilder
-
public class EntityBuilder extends java.lang.ObjectBuilder 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.java.lang.StringgetContentEncoding()Returns content encoding of the entity, if set.ContentTypegetContentType()ReturnsContentTypeof the entity, if set.java.io.FilegetFile()Returns entity content as aFileif 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.SerializablegetSerializable()Returns entity content as aSerializableif set usingsetSerializable(java.io.Serializable)method.java.io.InputStreamgetStream()Returns entity content as aInputStreamif set usingsetStream(java.io.InputStream)method.java.lang.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(java.lang.String contentEncoding)Sets content encoding of the entity.EntityBuildersetContentType(ContentType contentType)SetsContentTypeof the entity.EntityBuildersetFile(java.io.File file)Sets entity content as aFile.EntityBuildersetParameters(java.util.List<NameValuePair> parameters)Sets entity content as a parameter list.EntityBuildersetParameters(NameValuePair... parameters)Sets entity content as a parameter list.EntityBuildersetSerializable(java.io.Serializable serializable)Sets entity content as aSerializable.EntityBuildersetStream(java.io.InputStream stream)Sets entity content as aInputStream.EntityBuildersetText(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 aInputStreamif 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 aSerializableif 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 aFileif 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()
ReturnsContentTypeof the entity, if set.
-
setContentType
public EntityBuilder setContentType(ContentType contentType)
SetsContentTypeof 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()
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.
-
-