public final class DataSpec
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
DataSpec.Flags
The flags that apply to any request for data.
|
| Modifier and Type | Field and Description |
|---|---|
long |
absoluteStreamPosition
The absolute position of the data in the full stream.
|
static int |
FLAG_ALLOW_CACHING_UNKNOWN_LENGTH
Permits content to be cached even if its length can not be resolved.
|
static int |
FLAG_ALLOW_GZIP
Permits an underlying network stack to request that the server use gzip compression.
|
int |
flags
Request flags.
|
java.lang.String |
key
A key that uniquely identifies the original stream.
|
long |
length
The length of the data, or
C.LENGTH_UNSET. |
long |
position
The position of the data when read from
uri. |
byte[] |
postBody
Body for a POST request, null otherwise.
|
android.net.Uri |
uri
The source from which data should be read.
|
| Constructor and Description |
|---|
DataSpec(android.net.Uri uri)
|
DataSpec(android.net.Uri uri,
byte[] postBody,
long absoluteStreamPosition,
long position,
long length,
java.lang.String key,
int flags)
|
DataSpec(android.net.Uri uri,
int flags)
|
DataSpec(android.net.Uri uri,
long absoluteStreamPosition,
long position,
long length,
java.lang.String key,
int flags)
|
DataSpec(android.net.Uri uri,
long absoluteStreamPosition,
long length,
java.lang.String key)
|
DataSpec(android.net.Uri uri,
long absoluteStreamPosition,
long length,
java.lang.String key,
int flags)
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
isFlagSet(int flag)
Returns whether the given flag is set.
|
DataSpec |
subrange(long offset)
Returns a
DataSpec that represents a subrange of the data defined by this DataSpec. |
DataSpec |
subrange(long offset,
long length)
Returns a
DataSpec that represents a subrange of the data defined by this DataSpec. |
java.lang.String |
toString() |
DataSpec |
withUri(android.net.Uri uri)
Returns a copy of this
DataSpec with the specified Uri. |
public static final int FLAG_ALLOW_GZIP
Should not typically be set if the data being requested is already compressed (e.g. most audio and video requests). May be set when requesting other data.
When a DataSource is used to request data with this flag set, and if the
DataSource does make a network request, then the value returned from
DataSource.open(DataSpec) will typically be C.LENGTH_UNSET. The data read from
DataSource.read(byte[], int, int) will be the decompressed data.
public static final int FLAG_ALLOW_CACHING_UNKNOWN_LENGTH
FLAG_ALLOW_GZIP is used.public final android.net.Uri uri
@Nullable public final byte[] postBody
public final long absoluteStreamPosition
public final long position
uri.
Always equal to absoluteStreamPosition unless the uri defines the location
of a subset of the underlying data.
public final long length
C.LENGTH_UNSET.@Nullable public final java.lang.String key
DataSpec is not intended to be used in conjunction with a cache.public final int flags
FLAG_ALLOW_GZIP and
FLAG_ALLOW_CACHING_UNKNOWN_LENGTH are the only supported flags.public DataSpec(android.net.Uri uri)
uri - uri.public DataSpec(android.net.Uri uri,
long absoluteStreamPosition,
long length,
@Nullable
java.lang.String key)
uri - uri.absoluteStreamPosition - absoluteStreamPosition, equal to position.length - length.key - key.public DataSpec(android.net.Uri uri,
long absoluteStreamPosition,
long length,
@Nullable
java.lang.String key,
int flags)
public DataSpec(android.net.Uri uri,
long absoluteStreamPosition,
long position,
long length,
@Nullable
java.lang.String key,
int flags)
public DataSpec(android.net.Uri uri,
@Nullable
byte[] postBody,
long absoluteStreamPosition,
long position,
long length,
@Nullable
java.lang.String key,
int flags)
public boolean isFlagSet(int flag)
flag - Flag to be checked if it is set.public java.lang.String toString()
toString in class java.lang.Objectpublic DataSpec subrange(long offset)
DataSpec that represents a subrange of the data defined by this DataSpec. The
subrange includes data from the offset up to the end of this DataSpec.offset - The offset of the subrange.DataSpec that represents a subrange of the data defined by this DataSpec.public DataSpec subrange(long offset, long length)
DataSpec that represents a subrange of the data defined by this DataSpec.offset - The offset of the subrange.length - The length of the subrange.DataSpec that represents a subrange of the data defined by this DataSpec.