Package org.springframework.core.io.buffer

# Class JettyDataBufferFactory

java.lang.Object
org.springframework.core.io.buffer.JettyDataBufferFactory

All Implemented Interfaces:
  `DataBufferFactory`

public class JettyDataBufferFactory extends Object implements DataBufferFactory
Implementation of the `DataBufferFactory` interface that creates `JettyDataBuffer` instances.

Since:
  6.2
Author:
  Arjen Poutsma

## Constructor Summary

Constructors
Constructor
Description
`JettyDataBufferFactory()`
Creates a new `JettyDataBufferFactory` with default settings.
`JettyDataBufferFactory(boolean preferDirect)`
Creates a new `JettyDataBufferFactory`, indicating whether direct buffers should be created by `allocateBuffer()` and `allocateBuffer(int)`.
`JettyDataBufferFactory(boolean preferDirect, int defaultInitialCapacity)`
Creates a new `JettyDataBufferFactory`, indicating whether direct buffers should be created by `allocateBuffer()` and `allocateBuffer(int)`, and what the capacity is to be used for `allocateBuffer()`.

## Method Summary

Modifier and Type
Method
Description
`JettyDataBuffer`
`allocateBuffer()`
Deprecated.
`JettyDataBuffer`
`allocateBuffer(int initialCapacity)`
Allocate a data buffer of the given initial capacity.
`boolean`
`isDirect()`
Indicates whether this factory allocates direct buffers (i.e.
`JettyDataBuffer`
`join(List<? extends DataBuffer> dataBuffers)`
Return a new `DataBuffer` composed of the `dataBuffers` elements joined together.
`JettyDataBuffer`
`wrap(byte[] bytes)`
Wrap the given `byte` array in a `DataBuffer`.
`JettyDataBuffer`
`wrap(ByteBuffer byteBuffer)`
Wrap the given `ByteBuffer` in a `DataBuffer`.
`JettyDataBuffer`
`wrap(org.eclipse.jetty.io.Content.Chunk chunk)`

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

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### JettyDataBufferFactory

public JettyDataBufferFactory()
Creates a new `JettyDataBufferFactory` with default settings.

### JettyDataBufferFactory

public JettyDataBufferFactory(boolean preferDirect)
Creates a new `JettyDataBufferFactory`, indicating whether direct buffers should be created by `allocateBuffer()` and `allocateBuffer(int)`.

Parameters:
  `preferDirect` - `true` if direct buffers are to be preferred; `false` otherwise

### JettyDataBufferFactory

public JettyDataBufferFactory(boolean preferDirect, int defaultInitialCapacity)
Creates a new `JettyDataBufferFactory`, indicating whether direct buffers should be created by `allocateBuffer()` and `allocateBuffer(int)`, and what the capacity is to be used for `allocateBuffer()`.

Parameters:
  `preferDirect` - `true` if direct buffers are to be preferred; `false` otherwise

## Method Details

### allocateBuffer

@Deprecated public JettyDataBuffer allocateBuffer()
Deprecated.
Description copied from interface: `DataBufferFactory`
Allocate a data buffer of a default initial capacity. Depending on the underlying implementation and its configuration, this will be heap-based or direct buffer.

Specified by:
  `allocateBuffer` in interface `DataBufferFactory`
Returns:
  the allocated buffer

### allocateBuffer

public JettyDataBuffer allocateBuffer(int initialCapacity)
Description copied from interface: `DataBufferFactory`
Allocate a data buffer of the given initial capacity. Depending on the underlying implementation and its configuration, this will be heap-based or direct buffer.

Specified by:
  `allocateBuffer` in interface `DataBufferFactory`
Parameters:
  `initialCapacity` - the initial capacity of the buffer to allocate
Returns:
  the allocated buffer

### wrap

public JettyDataBuffer wrap(ByteBuffer byteBuffer)
Description copied from interface: `DataBufferFactory`
Wrap the given `ByteBuffer` in a `DataBuffer`. Unlike allocating, wrapping does not use new memory.

Specified by:
  `wrap` in interface `DataBufferFactory`
Parameters:
  `byteBuffer` - the NIO byte buffer to wrap
Returns:
  the wrapped buffer

### wrap

public JettyDataBuffer wrap(byte[] bytes)
Description copied from interface: `DataBufferFactory`
Wrap the given `byte` array in a `DataBuffer`. Unlike allocating, wrapping does not use new memory.

Specified by:
  `wrap` in interface `DataBufferFactory`
Parameters:
  `bytes` - the byte array to wrap
Returns:
  the wrapped buffer

### wrap

public JettyDataBuffer wrap(org.eclipse.jetty.io.Content.Chunk chunk)

### join

public JettyDataBuffer join(List<? extends DataBuffer> dataBuffers)
Description copied from interface: `DataBufferFactory`
Return a new `DataBuffer` composed of the `dataBuffers` elements joined together. Depending on the implementation, the returned buffer may be a single buffer containing all data of the provided buffers, or it may be a true composite that contains references to the buffers.

Note that the given data buffers do not have to be released, as they are released as part of the returned composite.

Specified by:
  `join` in interface `DataBufferFactory`
Parameters:
  `dataBuffers` - the data buffers to be composed
Returns:
  a buffer that is composed of the `dataBuffers` argument

### isDirect

public boolean isDirect()
Description copied from interface: `DataBufferFactory`
Indicates whether this factory allocates direct buffers (i.e. non-heap, native memory).

Specified by:
  `isDirect` in interface `DataBufferFactory`
Returns:
  `true` if this factory allocates direct buffers; `false` otherwise