public abstract class DownloadAction
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
DownloadAction.Deserializer
Used to deserialize
DownloadAction s. |
Modifier and Type | Field and Description |
---|---|
byte[] |
data
Custom data for this action.
|
boolean |
isRemoveAction
Whether this is a remove action.
|
java.lang.String |
type
The type of the action.
|
android.net.Uri |
uri
The uri being downloaded or removed.
|
int |
version
The action version.
|
Modifier | Constructor and Description |
---|---|
protected |
DownloadAction(java.lang.String type,
int version,
android.net.Uri uri,
boolean isRemoveAction,
byte[] data) |
Modifier and Type | Method and Description |
---|---|
abstract Downloader |
createDownloader(DownloaderConstructorHelper downloaderConstructorHelper)
Creates a
Downloader with the given parameters. |
static DownloadAction |
deserializeFromStream(DownloadAction.Deserializer[] deserializers,
java.io.InputStream input)
Deserializes one action that was serialized with
serializeToStream(DownloadAction,
OutputStream) from the input , using the DownloadAction.Deserializer s that supports the
action's type. |
boolean |
equals(java.lang.Object o) |
static DownloadAction.Deserializer[] |
getDefaultDeserializers()
Returns available default
DownloadAction.Deserializer s. |
java.util.List<StreamKey> |
getKeys()
Returns keys of tracks to be downloaded.
|
int |
hashCode() |
boolean |
isSameMedia(DownloadAction other)
Returns whether this is an action for the same media as the
other . |
static void |
serializeToStream(DownloadAction action,
java.io.OutputStream output)
Serializes
action type and data into the output . |
byte[] |
toByteArray()
Serializes itself into a byte array.
|
protected abstract void |
writeToStream(java.io.DataOutputStream output)
Serializes itself into the
output . |
public final java.lang.String type
public final int version
public final android.net.Uri uri
public final boolean isRemoveAction
public final byte[] data
protected DownloadAction(java.lang.String type, int version, android.net.Uri uri, boolean isRemoveAction, @Nullable byte[] data)
type
- The type of the action.version
- The action version.uri
- The uri being downloaded or removed.isRemoveAction
- Whether this is a remove action. If false, this is a download action.data
- Optional custom data for this action.public static DownloadAction.Deserializer[] getDefaultDeserializers()
DownloadAction.Deserializer
s.public static DownloadAction deserializeFromStream(DownloadAction.Deserializer[] deserializers, java.io.InputStream input) throws java.io.IOException
serializeToStream(DownloadAction,
OutputStream)
from the input
, using the DownloadAction.Deserializer
s that supports the
action's type.
The caller is responsible for closing the given InputStream
.
deserializers
- DownloadAction.Deserializer
s for supported actions.input
- The stream from which to read the action.java.io.IOException
- If there is an IO error reading from input
, or if the action type
isn't supported by any of the deserializers
.public static void serializeToStream(DownloadAction action, java.io.OutputStream output) throws java.io.IOException
action
type and data into the output
.java.io.IOException
public final byte[] toByteArray()
public boolean isSameMedia(DownloadAction other)
other
.public java.util.List<StreamKey> getKeys()
protected abstract void writeToStream(java.io.DataOutputStream output) throws java.io.IOException
output
.java.io.IOException
public abstract Downloader createDownloader(DownloaderConstructorHelper downloaderConstructorHelper)
Downloader
with the given parameters.public boolean equals(@Nullable java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object