Package org.apache.tapestry5.services.assets

## Interface StreamableResource

- All Known Implementing Classes:
    `CompressedStreamableResource`, `StreamableResourceImpl`

      public interface StreamableResource

  An object, derived from a `Resource`, that can be streamed (ultimately, to a client web browser). In addition, a StreamableResource may be transformed (by the stack of interceptors around `StreamableResourceSource`: this includes transforming a Resource (example: CoffeeScript to JavaScript compilation), as well as aggregation and compression.
  Since:
    5.3

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `StreamableResource` | `addResponseCustomizer​(ResponseCustomizer customizer)` | Returns a new StreamableResource that includes the provided customizer.
    `java.lang.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.
    `java.lang.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.
    `java.io.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​(java.io.OutputStream os)` | Streams the resource's content to the provided stream.
    `StreamableResource` | `withContentType​(ContentType newContentType)` | Returns a new StreamableResource instance with the new content type.

- - ### Method Detail

    - #### getDescription

          java.lang.String getDescription()

      Describes the underlying `Resource` (or resources} for this streamable resource; expressly used as part of the object's `toString()`.

    - #### getCompression

          CompressionStatus getCompression()

      Indicates if the content is compressed, or compressable.

    - #### getContentType

          @IncompatibleChange(release="5.4",
                              details="Changed from type String to ContentType")
          ContentType getContentType()

      Returns the resource's content type.

    - #### getSize

          int getSize()

      The size, in bytes, of the underlying bytestream.

    - #### streamTo

          void streamTo​(java.io.OutputStream os)
                 throws java.io.IOException

      Streams the resource's content to the provided stream. The caller is responsible for flushing or closing the output stream.
      Throws:
        `java.io.IOException`

    - #### openStream

          java.io.InputStream openStream()
                                  throws java.io.IOException

      Opens the content of the resource as an input stream; the caller is responsible for closing the stream after reading it.
      Returns:
        stream of the contents of the resource
      Throws:
        `java.io.IOException`

    - #### getLastModified

          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).

    - #### getChecksum

          java.lang.String getChecksum()
                                throws java.io.IOException

      Compute and return the checksum of the content for this asset; the checksum should be computed based on the uncompressed content.
      Returns:
        checksum for uncompressed content
      Throws:
        `java.io.IOException`
      Since:
        5.4
      See Also:
        `AssetChecksumGenerator.generateChecksum(StreamableResource)`

    - #### addResponseCustomizer

          StreamableResource addResponseCustomizer​(ResponseCustomizer customizer)

      Returns a new StreamableResource that includes the provided customizer. Customizers are invoked in the order they are added.
      Since:
        5.4

    - #### getResponseCustomizer

          ResponseCustomizer getResponseCustomizer()

      Returns the customizer, if any, for this resource. This may represent an aggregate customizer.
      Since:
        5.4

    - #### withContentType

          StreamableResource withContentType​(ContentType newContentType)

      Returns a new StreamableResource instance with the new content type.
      Parameters:
        `newContentType` -
      Since:
        5.4