Package com.castlabs.android.downloader

## Class ZipDataSource

- java.lang.Object
- - com.castlabs.android.downloader.ZipDataSource

- All Implemented Interfaces:
    `com.google.android.exoplayer2.upstream.DataSource`

      public class ZipDataSource
      extends Object
      implements com.google.android.exoplayer2.upstream.DataSource

  Implementation of a DataSource that can read data from a zip file. The URI scheme for this should be zip. We expect to get a URI where the path consistes of the path to the zip and the path to the zip entry. For example `zip:/path/to/container.zip/path/to/entry.txt`.
  Since:
    3.0.0

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `static class` | `ZipDataSource.ZipDataSourceException` | Thrown when IOException is encountered during local file read operation.

    - ### Nested classes/interfaces inherited from interface com.google.android.exoplayer2.upstream.DataSource

      `com.google.android.exoplayer2.upstream.DataSource.Factory`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `ZipDataSource()` | Constructs a new `DataSource` that retrieves data from a file.
    `ZipDataSource​(com.google.android.exoplayer2.upstream.TransferListener listener)` | Constructs a new `DataSource` that retrieves data from a file.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `addTransferListener​(com.google.android.exoplayer2.upstream.TransferListener listener)` |
    `void` | `close()` |
    `int` | `getResponseCode()` |
    `Map<String,​List<String>>` | `getResponseHeaders()` |
    `Uri` | `getUri()` |
    `long` | `open​(com.google.android.exoplayer2.upstream.DataSpec dataSpec)` |
    `int` | `read​(byte[] buffer, int offset, int readLength)` |

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

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ZipDataSource

          public ZipDataSource()

      Constructs a new `DataSource` that retrieves data from a file.

    - #### ZipDataSource

          public ZipDataSource​(com.google.android.exoplayer2.upstream.TransferListener listener)

      Constructs a new `DataSource` that retrieves data from a file.
      Parameters:
        `listener` - An optional listener. Specify `null` for no listener.

  - ### Method Detail

    - #### getResponseCode

          public int getResponseCode()

      Specified by:
        `getResponseCode` in interface `com.google.android.exoplayer2.upstream.DataSource`

    - #### getResponseHeaders

          public Map<String,​List<String>> getResponseHeaders()

      Specified by:
        `getResponseHeaders` in interface `com.google.android.exoplayer2.upstream.DataSource`

    - #### addTransferListener

          public void addTransferListener​(com.google.android.exoplayer2.upstream.TransferListener listener)

      Specified by:
        `addTransferListener` in interface `com.google.android.exoplayer2.upstream.DataSource`

    - #### open

          public long open​(com.google.android.exoplayer2.upstream.DataSpec dataSpec)
                    throws ZipDataSource.ZipDataSourceException

      Specified by:
        `open` in interface `com.google.android.exoplayer2.upstream.DataSource`
      Throws:
        `ZipDataSource.ZipDataSourceException`

    - #### read

          public int read​(byte[] buffer,
                          int offset,
                          int readLength)
                   throws ZipDataSource.ZipDataSourceException

      Specified by:
        `read` in interface `com.google.android.exoplayer2.upstream.DataSource`
      Throws:
        `ZipDataSource.ZipDataSourceException`

    - #### getUri

          public Uri getUri()

      Specified by:
        `getUri` in interface `com.google.android.exoplayer2.upstream.DataSource`

    - #### close

          public void close()
                     throws ZipDataSource.ZipDataSourceException

      Specified by:
        `close` in interface `com.google.android.exoplayer2.upstream.DataSource`
      Throws:
        `ZipDataSource.ZipDataSourceException`