Package com.google.android.exoplayer2.upstream.cache

## Class CacheSpan

- java.lang.Object
- - com.google.android.exoplayer2.upstream.cache.CacheSpan

- All Implemented Interfaces:
    `Comparable<CacheSpan>`

      public class CacheSpan
      extends Object
      implements Comparable<CacheSpan>

  Defines a span of data that may or may not be cached (as indicated by `isCached`).

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `File` | `file` | The file corresponding to this `CacheSpan`, or null if `isCached` is false.
    `boolean` | `isCached` | Whether the `CacheSpan` is cached.
    `String` | `key` | The cache key that uniquely identifies the resource.
    `long` | `lastTouchTimestamp` | The last touch timestamp, or `C.TIME_UNSET` if `isCached` is false.
    `long` | `length` | The length of the `CacheSpan`, or `C.LENGTH_UNSET` if this is an open-ended hole.
    `long` | `position` | The position of the `CacheSpan` in the resource.

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `CacheSpan​(String key, long position, long length)` | Creates a hole CacheSpan which isn't cached, has no last touch timestamp and no file associated.
    `CacheSpan​(String key, long position, long length, long lastTouchTimestamp, File file)` | Creates a CacheSpan.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `int` | `compareTo​(CacheSpan another)` |
    `boolean` | `isHoleSpan()` | Returns whether this is a hole `CacheSpan`.
    `boolean` | `isOpenEnded()` | Returns whether this is an open-ended `CacheSpan`.
    `String` | `toString()` |

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

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

- - ### Field Detail

    - #### key

          public final String key

      The cache key that uniquely identifies the resource.

    - #### position

          public final long position

      The position of the `CacheSpan` in the resource.

    - #### length

          public final long length

      The length of the `CacheSpan`, or `C.LENGTH_UNSET` if this is an open-ended hole.

    - #### isCached

          public final boolean isCached

      Whether the `CacheSpan` is cached.

    - #### file

          @Nullable
          public final File file

      The file corresponding to this `CacheSpan`, or null if `isCached` is false.

    - #### lastTouchTimestamp

          public final long lastTouchTimestamp

      The last touch timestamp, or `C.TIME_UNSET` if `isCached` is false.

  - ### Constructor Detail

    - #### CacheSpan

          public CacheSpan​(String key,
                           long position,
                           long length)

      Creates a hole CacheSpan which isn't cached, has no last touch timestamp and no file associated.
      Parameters:
        `key` - The cache key that uniquely identifies the resource.
        `position` - The position of the `CacheSpan` in the resource.
        `length` - The length of the `CacheSpan`, or `C.LENGTH_UNSET` if this is an open-ended hole.

    - #### CacheSpan

          public CacheSpan​(String key,
                           long position,
                           long length,
                           long lastTouchTimestamp,
                           @Nullable
                           File file)

      Creates a CacheSpan.
      Parameters:
        `key` - The cache key that uniquely identifies the resource.
        `position` - The position of the `CacheSpan` in the resource.
        `length` - The length of the `CacheSpan`, or `C.LENGTH_UNSET` if this is an open-ended hole.
        `lastTouchTimestamp` - The last touch timestamp, or `C.TIME_UNSET` if `isCached` is false.
        `file` - The file corresponding to this `CacheSpan`, or null if it's a hole.

  - ### Method Detail

    - #### isOpenEnded

          public boolean isOpenEnded()

      Returns whether this is an open-ended `CacheSpan`.

    - #### isHoleSpan

          public boolean isHoleSpan()

      Returns whether this is a hole `CacheSpan`.

    - #### compareTo

          public int compareTo​(CacheSpan another)

      Specified by:
        `compareTo` in interface `Comparable<CacheSpan>`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`