Interface RetainableByteBuffer.Mutable
- All Superinterfaces:
 Retainable, RetainableByteBuffer
- All Known Implementing Classes:
 AbstractRetainableByteBuffer, ArrayByteBufferPool.Tracking.TrackedBuffer, RetainableByteBuffer.Abstract, RetainableByteBuffer.DynamicCapacity, RetainableByteBuffer.FixedCapacity, RetainableByteBuffer.NonRetainableByteBuffer, RetainableByteBuffer.Pooled, RetainableByteBuffer.Wrapper
- Enclosing interface:
 RetainableByteBuffer
Extended 
RetainableByteBuffer API with mutator methods.
The mutator methods come in the following styles:
putmethods are used for putting raw bytes into the buffer and are similar toByteBuffer.put(byte)etc.Putmethods may be used in fluent style.addmethods are used for handing over an external buffer to be managed by this buffer. External buffers are passed by reference and the caller will not longer manage the added buffer.Addmethods may be used in fluent style.appendmethods are used for handing over the content of a buffer to be included in this buffer. The caller may still use the passed buffer and is responsible for eventually releasing it.
- 
Nested Class Summary
Nested classes/interfaces inherited from interface Retainable
Retainable.ReferenceCounterNested classes/interfaces inherited from interface RetainableByteBuffer
RetainableByteBuffer.Abstract, RetainableByteBuffer.DynamicCapacity, RetainableByteBuffer.EmptyRetainableByteBuffer, RetainableByteBuffer.FixedCapacity, RetainableByteBuffer.Mutable, RetainableByteBuffer.NonRetainableByteBuffer, RetainableByteBuffer.Pooled, RetainableByteBuffer.Wrapper - 
Field Summary
Fields inherited from interface Retainable
NON_RETAINABLEFields inherited from interface RetainableByteBuffer
EMPTY - 
Method Summary
Modifier and TypeMethodDescriptionadd(ByteBuffer bytes) Add the passedByteBufferto this buffer, growing this buffer if necessary and possible.add(RetainableByteBuffer bytes) Add the passedRetainableByteBufferto this buffer, growing this buffer if necessary and possible.booleanappend(ByteBuffer bytes) Copies the contents of the given byte buffer to the end of this buffer, growing this buffer if necessary and possible.booleanappend(RetainableByteBuffer bytes) Retain or copy the contents of the given retainable byte buffer to the end of this buffer, growing this buffer if necessary and possible.put(byte b) Put abyteto the buffer, growing this buffer if necessary and possible.default RetainableByteBuffer.Mutableput(byte[] bytes) Put abytearray to the buffer, growing this buffer if necessary and possible.put(byte[] bytes, int offset, int length) Put abytearray to the buffer, growing this buffer if necessary and possible.put(long index, byte b) Put abyteto the buffer at a given index.putInt(int i) Put anintto the buffer, growing this buffer if necessary and possible.putLong(long l) Put alongto the buffer, growing this buffer if necessary and possible.putShort(short s) Put ashortto the buffer, growing this buffer if necessary and possible.Methods inherited from interface Retainable
canRetain, getRetained, isRetained, release, retainMethods inherited from interface RetainableByteBuffer
appendTo, appendTo, asMutable, capacity, clear, copy, get, get, get, getByteBuffer, hasRemaining, isDirect, isEmpty, isFull, isMutable, limit, maxSize, putTo, remaining, size, skip, slice, slice, space, take, take, takeByteArray, takeFrom, toDetailString, writeTo, writeTo 
- 
Method Details
- 
add
RetainableByteBuffer.Mutable add(ByteBuffer bytes) throws ReadOnlyBufferException, BufferOverflowException Add the passedByteBufferto this buffer, growing this buffer if necessary and possible. The sourceByteBufferis passed by reference and the caller gives up "ownership", so implementations of this method may choose to avoid copies by keeping a reference to the buffer.- Parameters:
 bytes- the byte buffer to add, which is passed by reference and is not necessarily consumed by the add.- Returns:
 thisbuffer.- Throws:
 ReadOnlyBufferException- if this buffer is read only.BufferOverflowException- if this buffer cannot fit the byte- See Also:
 
 - 
add
RetainableByteBuffer.Mutable add(RetainableByteBuffer bytes) throws ReadOnlyBufferException, BufferOverflowException Add the passedRetainableByteBufferto this buffer, growing this buffer if necessary and possible. The sourceRetainableByteBufferis passed by reference and the caller gives up ownership, so implementations of this method may avoid copies by keeping a reference to the buffer. Unlike the similarappend(RetainableByteBuffer)and contrary to the general rules ofRetainable, implementations of this method need not callRetainable.retain()if keeping a reference, but they must ultimately callRetainable.release()the passed buffer. Callers should useaddrather thanappend(RetainableByteBuffer)if they already have an obligation to release the buffer and wish to delegate that obligation to this buffer.- Parameters:
 bytes- the byte buffer to add, which is passed by reference and is not necessarily consumed by the add.- Returns:
 thisbuffer.- Throws:
 ReadOnlyBufferException- if this buffer is read only.BufferOverflowException- if this buffer cannot fit the byte
 - 
append
Copies the contents of the given byte buffer to the end of this buffer, growing this buffer if necessary and possible.- Parameters:
 bytes- the byte buffer to copy from, which is consumed.- Returns:
 - true if all bytes of the given buffer were copied, false otherwise.
 - Throws:
 ReadOnlyBufferException- if this buffer is read only.- See Also:
 
 - 
append
Retain or copy the contents of the given retainable byte buffer to the end of this buffer, growing this buffer if necessary and possible. The implementation will heuristically decide to retain or copy the contents Unlike the similaradd(RetainableByteBuffer), implementations of this method mustRetainable.retain()the passed buffer if they keep a reference to it.- Parameters:
 bytes- the retainable byte buffer to copy from, which is consumed.- Returns:
 - true if all bytes of the given buffer were copied, false otherwise.
 - Throws:
 ReadOnlyBufferException- if this buffer is read only.- See Also:
 
 - 
put
Put abyteto the buffer, growing this buffer if necessary and possible.- Parameters:
 b- thebyteto put- Returns:
 thisbuffer.- Throws:
 ReadOnlyBufferException- if this buffer is read only.BufferOverflowException- if this buffer cannot fit the byte
 - 
putShort
Put ashortto the buffer, growing this buffer if necessary and possible.- Parameters:
 s- theshortto put- Returns:
 thisbuffer.- Throws:
 ReadOnlyBufferException- if this buffer is read only.BufferOverflowException- if this buffer cannot fit the byte
 - 
putInt
Put anintto the buffer, growing this buffer if necessary and possible.- Parameters:
 i- theintto put- Returns:
 thisbuffer.- Throws:
 ReadOnlyBufferException- if this buffer is read onlyBufferOverflowException- if this buffer cannot fit the byte
 - 
putLong
Put alongto the buffer, growing this buffer if necessary and possible.- Parameters:
 l- thelongto put- Returns:
 thisbuffer.- Throws:
 ReadOnlyBufferException- if this buffer is read onlyBufferOverflowException- if this buffer cannot fit the byte
 - 
put
Put abytearray to the buffer, growing this buffer if necessary and possible.- Parameters:
 bytes- thebytearray to putoffset- the offset into the arraylength- the length in bytes to put- Returns:
 thisbuffer.- Throws:
 ReadOnlyBufferException- if this buffer is read onlyBufferOverflowException- if this buffer cannot fit the byte
 - 
put
Put abytearray to the buffer, growing this buffer if necessary and possible.- Parameters:
 bytes- thebytearray to put- Returns:
 thisbuffer.- Throws:
 ReadOnlyBufferException- if this buffer is read onlyBufferOverflowException- if this buffer cannot fit the byte
 - 
put
Put abyteto the buffer at a given index.- Parameters:
 index- The index relative to the current start of unconsumed data in the buffer.b- thebyteto put- Returns:
 thisbuffer.- Throws:
 ReadOnlyBufferException- if this buffer is read only.BufferOverflowException- if this buffer cannot fit the byte
 
 -