Package org.springframework.core.io.buffer

# Class LimitedDataBufferList

java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.ArrayList<DataBuffer>
org.springframework.core.io.buffer.LimitedDataBufferList

All Implemented Interfaces:
  `Serializable`, `Cloneable`, `Iterable<DataBuffer>`, `Collection<DataBuffer>`, `List<DataBuffer>`, `RandomAccess`

public class LimitedDataBufferList extends ArrayList<DataBuffer>
Custom `List` to collect data buffers with and enforce a limit on the total number of bytes buffered. For use with "collect" or other buffering operators in declarative APIs, for example, `Flux`.

Adding elements increases the byte count and if the limit is exceeded, `DataBufferLimitException` is raised. `clear()` resets the count. Remove and set are not supported.

Note: This class does not automatically release the buffers it contains. It is usually preferable to use hooks such as `Flux.doOnDiscard(java.lang.Class<R>, java.util.function.Consumer<? super R>)` that also take care of cancel and error signals, or otherwise `releaseAndClear()` can be used.

Since:
  5.1.11
Author:
  Rossen Stoyanchev
See Also:
  - Serialized Form

## Field Summary

### Fields inherited from class java.util.AbstractList

`modCount`

## Constructor Summary

Constructors
Constructor
Description
`LimitedDataBufferList(int maxByteCount)`

## Method Summary

Modifier and Type
Method
Description
`void`
`add(int index, DataBuffer buffer)`
`boolean`
`add(DataBuffer buffer)`
`boolean`
`addAll(int index, Collection<? extends DataBuffer> collection)`
`boolean`
`addAll(Collection<? extends DataBuffer> collection)`
`void`
`clear()`
`void`
`releaseAndClear()`
Shortcut to `release` all data buffers and then `clear()`.
`DataBuffer`
`remove(int index)`
`boolean`
`remove(Object o)`
`boolean`
`removeAll(Collection<?> c)`
`boolean`
`removeIf(Predicate<? super DataBuffer> filter)`
`protected void`
`removeRange(int fromIndex, int toIndex)`
`DataBuffer`
`set(int index, DataBuffer element)`

### Methods inherited from class java.util.ArrayList

`clone, contains, ensureCapacity, equals, forEach, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, replaceAll, retainAll, size, sort, spliterator, subList, toArray, toArray, trimToSize`

### Methods inherited from class java.util.AbstractCollection

`containsAll, toString`

### Methods inherited from class java.lang.Object

`finalize, getClass, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface java.util.Collection

`parallelStream, stream, toArray`

### Methods inherited from interface java.util.List

`containsAll`

## Constructor Details

### LimitedDataBufferList

public LimitedDataBufferList(int maxByteCount)

## Method Details

### add

public boolean add(DataBuffer buffer)

Specified by:
  `add` in interface `Collection<DataBuffer>`
Specified by:
  `add` in interface `List<DataBuffer>`
Overrides:
  `add` in class `ArrayList<DataBuffer>`

### add

public void add(int index, DataBuffer buffer)

Specified by:
  `add` in interface `List<DataBuffer>`
Overrides:
  `add` in class `ArrayList<DataBuffer>`

### addAll

public boolean addAll(Collection<? extends DataBuffer> collection)

Specified by:
  `addAll` in interface `Collection<DataBuffer>`
Specified by:
  `addAll` in interface `List<DataBuffer>`
Overrides:
  `addAll` in class `ArrayList<DataBuffer>`

### addAll

public boolean addAll(int index, Collection<? extends DataBuffer> collection)

Specified by:
  `addAll` in interface `List<DataBuffer>`
Overrides:
  `addAll` in class `ArrayList<DataBuffer>`

### remove

public DataBuffer remove(int index)

Specified by:
  `remove` in interface `List<DataBuffer>`
Overrides:
  `remove` in class `ArrayList<DataBuffer>`

### remove

public boolean remove(Object o)

Specified by:
  `remove` in interface `Collection<DataBuffer>`
Specified by:
  `remove` in interface `List<DataBuffer>`
Overrides:
  `remove` in class `ArrayList<DataBuffer>`

### removeRange

protected void removeRange(int fromIndex, int toIndex)

Overrides:
  `removeRange` in class `ArrayList<DataBuffer>`

### removeAll

public boolean removeAll(Collection<?> c)

Specified by:
  `removeAll` in interface `Collection<DataBuffer>`
Specified by:
  `removeAll` in interface `List<DataBuffer>`
Overrides:
  `removeAll` in class `ArrayList<DataBuffer>`

### removeIf

public boolean removeIf(Predicate<? super DataBuffer> filter)

Specified by:
  `removeIf` in interface `Collection<DataBuffer>`
Overrides:
  `removeIf` in class `ArrayList<DataBuffer>`

### set

public DataBuffer set(int index, DataBuffer element)

Specified by:
  `set` in interface `List<DataBuffer>`
Overrides:
  `set` in class `ArrayList<DataBuffer>`

### clear

public void clear()

Specified by:
  `clear` in interface `Collection<DataBuffer>`
Specified by:
  `clear` in interface `List<DataBuffer>`
Overrides:
  `clear` in class `ArrayList<DataBuffer>`

### releaseAndClear

public void releaseAndClear()
Shortcut to `release` all data buffers and then `clear()`.