Top Description Inners Fields Methods
org.eclipse.jetty.io

public Interface RetainableByteBuffer

extends Retainable
Known Direct Implementers
org.eclipse.jetty.io.RetainableByteBuffer.Wrapper, org.eclipse.jetty.io.internal.NonRetainableByteBuffer, org.eclipse.jetty.io.AbstractRetainableByteBuffer
Imports
java.nio.ByteBuffer, org.eclipse.jetty.io.internal.NonRetainableByteBuffer, org.eclipse.jetty.util.BufferUtil

A pooled ByteBuffer which maintains a reference count that is incremented with retain() and decremented with release().

The ByteBuffer is released to a ByteBufferPool when release() is called one more time than retain(); in such case, the call to release() returns true.

A RetainableByteBuffer can either be:

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
public static final RetainableByteBuffer
EMPTY

A Zero-capacity, non-retainable RetainableByteBuffer.

Method Summary

Modifier and TypeMethod and Description
public default int

Returns:

the ByteBuffer capacity
capacity
()

public default void
public ByteBuffer

Returns:

the wrapped, not null, ByteBuffer
getByteBuffer
()

Get the wrapped, not null, ByteBuffer.

public default boolean

Returns:

whether the ByteBuffer has remaining bytes
hasRemaining
()

public default boolean

Returns:

whether the ByteBuffer is direct
isDirect
()

public boolean

Returns:

whether this instance is retained
isRetained
()

public default int

Returns:

the number of remaining bytes in the ByteBuffer
remaining
()

public static RetainableByteBuffer

Returns:

a non-retainable RetainableByteBuffer
wrap
(ByteBuffer
the ByteBuffer to wrap
byteBuffer
)

Returns a non-retainable RetainableByteBuffer that wraps the given ByteBuffer.

public static RetainableByteBuffer

Returns:

a RetainableByteBuffer
wrap
(ByteBuffer
the ByteBuffer to wrap
byteBuffer
,
Retainable
the associated Retainable.
retainable
)

Returns a RetainableByteBuffer that wraps the given ByteBuffer and Retainable.

Inherited from org.eclipse.jetty.io.Retainable:
canRetainreleaseretain

Field Detail

EMPTYback to summary
public static final RetainableByteBuffer EMPTY

A Zero-capacity, non-retainable RetainableByteBuffer.

Method Detail

capacityback to summary
public default int capacity()
Returns:int

the ByteBuffer capacity

clearback to summary
public default void clear()
See Also
BufferUtil#clear(ByteBuffer)
getByteBufferback to summary
public ByteBuffer getByteBuffer()

Get the wrapped, not null, ByteBuffer.

Returns:ByteBuffer

the wrapped, not null, ByteBuffer

hasRemainingback to summary
public default boolean hasRemaining()
Returns:boolean

whether the ByteBuffer has remaining bytes

isDirectback to summary
public default boolean isDirect()
Returns:boolean

whether the ByteBuffer is direct

isRetainedback to summary
public boolean isRetained()
Returns:boolean

whether this instance is retained

See Also
ReferenceCounter#isRetained()
remainingback to summary
public default int remaining()
Returns:int

the number of remaining bytes in the ByteBuffer

wrapback to summary
public static RetainableByteBuffer wrap(ByteBuffer byteBuffer)

Returns a non-retainable RetainableByteBuffer that wraps the given ByteBuffer.

Use this method to wrap user-provided ByteBuffers, or ByteBuffers that hold constant bytes, to make them look like RetainableByteBuffers.

The returned RetainableByteBuffer canRetain() method always returns false.

RetainableByteBuffers returned by this method are not suitable to be wrapped in other Retainable implementations that may delegate calls to retain().

Parameters
byteBuffer:ByteBuffer

the ByteBuffer to wrap

Returns:RetainableByteBuffer

a non-retainable RetainableByteBuffer

See Also
ByteBufferPool.NonPooling
wrapback to summary
public static RetainableByteBuffer wrap(ByteBuffer byteBuffer, Retainable retainable)

Returns a RetainableByteBuffer that wraps the given ByteBuffer and Retainable.

Parameters
byteBuffer:ByteBuffer

the ByteBuffer to wrap

retainable:Retainable

the associated Retainable.

Returns:RetainableByteBuffer

a RetainableByteBuffer

See Also
ByteBufferPool.NonPooling
org.eclipse.jetty.io back to summary

public Class RetainableByteBuffer.Wrapper

extends Wrapper
implements RetainableByteBuffer
Class Inheritance
All Implemented Interfaces
org.eclipse.jetty.io.RetainableByteBuffer, org.eclipse.jetty.io.Retainable
Known Direct Subclasses
org.eclipse.jetty.io.ArrayByteBufferPool.Tracking.Buffer

A wrapper for RetainableByteBuffer instances

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public int
public void
public ByteBuffer
getByteBuffer()

Implements org.eclipse.jetty.io.RetainableByteBuffer.getByteBuffer.

Get the wrapped, not null, ByteBuffer.
public RetainableByteBuffer
public boolean
public boolean
public boolean
public int
Inherited from org.eclipse.jetty.io.Retainable.Wrapper:
canRetainreleaseretaintoString

Constructor Detail

Wrapperback to summary
public Wrapper(RetainableByteBuffer wrapped)

Method Detail

capacityback to summary
public int capacity()

Overrides default org.eclipse.jetty.io.RetainableByteBuffer.capacity.

Returns:int

Doc from org.eclipse.jetty.io.RetainableByteBuffer.capacity.

the ByteBuffer capacity

Annotations
@Override
clearback to summary
public void clear()

Overrides default org.eclipse.jetty.io.RetainableByteBuffer.clear.

Annotations
@Override
getByteBufferback to summary
public ByteBuffer getByteBuffer()

Implements org.eclipse.jetty.io.RetainableByteBuffer.getByteBuffer.

Doc from org.eclipse.jetty.io.RetainableByteBuffer.getByteBuffer.

Get the wrapped, not null, ByteBuffer.

Returns:ByteBuffer

the wrapped, not null, ByteBuffer

Annotations
@Override
getWrappedback to summary
public RetainableByteBuffer getWrapped()

Overrides org.eclipse.jetty.io.Retainable.Wrapper.getWrapped.

hasRemainingback to summary
public boolean hasRemaining()

Overrides default org.eclipse.jetty.io.RetainableByteBuffer.hasRemaining.

Returns:boolean

Doc from org.eclipse.jetty.io.RetainableByteBuffer.hasRemaining.

whether the ByteBuffer has remaining bytes

Annotations
@Override
isDirectback to summary
public boolean isDirect()

Overrides default org.eclipse.jetty.io.RetainableByteBuffer.isDirect.

Returns:boolean

Doc from org.eclipse.jetty.io.RetainableByteBuffer.isDirect.

whether the ByteBuffer is direct

Annotations
@Override
isRetainedback to summary
public boolean isRetained()

Implements org.eclipse.jetty.io.RetainableByteBuffer.isRetained.

Returns:boolean

Doc from org.eclipse.jetty.io.RetainableByteBuffer.isRetained.

whether this instance is retained

Annotations
@Override
remainingback to summary
public int remaining()

Overrides default org.eclipse.jetty.io.RetainableByteBuffer.remaining.

Returns:int

Doc from org.eclipse.jetty.io.RetainableByteBuffer.remaining.

the number of remaining bytes in the ByteBuffer

Annotations
@Override