public abstract class DownloadAction
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
DownloadAction.Deserializer
Used to deserialize
DownloadActions. |
| 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 |
|---|---|
protected 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.Deserializers that supports the
action's type. |
boolean |
equals(java.lang.Object o) |
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 deserializeFromStream(DownloadAction.Deserializer[] deserializers, java.io.InputStream input) throws java.io.IOException
serializeToStream(DownloadAction,
OutputStream) from the input, using the DownloadAction.Deserializers that supports the
action's type.
The caller is responsible for closing the given InputStream.
deserializers - DownloadAction.Deserializers 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.IOExceptionpublic final byte[] toByteArray()
public boolean isSameMedia(DownloadAction other)
other.protected abstract void writeToStream(java.io.DataOutputStream output)
throws java.io.IOException
output.java.io.IOExceptionprotected abstract Downloader createDownloader(DownloaderConstructorHelper downloaderConstructorHelper)
Downloader with the given parameters.public boolean equals(@Nullable
java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Object