DataSpec.Builder


class DataSpec.Builder


Builds DataSpec instances.

Use DataSpec#buildUpon() to obtain a builder representing an existing DataSpec.

Summary

Public constructors

Creates a new instance with default values.

Public constructors

Builder

Builder()

Creates a new instance with default values.

Public functions

build

fun build(): DataSpec!

Builds a DataSpec with the builder's current values.

Returns
DataSpec!

The build DataSpec.

Throws
java.lang.IllegalStateException

If setUri has not been called.

setCustomData

@CanIgnoreReturnValue
fun setCustomData(customData: Any?): DataSpec.Builder!

Sets the customData. The default value is null.

Parameters
customData: Any?

The customData.

Returns
DataSpec.Builder!

The builder.

setFlags

@CanIgnoreReturnValue
fun setFlags(@DataSpec.Flags flags: Int): DataSpec.Builder!

Sets the flags. The default value is 0.

Parameters
@DataSpec.Flags flags: Int

The flags.

Returns
DataSpec.Builder!

The builder.

setHttpBody

@CanIgnoreReturnValue
fun setHttpBody(httpBody: ByteArray?): DataSpec.Builder!

Sets httpBody. The default value is null.

Parameters
httpBody: ByteArray?

The httpBody.

Returns
DataSpec.Builder!

The builder.

setHttpMethod

@CanIgnoreReturnValue
fun setHttpMethod(@DataSpec.HttpMethod httpMethod: Int): DataSpec.Builder!

Sets httpMethod. The default value is HTTP_METHOD_GET.

Parameters
@DataSpec.HttpMethod httpMethod: Int

The httpMethod.

Returns
DataSpec.Builder!

The builder.

setHttpRequestHeaders

@CanIgnoreReturnValue
fun setHttpRequestHeaders(httpRequestHeaders: (Mutable)Map<String!, String!>!): DataSpec.Builder!

Sets the httpRequestHeaders. The default value is an empty map.

Note: Range, Accept-Encoding and User-Agent should not be set with this method, since they are set directly by HttpDataSource implementations. See httpRequestHeaders for more details.

Parameters
httpRequestHeaders: (Mutable)Map<String!, String!>!

The httpRequestHeaders.

Returns
DataSpec.Builder!

The builder.

setKey

@CanIgnoreReturnValue
fun setKey(key: String?): DataSpec.Builder!

Sets the key. The default value is null.

Parameters
key: String?

The key.

Returns
DataSpec.Builder!

The builder.

setLength

@CanIgnoreReturnValue
fun setLength(length: Long): DataSpec.Builder!

Sets the length. The default value is LENGTH_UNSET.

Parameters
length: Long

The length.

Returns
DataSpec.Builder!

The builder.

setPosition

@CanIgnoreReturnValue
fun setPosition(position: Long): DataSpec.Builder!

Sets the position. The default value is 0.

Parameters
position: Long

The position.

Returns
DataSpec.Builder!

The builder.

setUri

@CanIgnoreReturnValue
fun setUri(uriString: String!): DataSpec.Builder!

Sets uri.

Parameters
uriString: String!

The uri.

Returns
DataSpec.Builder!

The builder.

setUri

@CanIgnoreReturnValue
fun setUri(uri: Uri!): DataSpec.Builder!

Sets uri.

Parameters
uri: Uri!

The uri.

Returns
DataSpec.Builder!

The builder.

setUriPositionOffset

@CanIgnoreReturnValue
fun setUriPositionOffset(uriPositionOffset: Long): DataSpec.Builder!

Sets the uriPositionOffset. The default value is 0.

Parameters
uriPositionOffset: Long

The uriPositionOffset.

Returns
DataSpec.Builder!

The builder.