Class SerializedEntity
- All Implemented Interfaces:
HttpEntity
- Direct Known Subclasses:
SerializedEntity.Unmodifiable
See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classUnmodifiable point-in-time snapshot of the enclosingSerializedEntity. -
Field Summary
Fields inherited from class org.apache.juneau.http.classic.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.booleanCompares the shared base content of two entities.longinthashCode()booleansetSchema(HttpPartSchema value) Sets the schema on this entity bean.setSerializer(Serializer value) Sets the serializer on this entity bean.Returns an unmodifiable snapshot of this bean.voidwriteTo(OutputStream os) Methods inherited from class org.apache.juneau.http.classic.entity.BasicHttpEntity
asBytes, asSafeBytes, assertBytes, assertString, asString, consumeContent, contentOrElse, freeze, getCharset, getContentEncoding, getMaxLength, isCached, isChunked, isStreaming, isSupplied, isUnmodifiable, modify, self, setCached, setCharset, setChunked, setChunked, setContent, setContent, setContentEncoding, setContentEncoding, setContentLength, setContentType, setContentType, setMaxLength
-
Constructor Details
-
SerializedEntity
public SerializedEntity()Constructor. -
SerializedEntity
public SerializedEntity(ContentType contentType, Object content, Serializer serializer, HttpPartSchema schema) Constructor.- Parameters:
contentType- The entity content type. Can benull , in which case theContent-Type header falls back to the serializer's primary media type (if a serializer is set) or is omitted.content- The entity content. Can benull , in which case it's converted to an empty string if no serializer is set, or passed through to the serializer as-is otherwise.serializer- The entity serializer. Can benull , in which case the content is written via itstoString() value (or an empty string if the content is alsonull ) instead of being serialized.schema- The entity schema. Can benull (no schema is applied to the serializer).
-
SerializedEntity
Copy constructor.- Parameters:
copyFrom- The bean being copied. Must not benull .
-
-
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.
- Specified by:
copyin classBasicHttpEntity<SerializedEntity>- 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 (the serializer is left unchanged).schema- The new schema for the bean. Can benull (the schema is left unchanged).- 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<SerializedEntity>
-
getContentLength
- Specified by:
getContentLengthin interfaceHttpEntity- Overrides:
getContentLengthin classBasicHttpEntity<SerializedEntity>
-
getContentType
- Specified by:
getContentTypein interfaceHttpEntity- Overrides:
getContentTypein classBasicHttpEntity<SerializedEntity>
-
isRepeatable
- Specified by:
isRepeatablein interfaceHttpEntity- Overrides:
isRepeatablein classBasicHttpEntity<SerializedEntity>
-
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 (no schema is applied to the serializer).- Returns:
- This object.
-
setSerializer
Sets the serializer on this entity bean.- Parameters:
value- The entity serializer, can benull , in which case the content is written via itstoString() value instead of being serialized.- Returns:
- This object.
-
unmodifiable
Description copied from class:BasicHttpEntityReturns an unmodifiable snapshot of this bean.The returned instance is a point-in-time copy of the leaf's nested
Unmodifiabletype; any attempt to set a property on it throws anUnsupportedOperationException. This method is idempotent: if this bean is already unmodifiable it returns itself rather than taking another snapshot. The receiver is left unchanged (and still modifiable unless it was already unmodifiable).- Specified by:
unmodifiablein classBasicHttpEntity<SerializedEntity>- Returns:
- An unmodifiable snapshot of this bean, or this bean if it is already unmodifiable.
-
writeTo
- Specified by:
writeToin interfaceHttpEntity- Overrides:
writeToin classBasicHttpEntity<SerializedEntity>- Throws:
IOException
-
equals
Description copied from class:BasicHttpEntityCompares the shared base content of two entities.This base implementation compares only the fields declared on
BasicHttpEntityand deliberately accepts anyBasicHttpEntitysubtype so that concrete leaves can delegate to it viasuper.equals(...). It does not gate on the concrete leaf type; each concrete leaf overridesequalsto first apply aninstanceof <ThatLeaf>gate (so two unrelated leaves with equal base content are not equal) and then callssuper.equals(...)to compare the inherited content. Usinginstanceof <ThatLeaf>(rather thangetClass() ==) is what preserves the immutability invariant thatbean.equals(bean.unmodifiable())holds, since eachX.Unmodifiablesnapshot is a subclass of its leafX.- Overrides:
equalsin classBasicHttpEntity<SerializedEntity>
-
hashCode
- Overrides:
hashCodein classBasicHttpEntity<SerializedEntity>
-