# AbstractDataBuffer


```
public abstract class AbstractDataBuffer<T> implements DataBuffer
```

<br />

*** ** * ** ***

Default implementation of DataBuffer. An `AbstractDataBuffer` wraps data provided across the binder from Google Play services.

## Summary

| ### Public methods |
|---|---|
| `final void` | `https://developers.google.com/android/reference/com/google/android/gms/common/data/AbstractDataBuffer#close()()` Releases the data buffer, for use in try-with-resources. |
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull.html T` | `https://developers.google.com/android/reference/com/google/android/gms/common/data/AbstractDataBuffer#get(int)(int position)` Get the item at the specified position. |
| `int` | `https://developers.google.com/android/reference/com/google/android/gms/common/data/AbstractDataBuffer#getCount()()` |
| `boolean` | `[isClosed](https://developers.google.com/android/reference/com/google/android/gms/common/data/AbstractDataBuffer#isClosed())()` **This method is deprecated.** release and close are idempotent, and so is safe to call multiple times <br /> |
| `https://developer.android.com/reference/java/util/Iterator.html<T>` | `https://developers.google.com/android/reference/com/google/android/gms/common/data/AbstractDataBuffer#iterator()()` |
| `void` | `https://developers.google.com/android/reference/com/google/android/gms/common/data/AbstractDataBuffer#release()()` Releases resources used by the buffer. |
| `https://developer.android.com/reference/java/util/Iterator.html<T>` | `https://developers.google.com/android/reference/com/google/android/gms/common/data/AbstractDataBuffer#singleRefIterator()()` In order to use this you should correctly override `https://developers.google.com/android/reference/com/google/android/gms/common/data/DataBufferRef#setDataRow(int)` in your `https://developers.google.com/android/reference/com/google/android/gms/common/data/DataBufferRef` implementation. |

### Inherited methods

From [java.io.Closeable](https://developer.android.com/reference/java/io/Closeable.html) `abstract void` `https://developer.android.com/reference/java/io/Closeable.html#close()()` From [java.lang.Iterable](https://developer.android.com/reference/java/lang/Iterable.html) `void` `https://developer.android.com/reference/java/lang/Iterable.html#forEach(java.util.function.Consumer&lt;? super T&gt;)(https://developer.android.com/reference/java/util/function/Consumer.html<T> p)` `abstract https://developer.android.com/reference/java/util/Iterator.html<T>` `https://developer.android.com/reference/java/lang/Iterable.html#iterator()()` `https://developer.android.com/reference/java/util/Spliterator.html<T>` `https://developer.android.com/reference/java/lang/Iterable.html#spliterator()()`

## Public methods

### close

```
public final void close()
```

Releases the data buffer, for use in try-with-resources.

Both close and release shall have identical semantics, and are idempotent.

### get

```
public abstract @NonNull T get(int position)
```

Get the item at the specified position. Note that the objects returned from subsequent invocations of this method for the same position may not be identical objects, but will be equal in value. In other words:

`buffer.get(i) == buffer.get(i)` may return false.

`buffer.get(i).equals(buffer.get(i))` will return true.

| Parameters |
|---|---|
| `int position` | The position of the item to retrieve. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html T` | the item at `position` in this buffer. |

### getCount

```
public int getCount()
```

### isClosed

```
public boolean [isClosed](https://developers.google.com/android/reference/com/google/android/gms/common/data/AbstractDataBuffer#isClosed())()
```

> [!CAUTION]
> **This method is deprecated.**   
>
> release and close are idempotent, and so is safe to call multiple times

### iterator

```
public Iterator<T> iterator()
```

### release

```
public void release()
```

Releases resources used by the buffer. This method is idempotent.

### singleRefIterator

```
public Iterator<T> singleRefIterator()
```

In order to use this you should correctly override `https://developers.google.com/android/reference/com/google/android/gms/common/data/DataBufferRef#setDataRow(int)` in your `https://developers.google.com/android/reference/com/google/android/gms/common/data/DataBufferRef` implementation. Be careful: there will be single `https://developers.google.com/android/reference/com/google/android/gms/common/data/DataBufferRef` while iterating. If you are not sure - DO NOT USE this iterator.

| See also |
|---|---|
| `https://developers.google.com/android/reference/com/google/android/gms/common/data/SingleRefDataBufferIterator` |   |