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 SummaryConstructorsModifierConstructorDescriptionConstructor.StringResource(ContentType contentType, String contents) Constructor.protectedStringResource(StringResource copyFrom) Copy constructor.
- 
Method SummaryModifier 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.BasicResourceaddHeader, addHeaders, asBytes, assertBytes, assertModifiable, assertString, asString, consumeContent, copyFrom, getContent, getContentEncoding, getContentLength, getContentType, getEntity, getHeaders, isChunked, isRepeatable, isStreaming, isUnmodifiable, setHeader, setHeaders, writeTo
- 
Constructor Details- 
StringResourcepublic StringResource()Constructor.
- 
StringResourceConstructor.- Parameters:
- contentType- The entity content type.
- contents- The entity contents.
 
- 
StringResourceCopy constructor.- Parameters:
- copyFrom- The bean being copied.
 
 
- 
- 
Method Details- 
copyDescription 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 class- BasicResource
- Returns:
- A new builder bean.
 
- 
setCachedDescription 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 class- BasicResource
- Returns:
- This object.
- Throws:
- IOException- If entity could not be read into memory.
 
- 
setChunkedDescription 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 class- BasicResource
- Returns:
- This object.
 
- If the 
- 
setChunkedDescription 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 class- BasicResource
- Parameters:
- value- The new value for this flag.
- Returns:
- This object.
 
- If the 
- 
setContentDescription copied from class:BasicResourceSets the content on this entity bean.- Overrides:
- setContentin class- BasicResource
- Parameters:
- value- The entity content, can be- null .
- Returns:
- This object.
 
- 
setContentDescription 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 class- BasicResource
- Parameters:
- value- The entity content, can be- null .
- Returns:
- This object.
 
- 
setContentEncodingDescription copied from class:BasicResourceSets the content encoding header on this entity bean.- Overrides:
- setContentEncodingin class- BasicResource
- Parameters:
- value- The new- Content-Encoding header, or- null to unset.
- Returns:
- This object.
 
- 
setContentEncodingDescription copied from class:BasicResourceSets the content encoding header on this entity bean.- Overrides:
- setContentEncodingin class- BasicResource
- Parameters:
- value- The new- Content-Encoding header, or- null to unset.
- Returns:
- This object.
 
- 
setContentLengthDescription copied from class:BasicResourceSets the content length on this entity bean.- Overrides:
- setContentLengthin class- BasicResource
- Parameters:
- value- The new- Content-Length header value, or- -1 to unset.
- Returns:
- This object.
 
- 
setContentTypeDescription copied from class:BasicResourceSets the content type on this entity bean.- Overrides:
- setContentTypein class- BasicResource
- Parameters:
- value- The new- Content-Type header, or- null to unset.
- Returns:
- This object.
 
- 
setContentTypeDescription copied from class:BasicResourceSets the content type on this entity bean.- Overrides:
- setContentTypein class- BasicResource
- Parameters:
- value- The new- Content-Type header, or- null to unset.
- Returns:
- This object.
 
- 
setHeadersDescription copied from class:BasicResourceSets the specified headers in this builder.- Overrides:
- setHeadersin class- BasicResource
- Parameters:
- value- The new value.
- Returns:
- This object.
 
- 
setUnmodifiableDescription 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 class- BasicResource
- Returns:
- This object.
 
 
-