public class EntityBuilder extends Object
HttpEntity 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:
| Modifier and Type | Method and Description | 
|---|---|
| HttpEntity | build()Builds a new instance of  HttpEntitybased on the current state. | 
| EntityBuilder | chunked()Sets entities to be chunked. | 
| static EntityBuilder | create() | 
| byte[] | getBinary()Gets entity content as a byte array if set using
  setBinary(byte[]). | 
| String | getContentEncoding()Gets the content encoding of the entity, may be null. | 
| ContentType | getContentType()Gets the  ContentTypeof the entity, may be null. | 
| File | getFile()Gets the entity content as a  Fileif set usingsetFile(java.io.File). | 
| List<NameValuePair> | getParameters()Gets entity content as a parameter list if set using
  setParameters(java.util.List)orsetParameters(NameValuePair...). | 
| Serializable | getSerializable()Gets entity content as a  Serializableif set usingsetSerializable(java.io.Serializable)method. | 
| InputStream | getStream()Gets entity content as an  InputStreamif set usingsetStream(java.io.InputStream)method. | 
| String | getText()Gets the entity content as a string if set using  setText(String). | 
| EntityBuilder | gzipCompressed()Sets entities to be GZIP compressed. | 
| boolean | isChunked()Tests if the entity is to be chunk coded ( true), or not (false). | 
| boolean | isGzipCompressed()Tests if entities are to be GZIP compressed ( true), or not (false). | 
| EntityBuilder | setBinary(byte[] binary)Sets entity content as a byte array. | 
| EntityBuilder | setContentEncoding(String contentEncoding)Sets the content encoding of the entity. | 
| EntityBuilder | setContentType(ContentType contentType)Sets the  ContentTypeof the entity. | 
| EntityBuilder | setFile(File file)Sets entity content as a  File. | 
| EntityBuilder | setParameters(List<NameValuePair> parameters)Sets entity content as a parameter list. | 
| EntityBuilder | setParameters(NameValuePair... parameters)Sets entity content as a parameter list. | 
| EntityBuilder | setSerializable(Serializable serializable)Sets entity content as a  Serializable. | 
| EntityBuilder | setStream(InputStream stream)Sets entity content as an  InputStream. | 
| EntityBuilder | setText(String text)Sets entity content as a string. | 
public static EntityBuilder create()
public String getText()
setText(String).public EntityBuilder setText(String text)
setBinary(byte[]),
 setStream(java.io.InputStream),
 setSerializable(java.io.Serializable),
 setParameters(java.util.List),
 setParameters(NameValuePair...)
 setFile(java.io.File) methods.text - entity content as a string.public byte[] getBinary()
setBinary(byte[]).public EntityBuilder setBinary(byte[] binary)
setText(String),
 setStream(java.io.InputStream),
 setSerializable(java.io.Serializable),
 setParameters(java.util.List),
 setParameters(NameValuePair...)
 setFile(java.io.File).binary - The new entity content as a byte array.public InputStream getStream()
InputStream if set using
 setStream(java.io.InputStream) method.InputStreampublic EntityBuilder setStream(InputStream stream)
InputStream. This method is mutually exclusive with
 setText(String),
 setBinary(byte[]),
 setSerializable(java.io.Serializable),
 setParameters(java.util.List),
 setParameters(NameValuePair...)
 setFile(java.io.File).stream - The new entity content as an InputStream.public List<NameValuePair> getParameters()
setParameters(java.util.List) or
 setParameters(NameValuePair...).public EntityBuilder setParameters(List<NameValuePair> parameters)
setText(String),
 setBinary(byte[]),
 setStream(java.io.InputStream),
 setSerializable(java.io.Serializable),
 setFile(java.io.File).parameters - entity content as a parameter list.public EntityBuilder setParameters(NameValuePair... parameters)
setText(String),
 setBinary(byte[]),
 setStream(java.io.InputStream),
 setSerializable(java.io.Serializable),
 setFile(java.io.File).parameters - entity content as a parameter list.public Serializable getSerializable()
Serializable if set using
 setSerializable(java.io.Serializable) method.Serializable.public EntityBuilder setSerializable(Serializable serializable)
Serializable. This method is mutually exclusive with
 setText(String),
 setBinary(byte[]),
 setStream(java.io.InputStream),
 setParameters(java.util.List),
 setParameters(NameValuePair...)
 setFile(java.io.File).serializable - entity content as a Serializable.public File getFile()
File if set using
 setFile(java.io.File).File.public EntityBuilder setFile(File file)
File. This method is mutually exclusive with
 setText(String),
 setBinary(byte[]),
 setStream(java.io.InputStream),
 setParameters(java.util.List),
 setParameters(NameValuePair...)
 setSerializable(java.io.Serializable).file - entity content as a File.public ContentType getContentType()
ContentType of the entity, may be null.ContentType of the entity, may be null.public EntityBuilder setContentType(ContentType contentType)
ContentType of the entity.contentType - the ContentType of the entity, may be null.public String getContentEncoding()
public EntityBuilder setContentEncoding(String contentEncoding)
contentEncoding - the content encoding of the entity, may be null.public boolean isChunked()
true), or not (false).true if entity is to be chunk coded, false otherwise.public EntityBuilder chunked()
public boolean isGzipCompressed()
true), or not (false).true if entity is to be GZIP compressed, false otherwise.public EntityBuilder gzipCompressed()
public HttpEntity build()
HttpEntity based on the current state.Copyright © 1999–2021 The Apache Software Foundation. All rights reserved.