ParsingLoadable
@UnstableApi
class ParsingLoadable<T> : Loader.Loadable
A Loadable for objects that can be parsed from binary data using a Parser.
| Parameters | |
|---|---|
<T> |
The type of the object being loaded. |
Summary
Nested types |
|---|
class ParsingLoadable.Builder<T>Builder for |
interface ParsingLoadable.Parser<T>Parses an object from loaded data. |
Public constructors |
|---|
This function is deprecated. Use |
This function is deprecated. Use |
Public functions |
|
|---|---|
Long |
Returns the number of bytes loaded. |
Unit |
Cancels the load. |
(Mutable)Map<String!, (Mutable)List<String!>!>! |
Returns the response headers associated with the load. |
Uri! |
getUri()Returns the |
Unit |
load()Performs the load, returning on completion or cancellation. |
java-static T! |
<T> load(Loads a single parsable object. |
java-static T! |
<T> load(Loads a single parsable object. |
Public properties |
|
|---|---|
DataSpec! |
The |
Long |
Identifies the load task for this loadable. |
volatile T? |
|
String? |
The ID of the steered pathway from which data is being loaded, or |
Int |
The |
Public constructors
ParsingLoadable
ParsingLoadable(
dataSource: DataSource!,
dataSpec: DataSpec!,
@C.DataType type: Int,
parser: ParsingLoadable.Parser<T!>!
)
ParsingLoadable
ParsingLoadable(
dataSource: DataSource!,
uri: Uri!,
@C.DataType type: Int,
parser: ParsingLoadable.Parser<T!>!
)
Public functions
bytesLoaded
fun bytesLoaded(): Long
Returns the number of bytes loaded. In the case that the network response was compressed, the value returned is the size of the data after decompression. Must only be called after the load completed, failed, or was canceled.
cancelLoad
fun cancelLoad(): Unit
Cancels the load.
Loadable implementations should ensure that a currently executing load call will exit reasonably quickly after this method is called. The load call may exit either by returning or by throwing an IOException.
If there is a currently executing load call, then the thread on which that call is being made will be interrupted immediately after the call to this method. Hence implementations do not need to (and should not attempt to) interrupt the loading thread themselves.
Although the loading thread will be interrupted, Loadable implementations should not use the interrupted status of the loading thread in load to determine whether the load has been canceled. This approach is not robust [Internal ref: b/79223737]. Instead, implementations should use their own flag to signal cancelation (for example, using AtomicBoolean).
getResponseHeaders
fun getResponseHeaders(): (Mutable)Map<String!, (Mutable)List<String!>!>!
Returns the response headers associated with the load. Must only be called after the load completed, failed, or was canceled.
getUri
fun getUri(): Uri!
Returns the Uri from which data was read. If redirection occurred, this is the redirected uri. Must only be called after the load completed, failed, or was canceled.
load
fun load(): Unit
Performs the load, returning on completion or cancellation.
| Throws | |
|---|---|
java.io.IOException |
If the input could not be loaded. |
load
java-static fun <T> load(
dataSource: DataSource!,
parser: ParsingLoadable.Parser<T!>!,
dataSpec: DataSpec!,
@C.DataType type: Int
): T!
Loads a single parsable object.
| Parameters | |
|---|---|
dataSource: DataSource! |
The |
parser: ParsingLoadable.Parser<T!>! |
The |
dataSpec: DataSpec! |
The |
@C.DataType type: Int |
The |
| Returns | |
|---|---|
T! |
The parsed object |
| Throws | |
|---|---|
java.io.IOException |
Thrown if there is an error while loading or parsing. |
load
java-static fun <T> load(
dataSource: DataSource!,
parser: ParsingLoadable.Parser<T!>!,
uri: Uri!,
@C.DataType type: Int
): T!
Loads a single parsable object.
| Parameters | |
|---|---|
dataSource: DataSource! |
The |
parser: ParsingLoadable.Parser<T!>! |
The |
uri: Uri! |
The |
@C.DataType type: Int |
The |
| Returns | |
|---|---|
T! |
The parsed object |
| Throws | |
|---|---|
java.io.IOException |
Thrown if there is an error while loading or parsing. |
Public properties
steeredPathwayId
val steeredPathwayId: String?
The ID of the steered pathway from which data is being loaded, or null if not applicable.