Package org.apache.juneau.http.entity
Class SerializedEntity
java.lang.Object
org.apache.juneau.http.entity.BasicHttpEntity
org.apache.juneau.http.entity.SerializedEntity
- All Implemented Interfaces:
HttpEntity
HttpEntity for serializing POJOs as the body of HTTP requests.
See Also:
-
Field Summary
Fields inherited from class org.apache.juneau.http.entity.BasicHttpEntity
EMPTY -
Constructor Summary
ConstructorsConstructorDescriptionConstructor.SerializedEntity(SerializedEntity copyFrom) Copy constructor.SerializedEntity(ContentType contentType, Object content, Serializer serializer, HttpPartSchema schema) Constructor. -
Method Summary
Modifier and TypeMethodDescriptioncopy()Creates a builder for this class initialized with the contents of this bean.copyWith(Serializer serializer, HttpPartSchema schema) Copies this bean and sets the serializer and schema on it.longbooleanSpecifies that the contents of this resource should be cached into an internal byte array so that it can be read multiple times.setCharset(Charset value) Specifies the charset to use when converting to and from stream-based resources.Sets the 'chunked' flag value totrue .setChunked(boolean value) Sets the 'chunked' flag value.setContent(Object value) Sets the content on this entity bean.setContent(Supplier<?> value) Sets the content on this entity bean from a supplier.setContentEncoding(String value) Sets the content encoding header on this entity bean.Sets the content encoding header on this entity bean.setContentLength(long value) Sets the content length on this entity bean.setContentType(String value) Sets the content type on this entity bean.setContentType(ContentType value) Sets the content type on this entity bean.setMaxLength(int value) Specifies the maximum number of bytes to read or write to and from stream-based resources.setSchema(HttpPartSchema value) Sets the schema on this entity bean.setSerializer(Serializer value) Sets the serializer on this entity bean.Specifies whether this bean should be unmodifiable.voidwriteTo(OutputStream os) Methods inherited from class org.apache.juneau.http.entity.BasicHttpEntity
asBytes, asSafeBytes, assertBytes, assertModifiable, assertString, asString, consumeContent, contentOrElse, getCharset, getContentEncoding, getMaxLength, isCached, isChunked, isStreaming, isSupplied, isUnmodifiable
-
Constructor Details
-
SerializedEntity
public SerializedEntity()Constructor. -
SerializedEntity
public SerializedEntity(ContentType contentType, Object content, Serializer serializer, HttpPartSchema schema) Constructor.- Parameters:
contentType- The entity content type.content- The entity content.serializer- The entity serializer.schema- The entity schema. Can benull .
-
SerializedEntity
Copy constructor.- Parameters:
copyFrom- The bean being copied.
-
-
Method Details
-
copy
Creates a builder for this class initialized with the contents of this bean.Allows you to create a modifiable copy of this bean.
- Overrides:
copyin classBasicHttpEntity- Returns:
- A new builder bean.
-
copyWith
Copies this bean and sets the serializer and schema on it.- Parameters:
serializer- The new serializer for the bean. Can benull .schema- The new schema for the bean. Can benull .- Returns:
- Either a new bean with the serializer set, or this bean if
both values are
null or the serializer and schema were already set.
-
getContent
- Specified by:
getContentin interfaceHttpEntity- Overrides:
getContentin classBasicHttpEntity
-
getContentLength
- Specified by:
getContentLengthin interfaceHttpEntity- Overrides:
getContentLengthin classBasicHttpEntity
-
getContentType
- Specified by:
getContentTypein interfaceHttpEntity- Overrides:
getContentTypein classBasicHttpEntity
-
isRepeatable
- Specified by:
isRepeatablein interfaceHttpEntity- Overrides:
isRepeatablein classBasicHttpEntity
-
setCached
Description copied from class:BasicHttpEntitySpecifies that the contents of this resource should be cached into an internal byte array so that it can be read multiple times.- Overrides:
setCachedin classBasicHttpEntity- Returns:
- This object.
- Throws:
IOException- If entity could not be read into memory.
-
setCharset
Description copied from class:BasicHttpEntitySpecifies the charset to use when converting to and from stream-based resources.- Overrides:
setCharsetin classBasicHttpEntity- Parameters:
value- The new value. Ifnull ,UTF-8 is assumed.- Returns:
- This object.
-
setChunked
Description copied from class:BasicHttpEntitySets the 'chunked' flag value totrue .Notes:
- If the
HttpEntity.getContentLength()method returns a negative value, the HttpClient code will always use chunked encoding.
- Overrides:
setChunkedin classBasicHttpEntity- Returns:
- This object.
- If the
-
setChunked
Description copied from class:BasicHttpEntitySets the 'chunked' flag value.Notes:
- If the
HttpEntity.getContentLength()method returns a negative value, the HttpClient code will always use chunked encoding.
- Overrides:
setChunkedin classBasicHttpEntity- Parameters:
value- The new value for this flag.- Returns:
- This object.
- If the
-
setContent
Description copied from class:BasicHttpEntitySets the content on this entity bean.- Overrides:
setContentin classBasicHttpEntity- Parameters:
value- The entity content, can benull .- Returns:
- This object.
-
setContent
Description copied from class:BasicHttpEntitySets the content on this entity bean from a supplier.Repeatable entities such as
StringEntityuse this to allow the entity content to be resolved at serialization time.- Overrides:
setContentin classBasicHttpEntity- Parameters:
value- The entity content, can benull .- Returns:
- This object.
-
setContentEncoding
Description copied from class:BasicHttpEntitySets the content encoding header on this entity bean.- Overrides:
setContentEncodingin classBasicHttpEntity- Parameters:
value- The newContent-Encoding header, ornull to unset.- Returns:
- This object.
-
setContentEncoding
Description copied from class:BasicHttpEntitySets the content encoding header on this entity bean.- Overrides:
setContentEncodingin classBasicHttpEntity- Parameters:
value- The newContent-Encoding header, ornull to unset.- Returns:
- This object.
-
setContentLength
Description copied from class:BasicHttpEntitySets the content length on this entity bean.- Overrides:
setContentLengthin classBasicHttpEntity- Parameters:
value- The newContent-Length header value, or-1 to unset.- Returns:
- This object.
-
setContentType
Description copied from class:BasicHttpEntitySets the content type on this entity bean.- Overrides:
setContentTypein classBasicHttpEntity- Parameters:
value- The newContent-Type header, ornull to unset.- Returns:
- This object.
-
setContentType
Description copied from class:BasicHttpEntitySets the content type on this entity bean.- Overrides:
setContentTypein classBasicHttpEntity- Parameters:
value- The newContent-Type header, ornull to unset.- Returns:
- This object.
-
setMaxLength
Description copied from class:BasicHttpEntitySpecifies the maximum number of bytes to read or write to and from stream-based resources.Implementation is not universal.
- Overrides:
setMaxLengthin classBasicHttpEntity- Parameters:
value- The new value. The default is-1 which means read everything.- Returns:
- This object.
-
setSchema
Sets the schema on this entity bean.Used to provide instructions to the serializer on how to serialize this object.
- Parameters:
value- The entity schema, can benull .- Returns:
- This object.
-
setSerializer
Sets the serializer on this entity bean.- Parameters:
value- The entity serializer, can benull .- Returns:
- This object.
-
setUnmodifiable
Description copied from class:BasicHttpEntitySpecifies whether this bean should be unmodifiable.When enabled, attempting to set any properties on this bean will cause an
UnsupportedOperationException.- Overrides:
setUnmodifiablein classBasicHttpEntity- Returns:
- This object.
-
writeTo
- Specified by:
writeToin interfaceHttpEntity- Overrides:
writeToin classBasicHttpEntity- Throws:
IOException
-