DataSpec.Builder


public final 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

public Builder()

Creates a new instance with default values.

Public methods

build

public DataSpec build()

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
public DataSpec.Builder setCustomData(@Nullable Object customData)

Sets the customData. The default value is null.

Parameters
@Nullable Object customData

The customData.

Returns
DataSpec.Builder

The builder.

setFlags

@CanIgnoreReturnValue
public DataSpec.Builder setFlags(@DataSpec.Flags int flags)

Sets the flags. The default value is 0.

Parameters
@DataSpec.Flags int flags

The flags.

Returns
DataSpec.Builder

The builder.

setHttpBody

@CanIgnoreReturnValue
public DataSpec.Builder setHttpBody(@Nullable byte[] httpBody)

Sets httpBody. The default value is null.

Parameters
@Nullable byte[] httpBody

The httpBody.

Returns
DataSpec.Builder

The builder.

setHttpMethod

@CanIgnoreReturnValue
public DataSpec.Builder setHttpMethod(@DataSpec.HttpMethod int httpMethod)

Sets httpMethod. The default value is HTTP_METHOD_GET.

Parameters
@DataSpec.HttpMethod int httpMethod

The httpMethod.

Returns
DataSpec.Builder

The builder.

setHttpRequestHeaders

@CanIgnoreReturnValue
public DataSpec.Builder setHttpRequestHeaders(Map<StringString> httpRequestHeaders)

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
Map<StringString> httpRequestHeaders

The httpRequestHeaders.

Returns
DataSpec.Builder

The builder.

setKey

@CanIgnoreReturnValue
public DataSpec.Builder setKey(@Nullable String key)

Sets the key. The default value is null.

Parameters
@Nullable String key

The key.

Returns
DataSpec.Builder

The builder.

setLength

@CanIgnoreReturnValue
public DataSpec.Builder setLength(long length)

Sets the length. The default value is LENGTH_UNSET.

Parameters
long length

The length.

Returns
DataSpec.Builder

The builder.

setPosition

@CanIgnoreReturnValue
public DataSpec.Builder setPosition(long position)

Sets the position. The default value is 0.

Parameters
long position

The position.

Returns
DataSpec.Builder

The builder.

setUri

@CanIgnoreReturnValue
public DataSpec.Builder setUri(String uriString)

Sets uri.

Parameters
String uriString

The uri.

Returns
DataSpec.Builder

The builder.

setUri

@CanIgnoreReturnValue
public DataSpec.Builder setUri(Uri uri)

Sets uri.

Parameters
Uri uri

The uri.

Returns
DataSpec.Builder

The builder.

setUriPositionOffset

@CanIgnoreReturnValue
public DataSpec.Builder setUriPositionOffset(long uriPositionOffset)

Sets the uriPositionOffset. The default value is 0.

Parameters
long uriPositionOffset

The uriPositionOffset.

Returns
DataSpec.Builder

The builder.