Package org.apache.juneau.http.entity
Class StreamEntity
java.lang.Object
org.apache.juneau.http.entity.BasicHttpEntity
org.apache.juneau.http.entity.StreamEntity
- All Implemented Interfaces:
- HttpEntity
A streamed, non-repeatable entity that obtains its content from an 
InputStream.
 See Also:
- 
Field SummaryFields inherited from class org.apache.juneau.http.entity.BasicHttpEntityEMPTY
- 
Constructor SummaryConstructorsModifierConstructorDescriptionConstructor.protectedStreamEntity(StreamEntity copyFrom) Copy constructor.StreamEntity(ContentType contentType, InputStream content) Constructor.
- 
Method SummaryModifier 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.longbooleanbooleanSpecifies 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.Specifies whether this bean should be unmodifiable.voidwriteTo(OutputStream out) Writes bytes from theInputStreamthis entity was constructed with to anOutputStream.Methods inherited from class org.apache.juneau.http.entity.BasicHttpEntityasSafeBytes, assertBytes, assertModifiable, assertString, consumeContent, contentOrElse, getCharset, getContentEncoding, getContentType, getMaxLength, isCached, isChunked, isSupplied, isUnmodifiable
- 
Constructor Details- 
StreamEntitypublic StreamEntity()Constructor.
- 
StreamEntityConstructor.- Parameters:
- contentType- The entity content type.
- content- The entity contents.
 
- 
StreamEntityCopy constructor.- Parameters:
- copyFrom- The bean being copied.
 
 
- 
- 
Method Details- 
copyDescription 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. - Overrides:
- copyin class- BasicHttpEntity
- Returns:
- A new builder bean.
 
- 
asStringDescription 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 class- BasicHttpEntity
- Returns:
- The contents of this entity as a string.
- Throws:
- IOException- If a problem occurred while trying to read the content.
 
- 
asBytesDescription 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 class- BasicHttpEntity
- Returns:
- The contents of this entity as a byte array.
- Throws:
- IOException- If a problem occurred while trying to read the content.
 
- 
isRepeatable- Specified by:
- isRepeatablein interface- HttpEntity
- Overrides:
- isRepeatablein class- BasicHttpEntity
 
- 
getContentLength- Specified by:
- getContentLengthin interface- HttpEntity
- Overrides:
- getContentLengthin class- BasicHttpEntity
 
- 
getContent- Specified by:
- getContentin interface- HttpEntity
- Overrides:
- getContentin class- BasicHttpEntity
- Throws:
- IOException
 
- 
writeToWrites 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 interface- HttpEntity
- Overrides:
- writeToin class- BasicHttpEntity
- Throws:
- IOException
 
- 
isStreaming- Specified by:
- isStreamingin interface- HttpEntity
- Overrides:
- isStreamingin class- BasicHttpEntity
 
- 
setCachedDescription 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 class- BasicHttpEntity
- Returns:
- This object.
- Throws:
- IOException- If entity could not be read into memory.
 
- 
setCharsetDescription copied from class:BasicHttpEntitySpecifies the charset to use when converting to and from stream-based resources.- Overrides:
- setCharsetin class- BasicHttpEntity
- Parameters:
- value- The new value. If- null ,- UTF-8 is assumed.
- Returns:
- This object.
 
- 
setChunkedDescription 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 class- BasicHttpEntity
- Returns:
- This object.
 
- If the 
- 
setChunkedDescription 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 class- BasicHttpEntity
- Parameters:
- value- The new value for this flag.
- Returns:
- This object.
 
- If the 
- 
setContentDescription copied from class:BasicHttpEntitySets the content on this entity bean.- Overrides:
- setContentin class- BasicHttpEntity
- Parameters:
- value- The entity content, can be- null .
- Returns:
- This object.
 
- 
setContentDescription 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 class- BasicHttpEntity
- Parameters:
- value- The entity content, can be- null .
- Returns:
- This object.
 
- 
setContentEncodingDescription copied from class:BasicHttpEntitySets the content encoding header on this entity bean.- Overrides:
- setContentEncodingin class- BasicHttpEntity
- Parameters:
- value- The new- Content-Encoding header, or- null to unset.
- Returns:
- This object.
 
- 
setContentEncodingDescription copied from class:BasicHttpEntitySets the content encoding header on this entity bean.- Overrides:
- setContentEncodingin class- BasicHttpEntity
- Parameters:
- value- The new- Content-Encoding header, or- null to unset.
- Returns:
- This object.
 
- 
setContentLengthDescription copied from class:BasicHttpEntitySets the content length on this entity bean.- Overrides:
- setContentLengthin class- BasicHttpEntity
- Parameters:
- value- The new- Content-Length header value, or- -1 to unset.
- Returns:
- This object.
 
- 
setContentTypeDescription copied from class:BasicHttpEntitySets the content type on this entity bean.- Overrides:
- setContentTypein class- BasicHttpEntity
- Parameters:
- value- The new- Content-Type header, or- null to unset.
- Returns:
- This object.
 
- 
setContentTypeDescription copied from class:BasicHttpEntitySets the content type on this entity bean.- Overrides:
- setContentTypein class- BasicHttpEntity
- Parameters:
- value- The new- Content-Type header, or- null to unset.
- Returns:
- This object.
 
- 
setMaxLengthDescription 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 class- BasicHttpEntity
- Parameters:
- value- The new value. The default is- -1 which means read everything.
- Returns:
- This object.
 
- 
setUnmodifiableDescription 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 class- BasicHttpEntity
- Returns:
- This object.
 
 
-