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
-
-
Field Summary
Fields Modifier and Type Field Description private byte[]binaryprivate booleanchunkedprivate java.lang.StringcontentEncodingprivate org.apache.http.entity.ContentTypecontentTypeprivate java.io.Filefileprivate booleangzipCompressprivate java.util.List<org.apache.http.NameValuePair>parametersprivate java.io.Serializableserializableprivate java.io.InputStreamstreamprivate java.lang.Stringtext
-
Constructor Summary
Constructors Constructor Description EntityBuilder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apache.http.HttpEntitybuild()Creates new instance ofHttpEntitybased on the current state.EntityBuilderchunked()Makes entity chunk coded.private voidclearContent()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.private org.apache.http.entity.ContentTypegetContentOrDefault(org.apache.http.entity.ContentType def)org.apache.http.entity.ContentTypegetContentType()ReturnsContentTypeof the entity, if set.java.io.FilegetFile()Returns entity content as aFileif 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.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(org.apache.http.entity.ContentType contentType)SetsContentTypeof the entity.EntityBuildersetFile(java.io.File file)Sets entity content as aFile.EntityBuildersetParameters(java.util.List<org.apache.http.NameValuePair> parameters)Sets entity content as a parameter list.EntityBuildersetParameters(org.apache.http.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.
-
-
-
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 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<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 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 org.apache.http.entity.ContentType getContentType()
ReturnsContentTypeof the entity, if set.
-
setContentType
public EntityBuilder setContentType(org.apache.http.entity.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.
-
getContentOrDefault
private org.apache.http.entity.ContentType getContentOrDefault(org.apache.http.entity.ContentType def)
-
build
public org.apache.http.HttpEntity build()
Creates new instance ofHttpEntitybased on the current state.
-
-