Package org.apache.juneau.http.resource
Class StringResource
java.lang.Object
org.apache.juneau.http.resource.BasicResource
org.apache.juneau.http.resource.StringResource
- All Implemented Interfaces:
HttpEntity,HttpResource
A self contained, repeatable resource that obtains its content from a
String.
See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionConstructor.StringResource(ContentType contentType, String contents) Constructor.protectedStringResource(StringResource 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
-
StringResource
public StringResource()Constructor. -
StringResource
Constructor.- Parameters:
contentType- The entity content type.contents- The entity contents.
-
StringResource
Copy constructor.- Parameters:
copyFrom- The bean being copied.
-
-
Method Details
-
copy
Description copied from class:BasicResourceCreates a builder for this class initialized with the contents of this bean.Allows you to create a modifiable copy of this bean.
- Overrides:
copyin classBasicResource- Returns:
- A new builder bean.
-
setCached
Description copied from class:BasicResourceSpecifies that the contents of this resource should be cached into an internal byte array so that it can be read multiple times.- Overrides:
setCachedin classBasicResource- Returns:
- This object.
- Throws:
IOException- If entity could not be read into memory.
-
setChunked
Description copied from class:BasicResourceSets 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 classBasicResource- Returns:
- This object.
- If the
-
setChunked
Description copied from class:BasicResourceSets the 'chunked' flag value.Notes:
- If the
HttpEntity.getContentLength()method returns a negative value, the HttpClient code will always use chunked encoding.
- Overrides:
setChunkedin classBasicResource- Parameters:
value- The new value for this flag.- Returns:
- This object.
- If the
-
setContent
Description copied from class:BasicResourceSets the content on this entity bean.- Overrides:
setContentin classBasicResource- Parameters:
value- The entity content, can benull .- Returns:
- This object.
-
setContent
Description copied from class:BasicResourceSets 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 classBasicResource- Parameters:
value- The entity content, can benull .- Returns:
- This object.
-
setContentEncoding
Description copied from class:BasicResourceSets the content encoding header on this entity bean.- Overrides:
setContentEncodingin classBasicResource- Parameters:
value- The newContent-Encoding header, ornull to unset.- Returns:
- This object.
-
setContentEncoding
Description copied from class:BasicResourceSets the content encoding header on this entity bean.- Overrides:
setContentEncodingin classBasicResource- Parameters:
value- The newContent-Encoding header, ornull to unset.- Returns:
- This object.
-
setContentLength
Description copied from class:BasicResourceSets the content length on this entity bean.- Overrides:
setContentLengthin classBasicResource- Parameters:
value- The newContent-Length header value, or-1 to unset.- Returns:
- This object.
-
setContentType
Description copied from class:BasicResourceSets the content type on this entity bean.- Overrides:
setContentTypein classBasicResource- Parameters:
value- The newContent-Type header, ornull to unset.- Returns:
- This object.
-
setContentType
Description copied from class:BasicResourceSets the content type on this entity bean.- Overrides:
setContentTypein classBasicResource- Parameters:
value- The newContent-Type header, ornull to unset.- Returns:
- This object.
-
setHeaders
Description copied from class:BasicResourceSets the specified headers in this builder.- Overrides:
setHeadersin classBasicResource- Parameters:
value- The new value.- Returns:
- This object.
-
setUnmodifiable
Description copied from class:BasicResourceSpecifies whether this bean should be unmodifiable.When enabled, attempting to set any properties on this bean will cause an
UnsupportedOperationException.- Overrides:
setUnmodifiablein classBasicResource- Returns:
- This object.
-