org.apache.tapestry5.internal.services.assets

## Class StreamableResourceImpl

- java.lang.Object
- - org.apache.tapestry5.internal.services.assets.StreamableResourceImpl

- All Implemented Interfaces:
    StreamableResource
  Direct Known Subclasses:
    CompressedStreamableResource

      public class StreamableResourceImpl
      extends Object
      implements StreamableResource

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected AssetChecksumGenerator` | `assetChecksumGenerator`
    `protected BytestreamCache` | `bytestreamCache`
    `protected CompressionStatus` | `compression`
    `protected String` | `description`
    `protected long` | `lastModified`
    `protected ResponseCustomizer` | `responseCustomizer`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `StreamableResourceImpl(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 and Description
    --- | ---
    `StreamableResource` | `addResponseCustomizer(ResponseCustomizer customizer)` Returns a new StreamableResource that includes the provided customizer.
    `String` | `getChecksum()` Compute and return the checksum of the content for this asset; the checksum should be computed based on the uncompressed content.
    `CompressionStatus` | `getCompression()` Indicates if the content is compressed, or compressable.
    `ContentType` | `getContentType()` Returns the resource's content type.
    `String` | `getDescription()` Describes the underlying `Resource` (or resources} for this streamable resource; expressly used as part of the object's `toString()`.
    `long` | `getLastModified()` Returns the time the resource was last modified, with accuracy to one second (so as to match the HTTP request/response date headers).
    `ResponseCustomizer` | `getResponseCustomizer()` Returns the customizer, if any, for this resource.
    `int` | `getSize()` The size, in bytes, of the underlying bytestream.
    `InputStream` | `openStream()` Opens the content of the resource as an input stream; the caller is responsible for closing the stream after reading it.
    `void` | `streamTo(OutputStream os)` Streams the resource's content to the provided stream.
    `String` | `toString()`
    `StreamableResource` | `withContentType(ContentType newContentType)` Returns a new StreamableResource instance with the new content type.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### description

          protected final 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(String description,
                                        ContentType contentType,
                                        CompressionStatus compression,
                                        long lastModified,
                                        BytestreamCache bytestreamCache,
                                        AssetChecksumGenerator assetChecksumGenerator,
                                        ResponseCustomizer responseCustomizer)

  - ### Method Detail

    - #### getDescription

          public String getDescription()

      Description copied from interface: `StreamableResource`
      Describes the underlying `Resource` (or resources} for this streamable resource; expressly used as part of the object's `toString()`.
      Specified by:
        `getDescription` in interface `StreamableResource`

    - #### getCompression

          public CompressionStatus getCompression()

      Description copied from interface: `StreamableResource`
      Indicates if the content is compressed, or compressable.
      Specified by:
        `getCompression` in interface `StreamableResource`

    - #### getContentType

          public ContentType getContentType()

      Description copied from interface: `StreamableResource`
      Returns the resource's content type.
      Specified by:
        `getContentType` in interface `StreamableResource`

    - #### getSize

          public int getSize()

      Description copied from interface: `StreamableResource`
      The size, in bytes, of the underlying bytestream.
      Specified by:
        `getSize` in interface `StreamableResource`

    - #### getLastModified

          public long getLastModified()

      Description copied from interface: `StreamableResource`
      Returns the time the resource was last modified, with accuracy to one second (so as to match the HTTP request/response date headers).
      Specified by:
        `getLastModified` in interface `StreamableResource`

    - #### streamTo

          public void streamTo(OutputStream os)
                        throws IOException

      Description copied from interface: `StreamableResource`
      Streams the resource's content to the provided stream. The caller is responsible for flushing or closing the output stream.
      Specified by:
        `streamTo` in interface `StreamableResource`
      Throws:
        `IOException`

    - #### openStream

          public InputStream openStream()
                                 throws IOException

      Description copied from interface: `StreamableResource`
      Opens the content of the resource as an input stream; the caller is responsible for closing the stream after reading it.
      Specified by:
        `openStream` in interface `StreamableResource`
      Returns:
        stream of the contents of the resource
      Throws:
        `IOException`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### getChecksum

          public String getChecksum()
                             throws IOException

      Description copied from interface: `StreamableResource`
      Compute and return the checksum of the content for this asset; the checksum should be computed based on the uncompressed content.
      Specified by:
        `getChecksum` in interface `StreamableResource`
      Returns:
        checksum for uncompressed content
      Throws:
        `IOException`
      See Also:
        `AssetChecksumGenerator.generateChecksum(StreamableResource)`

    - #### addResponseCustomizer

          public StreamableResource addResponseCustomizer(ResponseCustomizer customizer)

      Description copied from interface: `StreamableResource`
      Returns a new StreamableResource that includes the provided customizer. Customizers are invoked in the order they are added.
      Specified by:
        `addResponseCustomizer` in interface `StreamableResource`

    - #### getResponseCustomizer

          public ResponseCustomizer getResponseCustomizer()

      Description copied from interface: `StreamableResource`
      Returns the customizer, if any, for this resource. This may represent an aggregate customizer.
      Specified by:
        `getResponseCustomizer` in interface `StreamableResource`

    - #### withContentType

          public StreamableResource withContentType(ContentType newContentType)

      Description copied from interface: `StreamableResource`
      Returns a new StreamableResource instance with the new content type.
      Specified by:
        `withContentType` in interface `StreamableResource`

${project.version} - Copyright © 2003-2015 The Apache Software Foundation.