# FakeDataSet.FakeData

Artifact: [androidx.media3:media3-test-utils](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/test/utils/FakeDataSet.java+class:androidx.media3.test.utils.FakeDataSet.FakeData)

*** ** * ** ***


```
public final class FakeDataSet.FakeData
```

<br />

*** ** * ** ***

Container of fake data to be served by a `https://developer.android.com/reference/androidx/media3/test/utils/FakeDataSource`.

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/media3/test/utils/FakeDataSet.FakeData.Segment` A segment of `https://developer.android.com/reference/androidx/media3/test/utils/FakeDataSet.FakeData`. |

| ### Public fields |
|---|---|
| `final @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/net/Uri.html` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeDataSet.FakeData#uri()` Uri of the data or null if this is the default FakeData. |

| ### Public methods |
|---|---|
| `https://developer.android.com/reference/androidx/media3/test/utils/FakeDataSet.FakeData` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/test/utils/FakeDataSet.FakeData#appendReadAction(java.lang.Runnable)(https://developer.android.com/reference/java/lang/Runnable.html action)` Appends an action. |
| `https://developer.android.com/reference/androidx/media3/test/utils/FakeDataSet.FakeData` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/test/utils/FakeDataSet.FakeData#appendReadData(byte[])(byte[] data)` Appends to the underlying data. |
| `https://developer.android.com/reference/androidx/media3/test/utils/FakeDataSet.FakeData` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/test/utils/FakeDataSet.FakeData#appendReadData(int)(int length)` Appends a data segment of the specified length. |
| `https://developer.android.com/reference/androidx/media3/test/utils/FakeDataSet.FakeData` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/test/utils/FakeDataSet.FakeData#appendReadError(java.io.IOException)(https://developer.android.com/reference/java/io/IOException.html exception)` Appends an error in the underlying data. |
| `https://developer.android.com/reference/androidx/media3/test/utils/FakeDataSet` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeDataSet.FakeData#endData()()` Returns the `https://developer.android.com/reference/androidx/media3/test/utils/FakeDataSet` this FakeData belongs to. |
| `byte[]` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeDataSet.FakeData#getData()()` Returns the whole data added by `https://developer.android.com/reference/androidx/media3/test/utils/FakeDataSet.FakeData#appendReadData(byte[])`. |
| `https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/test/utils/FakeDataSet.FakeData.Segment>` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeDataSet.FakeData#getSegments()()` Returns the list of `https://developer.android.com/reference/androidx/media3/test/utils/FakeDataSet.FakeData.Segment`s. |
| `boolean` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeDataSet.FakeData#isSimulatingUnknownLength()()` Returns whether unknown length is simulated |
| `https://developer.android.com/reference/androidx/media3/test/utils/FakeDataSet.FakeData` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/test/utils/FakeDataSet.FakeData#setSimulateUnknownLength(boolean)(boolean simulateUnknownLength)` When set, `https://developer.android.com/reference/androidx/media3/test/utils/FakeDataSource#open(androidx.media3.datasource.DataSpec)` will behave as though the source is unable to determine the length of the underlying data. |

## Public fields

### uri

```
public final @Nullable Uri uri
```

Uri of the data or null if this is the default FakeData.

## Public methods

### appendReadAction

```
@CanIgnoreReturnValue
public FakeDataSet.FakeData appendReadAction(Runnable action)
```

Appends an action.

### appendReadData

```
@CanIgnoreReturnValue
public FakeDataSet.FakeData appendReadData(byte[] data)
```

Appends to the underlying data.

### appendReadData

```
@CanIgnoreReturnValue
public FakeDataSet.FakeData appendReadData(int length)
```

Appends a data segment of the specified length. No actual data is available and the `https://developer.android.com/reference/androidx/media3/test/utils/FakeDataSource` will perform no copy operations when this data is read.

### appendReadError

```
@CanIgnoreReturnValue
public FakeDataSet.FakeData appendReadError(IOException exception)
```

Appends an error in the underlying data.

### endData

```
public FakeDataSet endData()
```

Returns the `https://developer.android.com/reference/androidx/media3/test/utils/FakeDataSet` this FakeData belongs to.

### getData

```
public byte[] getData()
```

Returns the whole data added by `https://developer.android.com/reference/androidx/media3/test/utils/FakeDataSet.FakeData#appendReadData(byte[])`.

### getSegments

```
public List<FakeDataSet.FakeData.Segment> getSegments()
```

Returns the list of `https://developer.android.com/reference/androidx/media3/test/utils/FakeDataSet.FakeData.Segment`s.

### isSimulatingUnknownLength

```
public boolean isSimulatingUnknownLength()
```

Returns whether unknown length is simulated

### setSimulateUnknownLength

```
@CanIgnoreReturnValue
public FakeDataSet.FakeData setSimulateUnknownLength(boolean simulateUnknownLength)
```

When set, `https://developer.android.com/reference/androidx/media3/test/utils/FakeDataSource#open(androidx.media3.datasource.DataSpec)` will behave as though the source is unable to determine the length of the underlying data. Hence the return value will always be equal to the `https://developer.android.com/reference/androidx/media3/datasource/DataSpec#length()` of the argument, including the case where the length is equal to `https://developer.android.com/reference/androidx/media3/common/C#LENGTH_UNSET()`.