@UnstableApi
public final class RangedUri


Defines a range of data located at a reference uri.

Summary

Public fields

final long

The length of the range, or LENGTH_UNSET to indicate that the range is unbounded.

final long

The (zero based) index of the first byte of the range.

Public constructors

RangedUri(@Nullable String referenceUri, long start, long length)

Constructs an ranged uri.

Public methods

@Nullable RangedUri

Attempts to merge this RangedUri with another and an optional common base uri.

boolean
int
Uri
resolveUri(String baseUri)

Returns the resolved Uri represented by the instance.

String

Returns the resolved uri represented by the instance as a string.

String

Public fields

length

public final long length

The length of the range, or LENGTH_UNSET to indicate that the range is unbounded.

start

public final long start

The (zero based) index of the first byte of the range.

Public constructors

RangedUri

public RangedUri(@Nullable String referenceUri, long start, long length)

Constructs an ranged uri.

Parameters
@Nullable String referenceUri

The reference uri.

long start

The (zero based) index of the first byte of the range.

long length

The length of the range, or LENGTH_UNSET to indicate that the range is unbounded.

Public methods

attemptMerge

public @Nullable RangedUri attemptMerge(@Nullable RangedUri other, String baseUri)

Attempts to merge this RangedUri with another and an optional common base uri.

A merge is successful if both instances define the same Uri after resolution with the base uri, and if one starts the byte after the other ends, forming a contiguous region with no overlap.

If other is null then the merge is considered unsuccessful, and null is returned.

Parameters
@Nullable RangedUri other

The RangedUri to merge.

String baseUri

The base Uri.

Returns
@Nullable RangedUri

The merged RangedUri if the merge was successful. Null otherwise.

equals

public boolean equals(@Nullable Object obj)

hashCode

public int hashCode()

resolveUri

public Uri resolveUri(String baseUri)

Returns the resolved Uri represented by the instance.

Parameters
String baseUri

The base Uri.

Returns
Uri

The Uri represented by the instance.

resolveUriString

public String resolveUriString(String baseUri)

Returns the resolved uri represented by the instance as a string.

Parameters
String baseUri

The base Uri.

Returns
String

The uri represented by the instance.

toString

public String toString()