Class StreamableResourceImpl
- java.lang.Object
-
- org.apache.tapestry5.internal.services.assets.StreamableResourceImpl
-
- All Implemented Interfaces:
StreamableResource
- Direct Known Subclasses:
CompressedStreamableResource
public class StreamableResourceImpl extends java.lang.Object implements StreamableResource
-
-
Field Summary
Fields Modifier and Type Field Description protected AssetChecksumGeneratorassetChecksumGeneratorprotected BytestreamCachebytestreamCacheprotected CompressionStatuscompressionprotected java.lang.Stringdescriptionprotected longlastModifiedprotected ResponseCustomizerresponseCustomizer
-
Constructor Summary
Constructors Constructor Description StreamableResourceImpl(java.lang.String description, ContentType contentType, CompressionStatus compression, long lastModified, BytestreamCache bytestreamCache, AssetChecksumGenerator assetChecksumGenerator, ResponseCustomizer responseCustomizer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StreamableResourceaddResponseCustomizer(ResponseCustomizer customizer)Returns a new StreamableResource that includes the provided customizer.booleanequals(java.lang.Object obj)java.lang.StringgetChecksum()Compute and return the checksum of the content for this asset; the checksum should be computed based on the uncompressed content.CompressionStatusgetCompression()Indicates if the content is compressed, or compressable.ContentTypegetContentType()Returns the resource's content type.java.lang.StringgetDescription()Describes the underlyingResource(or resources} for this streamable resource; expressly used as part of the object'stoString().longgetLastModified()Returns the time the resource was last modified, with accuracy to one second (so as to match the HTTP request/response date headers).ResponseCustomizergetResponseCustomizer()Returns the customizer, if any, for this resource.intgetSize()The size, in bytes, of the underlying bytestream.inthashCode()java.io.InputStreamopenStream()Opens the content of the resource as an input stream; the caller is responsible for closing the stream after reading it.voidstreamTo(java.io.OutputStream os)Streams the resource's content to the provided stream.java.lang.StringtoString()StreamableResourcewithContentType(ContentType newContentType)Returns a new StreamableResource instance with the new content type.
-
-
-
Field Detail
-
description
protected final java.lang.String description
-
compression
protected final CompressionStatus compression
-
lastModified
protected final long lastModified
-
bytestreamCache
protected final BytestreamCache bytestreamCache
-
assetChecksumGenerator
protected final AssetChecksumGenerator assetChecksumGenerator
-
responseCustomizer
protected final ResponseCustomizer responseCustomizer
-
-
Constructor Detail
-
StreamableResourceImpl
public StreamableResourceImpl(java.lang.String description, ContentType contentType, CompressionStatus compression, long lastModified, BytestreamCache bytestreamCache, AssetChecksumGenerator assetChecksumGenerator, ResponseCustomizer responseCustomizer)
-
-
Method Detail
-
getDescription
public java.lang.String getDescription()
Description copied from interface:StreamableResourceDescribes the underlyingResource(or resources} for this streamable resource; expressly used as part of the object'stoString().- Specified by:
getDescriptionin interfaceStreamableResource
-
getCompression
public CompressionStatus getCompression()
Description copied from interface:StreamableResourceIndicates if the content is compressed, or compressable.- Specified by:
getCompressionin interfaceStreamableResource
-
getContentType
public ContentType getContentType()
Description copied from interface:StreamableResourceReturns the resource's content type.- Specified by:
getContentTypein interfaceStreamableResource
-
getSize
public int getSize()
Description copied from interface:StreamableResourceThe size, in bytes, of the underlying bytestream.- Specified by:
getSizein interfaceStreamableResource
-
getLastModified
public long getLastModified()
Description copied from interface:StreamableResourceReturns the time the resource was last modified, with accuracy to one second (so as to match the HTTP request/response date headers).- Specified by:
getLastModifiedin interfaceStreamableResource
-
streamTo
public void streamTo(java.io.OutputStream os) throws java.io.IOException
Description copied from interface:StreamableResourceStreams the resource's content to the provided stream. The caller is responsible for flushing or closing the output stream.- Specified by:
streamToin interfaceStreamableResource- Throws:
java.io.IOException
-
openStream
public java.io.InputStream openStream() throws java.io.IOException
Description copied from interface:StreamableResourceOpens the content of the resource as an input stream; the caller is responsible for closing the stream after reading it.- Specified by:
openStreamin interfaceStreamableResource- Returns:
- stream of the contents of the resource
- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getChecksum
public java.lang.String getChecksum() throws java.io.IOException
Description copied from interface:StreamableResourceCompute and return the checksum of the content for this asset; the checksum should be computed based on the uncompressed content.- Specified by:
getChecksumin interfaceStreamableResource- Returns:
- checksum for uncompressed content
- Throws:
java.io.IOException- See Also:
AssetChecksumGenerator.generateChecksum(StreamableResource)
-
addResponseCustomizer
public StreamableResource addResponseCustomizer(ResponseCustomizer customizer)
Description copied from interface:StreamableResourceReturns a new StreamableResource that includes the provided customizer. Customizers are invoked in the order they are added.- Specified by:
addResponseCustomizerin interfaceStreamableResource
-
getResponseCustomizer
public ResponseCustomizer getResponseCustomizer()
Description copied from interface:StreamableResourceReturns the customizer, if any, for this resource. This may represent an aggregate customizer.- Specified by:
getResponseCustomizerin interfaceStreamableResource
-
withContentType
public StreamableResource withContentType(ContentType newContentType)
Description copied from interface:StreamableResourceReturns a new StreamableResource instance with the new content type.- Specified by:
withContentTypein interfaceStreamableResource
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
-