Class RetainableByteBuffer.EmptyRetainableByteBuffer
java.lang.Object
org.eclipse.jetty.io.RetainableByteBuffer.EmptyRetainableByteBuffer
- All Implemented Interfaces:
Retainable
,RetainableByteBuffer
- Enclosing interface:
RetainableByteBuffer
public static class RetainableByteBuffer.EmptyRetainableByteBuffer
extends Object
implements RetainableByteBuffer
A
RetainableByteBuffer
that is empty and not retainable.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.eclipse.jetty.io.Retainable
Retainable.ReferenceCounter
Nested classes/interfaces inherited from interface org.eclipse.jetty.io.RetainableByteBuffer
RetainableByteBuffer.Abstract, RetainableByteBuffer.DynamicCapacity, RetainableByteBuffer.EmptyRetainableByteBuffer, RetainableByteBuffer.FixedCapacity, RetainableByteBuffer.Mutable, RetainableByteBuffer.NonRetainableByteBuffer, RetainableByteBuffer.Pooled, RetainableByteBuffer.Wrapper
-
Field Summary
Fields inherited from interface org.eclipse.jetty.io.Retainable
NON_RETAINABLE
Fields inherited from interface org.eclipse.jetty.io.RetainableByteBuffer
EMPTY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
copy()
Creates a deep copy of this RetainableByteBuffer that is entirely independentGet the wrapped, notnull
,ByteBuffer
.boolean
Check if the underlying implementation is mutable.slice()
Get a slice of the buffer.slice
(long length) Get a partial slice of the buffer.take()
Take the contents of this buffer, leaving it clear.byte[]
Take the contents of this buffer, leaving it clear and independent.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.eclipse.jetty.io.Retainable
canRetain, getRetained, isRetained, release, retain
-
Constructor Details
-
EmptyRetainableByteBuffer
public EmptyRetainableByteBuffer()
-
-
Method Details
-
getByteBuffer
Description copied from interface:RetainableByteBuffer
Get the wrapped, notnull
,ByteBuffer
.If the implementation contains multiple buffers, they are coalesced to a single buffer before being returned. If the content is too large for a single
ByteBuffer
, then the content should be access withRetainableByteBuffer.writeTo(Content.Sink, boolean)
.- Specified by:
getByteBuffer
in interfaceRetainableByteBuffer
- Returns:
- the wrapped, not
null
,ByteBuffer
-
isMutable
public boolean isMutable()Description copied from interface:RetainableByteBuffer
Check if the underlying implementation is mutable. Note that the immutableRetainableByteBuffer
API may be backed by a mutableByteBuffer
or theRetainableByteBuffer.Mutable
API may be backed by an immutableByteBuffer
.- Specified by:
isMutable
in interfaceRetainableByteBuffer
- Returns:
- whether this buffers implementation is mutable
- See Also:
-
copy
Description copied from interface:RetainableByteBuffer
Creates a deep copy of this RetainableByteBuffer that is entirely independent- Specified by:
copy
in interfaceRetainableByteBuffer
- Returns:
- A copy of this RetainableByteBuffer
-
clear
public void clear()- Specified by:
clear
in interfaceRetainableByteBuffer
- See Also:
-
slice
Description copied from interface:RetainableByteBuffer
Get a slice of the buffer.- Specified by:
slice
in interfaceRetainableByteBuffer
- Returns:
- A sliced
RetainableByteBuffer
sharing this buffers data and reference count, but with independent position. The buffer isretained
by this call. - See Also:
-
slice
Description copied from interface:RetainableByteBuffer
Get a partial slice of the buffer. This is equivalent toRetainableByteBuffer.slice()
.RetainableByteBuffer.limit(long)
, but may be implemented more efficiently.- Specified by:
slice
in interfaceRetainableByteBuffer
- Parameters:
length
- The number of bytes to slice, which may beyond the limit and less than the capacity, in which case it will ensure some spare capacity in the slice.- Returns:
- A sliced
RetainableByteBuffer
sharing the firstlength
bytes of this buffers data and reference count, but with independent position. The buffer isretained
by this call.
-
take
Description copied from interface:RetainableByteBuffer
Take the contents of this buffer, leaving it clear.- Specified by:
take
in interfaceRetainableByteBuffer
- Returns:
- A buffer with the contents of this buffer, avoiding copies if possible.
- See Also:
-
takeByteArray
public byte[] takeByteArray()Description copied from interface:RetainableByteBuffer
Take the contents of this buffer, leaving it clear and independent.- Specified by:
takeByteArray
in interfaceRetainableByteBuffer
- Returns:
- A possibly newly allocated array with the contents of this buffer, avoiding copies if possible.
-
toDetailString
- Specified by:
toDetailString
in interfaceRetainableByteBuffer
- Returns:
- A string showing the info and detail about this buffer, as well as a summary of the contents
-