public abstract class DownloadAction extends 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.
|
String |
type
The type of the action.
|
Uri |
uri
The uri being downloaded or removed.
|
int |
version
The action version.
|
Modifier | Constructor and Description |
---|---|
protected |
DownloadAction(String type,
int version,
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,
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(Object o) |
static DownloadAction.Deserializer[] |
getDefaultDeserializers()
Returns available default
DownloadAction.Deserializer s. |
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,
OutputStream output)
Serializes
action type and data into the output . |
byte[] |
toByteArray()
Serializes itself into a byte array.
|
protected abstract void |
writeToStream(DataOutputStream output)
Serializes itself into the
output . |
public final String type
public final int version
public final Uri uri
public final boolean isRemoveAction
public final byte[] data
protected DownloadAction(String type, int version, 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, InputStream input) throws 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.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, OutputStream output) throws IOException
action
type and data into the output
.IOException
public final byte[] toByteArray()
public boolean isSameMedia(DownloadAction other)
other
.protected abstract void writeToStream(DataOutputStream output) throws IOException
output
.IOException
public abstract Downloader createDownloader(DownloaderConstructorHelper downloaderConstructorHelper)
Downloader
with the given parameters.