Class RetainableByteBuffer.FixedCapacity
java.lang.Object
org.eclipse.jetty.io.Retainable.Wrapper
org.eclipse.jetty.io.RetainableByteBuffer.Abstract
org.eclipse.jetty.io.RetainableByteBuffer.FixedCapacity
- All Implemented Interfaces:
 Retainable, RetainableByteBuffer, RetainableByteBuffer.Mutable
- Direct Known Subclasses:
 AbstractRetainableByteBuffer, ArrayByteBufferPool.Tracking.TrackedBuffer, RetainableByteBuffer.NonRetainableByteBuffer, RetainableByteBuffer.Pooled
- Enclosing interface:
 RetainableByteBuffer
public static class RetainableByteBuffer.FixedCapacity
extends RetainableByteBuffer.Abstract
implements RetainableByteBuffer.Mutable
- 
Nested Class Summary
Nested classes/interfaces inherited from interface Retainable
Retainable.ReferenceCounter, Retainable.WrapperNested 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 - 
Constructor Summary
ConstructorsConstructorDescriptionFixedCapacity(ByteBuffer byteBuffer) FixedCapacity(ByteBuffer byteBuffer, Retainable retainable)  - 
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.protected voidaddValueMarker(StringBuilder builder, boolean beginning) 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.Access this buffer via theRetainableByteBuffer.MutableAPI.intcapacity()voidclear()byteget(long index) Returns a byte from this RetainableByteBuffer at a specific indexGet the wrapped, notnull,ByteBuffer.booleanbooleanisDirect()voidlimit(long size) Limit this buffer's contents to the size.put(byte b) Put abyteto 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.intlongspace()Methods inherited from class RetainableByteBuffer.Abstract
addExtraStringInfo, addStringInfo, addValueString, toDetailString, toStringMethods inherited from class Retainable.Wrapper
canRetain, getRetained, getWrapped, isRetained, release, retainMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Retainable
canRetain, getRetained, isRetained, release, retainMethods inherited from interface RetainableByteBuffer
appendTo, appendTo, copy, get, get, isEmpty, isFull, isMutable, maxSize, putTo, size, skip, slice, slice, take, take, takeByteArray, takeFrom, toDetailString, writeTo, writeToMethods inherited from interface RetainableByteBuffer.Mutable
put 
- 
Constructor Details
- 
FixedCapacity
 - 
FixedCapacity
 
 - 
 - 
Method Details
- 
clear
public void clear()- Specified by:
 clearin interfaceRetainableByteBuffer- See Also:
 
 - 
space
public long space()- Specified by:
 spacein interfaceRetainableByteBuffer- Returns:
 - the number of bytes that can be added, appended or put into this buffer,
assuming it is 
mutable. 
 - 
asMutable
Description copied from interface:RetainableByteBufferAccess this buffer via theRetainableByteBuffer.MutableAPI. Note that theRetainableByteBuffer.MutableAPI may be backed by an immutableByteBuffer.- Specified by:
 asMutablein interfaceRetainableByteBuffer- Returns:
 - An 
RetainableByteBuffer.Mutablerepresentation of this buffer with same data and pointers. - See Also:
 
 - 
remaining
public int remaining()- Specified by:
 remainingin interfaceRetainableByteBuffer- Returns:
 - the number of remaining bytes in the 
ByteBuffer - See Also:
 
 - 
hasRemaining
public boolean hasRemaining()- Specified by:
 hasRemainingin interfaceRetainableByteBuffer- Returns:
 - whether the 
ByteBufferhas remaining bytes 
 - 
isDirect
public boolean isDirect()- Specified by:
 isDirectin interfaceRetainableByteBuffer- Returns:
 - whether the 
ByteBufferis direct 
 - 
capacity
public int capacity()- Specified by:
 capacityin interfaceRetainableByteBuffer- Returns:
 - the capacity
 - See Also:
 
 - 
get
Description copied from interface:RetainableByteBufferReturns a byte from this RetainableByteBuffer at a specific index- Specified by:
 getin interfaceRetainableByteBuffer- Parameters:
 index- The index relative to the current start of unconsumed data in the buffer.- Returns:
 - the byte
 - Throws:
 IndexOutOfBoundsException- if the index is too large.
 - 
limit
public void limit(long size) Description copied from interface:RetainableByteBufferLimit this buffer's contents to the size.
- Specified by:
 limitin interfaceRetainableByteBuffer- Parameters:
 size- the new size of the buffer
 - 
getByteBuffer
Description copied from interface:RetainableByteBufferGet 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:
 getByteBufferin interfaceRetainableByteBuffer- Returns:
 - the wrapped, not 
null,ByteBuffer 
 - 
append
Description copied from interface:RetainableByteBuffer.MutableCopies the contents of the given byte buffer to the end of this buffer, growing this buffer if necessary and possible.- Specified by:
 appendin interfaceRetainableByteBuffer.Mutable- 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
Description copied from interface:RetainableByteBuffer.MutableRetain 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 similarRetainableByteBuffer.Mutable.add(RetainableByteBuffer), implementations of this method mustRetainable.retain()the passed buffer if they keep a reference to it.- Specified by:
 appendin interfaceRetainableByteBuffer.Mutable- 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:
 
 - 
add
Description copied from interface:RetainableByteBuffer.MutableAdd 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.- Specified by:
 addin interfaceRetainableByteBuffer.Mutable- 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.- See Also:
 
 - 
add
Description copied from interface:RetainableByteBuffer.MutableAdd 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 similarRetainableByteBuffer.Mutable.append(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 thanRetainableByteBuffer.Mutable.append(RetainableByteBuffer)if they already have an obligation to release the buffer and wish to delegate that obligation to this buffer.- Specified by:
 addin interfaceRetainableByteBuffer.Mutable- 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.
 - 
put
Put abyteto the buffer, growing this buffer if necessary and possible.- Specified by:
 putin interfaceRetainableByteBuffer.Mutable- Parameters:
 b- thebyteto put- Returns:
 thisbuffer.- Throws:
 ReadOnlyBufferException- if this buffer is read only.BufferOverflowException- if this buffer cannot fit the byte
 - 
put
Description copied from interface:RetainableByteBuffer.MutablePut abyteto the buffer at a given index.- Specified by:
 putin interfaceRetainableByteBuffer.Mutable- Parameters:
 index- The index relative to the current start of unconsumed data in the buffer.b- thebyteto put- Returns:
 thisbuffer.
 - 
putShort
Put ashortto the buffer, growing this buffer if necessary and possible.- Specified by:
 putShortin interfaceRetainableByteBuffer.Mutable- 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.- Specified by:
 putIntin interfaceRetainableByteBuffer.Mutable- 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.- Specified by:
 putLongin interfaceRetainableByteBuffer.Mutable- 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.- Specified by:
 putin interfaceRetainableByteBuffer.Mutable- 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
 - 
addValueMarker
- Overrides:
 addValueMarkerin classRetainableByteBuffer.Abstract
 
 -