Package org.apache.juneau.http.resource
Class FileResource
java.lang.Object
org.apache.juneau.http.resource.BasicResource
org.apache.juneau.http.resource.FileResource
- All Implemented Interfaces:
HttpEntity
,HttpResource
-
Constructor Summary
ModifierConstructorDescriptionConstructor.FileResource
(ContentType contentType, File contents) Constructor.protected
FileResource
(FileResource copyFrom) Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptioncopy()
Creates a builder for this class initialized with the contents of this bean.Specifies that the contents of this resource should be cached into an internal byte array so that it can be read multiple times.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.setHeaders
(HeaderList value) Sets the specified headers in this builder.Specifies whether this bean should be unmodifiable.Methods inherited from class org.apache.juneau.http.resource.BasicResource
addHeader, addHeaders, asBytes, assertBytes, assertModifiable, assertString, asString, consumeContent, copyFrom, getContent, getContentEncoding, getContentLength, getContentType, getEntity, getHeaders, isChunked, isRepeatable, isStreaming, isUnmodifiable, setHeader, setHeaders, writeTo
-
Constructor Details
-
FileResource
public FileResource()Constructor. -
FileResource
Constructor.- Parameters:
contentType
- The entity content type.contents
- The entity contents.
-
FileResource
Copy constructor.- Parameters:
copyFrom
- The bean being copied.
-
-
Method Details
-
copy
Description copied from class:BasicResource
Creates a builder for this class initialized with the contents of this bean.Allows you to create a modifiable copy of this bean.
- Overrides:
copy
in classBasicResource
- Returns:
- A new builder bean.
-
setCached
Description copied from class:BasicResource
Specifies that the contents of this resource should be cached into an internal byte array so that it can be read multiple times.- Overrides:
setCached
in classBasicResource
- Returns:
- This object.
- Throws:
IOException
- If entity could not be read into memory.
-
setChunked
Description copied from class:BasicResource
Sets the 'chunked' flag value totrue .Notes:
- If the
HttpEntity.getContentLength()
method returns a negative value, the HttpClient code will always use chunked encoding.
- Overrides:
setChunked
in classBasicResource
- Returns:
- This object.
- If the
-
setChunked
Description copied from class:BasicResource
Sets the 'chunked' flag value.Notes:
- If the
HttpEntity.getContentLength()
method returns a negative value, the HttpClient code will always use chunked encoding.
- Overrides:
setChunked
in classBasicResource
- Parameters:
value
- The new value for this flag.- Returns:
- This object.
- If the
-
setContent
Description copied from class:BasicResource
Sets the content on this entity bean.- Overrides:
setContent
in classBasicResource
- Parameters:
value
- The entity content, can benull .- Returns:
- This object.
-
setContent
Description copied from class:BasicResource
Sets the content on this entity bean from a supplier.Repeatable entities such as
StringEntity
use this to allow the entity content to be resolved at serialization time.- Overrides:
setContent
in classBasicResource
- Parameters:
value
- The entity content, can benull .- Returns:
- This object.
-
setContentEncoding
Description copied from class:BasicResource
Sets the content encoding header on this entity bean.- Overrides:
setContentEncoding
in classBasicResource
- Parameters:
value
- The newContent-Encoding header, ornull to unset.- Returns:
- This object.
-
setContentEncoding
Description copied from class:BasicResource
Sets the content encoding header on this entity bean.- Overrides:
setContentEncoding
in classBasicResource
- Parameters:
value
- The newContent-Encoding header, ornull to unset.- Returns:
- This object.
-
setContentLength
Description copied from class:BasicResource
Sets the content length on this entity bean.- Overrides:
setContentLength
in classBasicResource
- Parameters:
value
- The newContent-Length header value, or-1 to unset.- Returns:
- This object.
-
setContentType
Description copied from class:BasicResource
Sets the content type on this entity bean.- Overrides:
setContentType
in classBasicResource
- Parameters:
value
- The newContent-Type header, ornull to unset.- Returns:
- This object.
-
setContentType
Description copied from class:BasicResource
Sets the content type on this entity bean.- Overrides:
setContentType
in classBasicResource
- Parameters:
value
- The newContent-Type header, ornull to unset.- Returns:
- This object.
-
setHeaders
Description copied from class:BasicResource
Sets the specified headers in this builder.- Overrides:
setHeaders
in classBasicResource
- Parameters:
value
- The new value.- Returns:
- This object.
-
setUnmodifiable
Description copied from class:BasicResource
Specifies whether this bean should be unmodifiable.When enabled, attempting to set any properties on this bean will cause an
UnsupportedOperationException
.- Overrides:
setUnmodifiable
in classBasicResource
- Returns:
- This object.
-