Class ReaderEntity
- All Implemented Interfaces:
HttpEntity
- Direct Known Subclasses:
ReaderEntity.Unmodifiable
Reader.
See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classUnmodifiable point-in-time snapshot of the enclosingReaderEntity. -
Field Summary
Fields inherited from class org.apache.juneau.http.classic.entity.BasicHttpEntity
EMPTY -
Constructor Summary
ConstructorsModifierConstructorDescriptionConstructor.protectedReaderEntity(ReaderEntity copyFrom) Copy constructor.ReaderEntity(ContentType contentType, Reader content) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]asBytes()Converts the contents of this entity as a byte array.asString()Converts the contents of this entity as a string.copy()Creates a builder for this class initialized with the contents of this bean.booleanCompares the shared base content of two entities.longinthashCode()booleanbooleanReturns an unmodifiable snapshot of this bean.voidwriteTo(OutputStream out) Writes bytes from theInputStreamthis entity was constructed with to anOutputStream.Methods inherited from class org.apache.juneau.http.classic.entity.BasicHttpEntity
asSafeBytes, assertBytes, assertString, consumeContent, contentOrElse, freeze, getCharset, getContentEncoding, getContentType, getMaxLength, isCached, isChunked, isSupplied, isUnmodifiable, modify, self, setCached, setCharset, setChunked, setChunked, setContent, setContent, setContentEncoding, setContentEncoding, setContentLength, setContentType, setContentType, setMaxLength
-
Constructor Details
-
ReaderEntity
public ReaderEntity()Constructor. -
ReaderEntity
Constructor.- Parameters:
contentType- The entity content type. Can benull to omit an explicitContent-Type header.content- The entity contents. Can benull , in which case aNullPointerExceptionis thrown when the entity's content is read.
-
ReaderEntity
Copy constructor.- Parameters:
copyFrom- The bean being copied. Must not benull .
-
-
Method Details
-
asBytes
Description copied from class:BasicHttpEntityConverts the contents of this entity as a byte array.Note that this may exhaust the content on non-repeatable, non-cached entities.
- Overrides:
asBytesin classBasicHttpEntity<ReaderEntity>- Returns:
- The contents of this entity as a byte array.
- Throws:
IOException- If a problem occurred while trying to read the content.
-
asString
Description copied from class:BasicHttpEntityConverts the contents of this entity as a string.Note that this may exhaust the content on non-repeatable, non-cached entities.
- Overrides:
asStringin classBasicHttpEntity<ReaderEntity>- Returns:
- The contents of this entity as a string.
- Throws:
IOException- If a problem occurred while trying to read the content.
-
copy
Description copied from class:BasicHttpEntityCreates 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<ReaderEntity>- Returns:
- A new builder bean.
-
getContent
- Specified by:
getContentin interfaceHttpEntity- Overrides:
getContentin classBasicHttpEntity<ReaderEntity>- Throws:
IOException
-
getContentLength
- Specified by:
getContentLengthin interfaceHttpEntity- Overrides:
getContentLengthin classBasicHttpEntity<ReaderEntity>
-
isRepeatable
- Specified by:
isRepeatablein interfaceHttpEntity- Overrides:
isRepeatablein classBasicHttpEntity<ReaderEntity>
-
isStreaming
- Specified by:
isStreamingin interfaceHttpEntity- Overrides:
isStreamingin classBasicHttpEntity<ReaderEntity>
-
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<ReaderEntity>- Returns:
- An unmodifiable snapshot of this bean, or this bean if it is already unmodifiable.
-
writeTo
Writes bytes from theInputStreamthis entity was constructed with to anOutputStream. The content length determines how many bytes are written. If the length is unknown (-1), the stream will be completely consumed (to the end of the stream).- Specified by:
writeToin interfaceHttpEntity- Overrides:
writeToin classBasicHttpEntity<ReaderEntity>- 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<ReaderEntity>
-
hashCode
- Overrides:
hashCodein classBasicHttpEntity<ReaderEntity>
-