Top Inners Fields Constructors Methods
org.glassfish.grizzly.memory

public final Class BuffersBuffer

extends CompositeBuffer
Class Inheritance
Imports
java.io.UnsupportedEncodingException, java.nio.BufferOverflowException, .BufferUnderflowException, .ByteBuffer, .ByteOrder, .InvalidMarkException, java.nio.charset.Charset, java.util.Arrays, org.glassfish.grizzly.Buffer, .ThreadCache, org.glassfish.grizzly.utils.ArrayUtils

Author
Alexey Stashok

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class

Field Summary

Modifier and TypeField and Description
private Buffer
private int
private boolean
private boolean
private boolean
private int[]
private Buffer[]
private int
private ByteOrder
private static final ThreadCache.CachedTypeIndex<BuffersBuffer>
private int
public static volatile boolean
protected Exception
private boolean
private boolean
private int
private int
private int
private int
private MemoryManager<E extends Buffer>
private int
private final BuffersBuffer.SetterImpl
private int
Inherited from org.glassfish.grizzly.memory.CompositeBuffer:
disposeOrder

Constructor Summary

AccessConstructor and Description
protected
BuffersBuffer(final MemoryManager<E extends Buffer> memoryManager, final Buffer[] buffers, final int buffersSize, final boolean isReadOnly)

Method Summary

Modifier and TypeMethod and Description
public boolean
public void
public boolean
public void
public BuffersBuffer
public byte[]
array()

Implements org.glassfish.grizzly.Buffer.array.

Returns the byte array that backs this buffer (optional operation).

public int
arrayOffset()

Implements org.glassfish.grizzly.Buffer.arrayOffset.

Returns the offset within this buffer's backing array of the first element of the buffer (optional operation).

public BuffersBuffer
asReadOnlyBuffer()

Implements org.glassfish.grizzly.Buffer.asReadOnlyBuffer.

Creates a new, read-only Buffer that shares this buffer's content.

public int
bulk(final CompositeBuffer.BulkOperation operation)

Implements abstract org.glassfish.grizzly.memory.CompositeBuffer.bulk.

Iterates over Buffer bytes from position() to limit() and lets BulkOperation examine/change the buffer content;

public int
bulk(final CompositeBuffer.BulkOperation operation, final int position, final int limit)

Implements abstract org.glassfish.grizzly.memory.CompositeBuffer.bulk.

Iterates over Buffer bytes from position to limit and lets BulkOperation examine/change the buffer content;

public int
capacity()

Implements org.glassfish.grizzly.Buffer.capacity.

Returns this buffer's capacity.

private void
private void
checkIndex(final int index)

private void
public BuffersBuffer
clear()

Implements org.glassfish.grizzly.Buffer.clear.

Clears this buffer.

public BuffersBuffer
compact()

Implements org.glassfish.grizzly.Buffer.compact.

Compacts this buffer  (optional operation).

public int
compareTo(Buffer that)

Implements java.lang.Comparable.compareTo.

Compares this object with the specified object for order.

public static BuffersBuffer

Returns:

BuffersBuffer
create
()

Construct BuffersBuffer.

public static BuffersBuffer
create(final MemoryManager<E extends Buffer> memoryManager)

public static BuffersBuffer
create(final MemoryManager<E extends Buffer> memoryManager, final Buffer... buffers)

public static BuffersBuffer
create(final MemoryManager<E extends Buffer> memoryManager, final Buffer[] buffers, final boolean isReadOnly)

private static BuffersBuffer
create(final MemoryManager<E extends Buffer> memoryManager, final Buffer[] buffers, final int buffersSize, final boolean isReadOnly)

private static BuffersBuffer
create(final MemoryManager<E extends Buffer> memoryManager, final Buffer[] buffers, final int buffersSize, final ByteOrder byteOrder, final boolean isReadOnly)

public void
dispose()

Implements org.glassfish.grizzly.Buffer.dispose.

Notify the allocator that the space for this Buffer is no longer needed.

public void
dumpHex(Appendable appendable)

Implements org.glassfish.grizzly.Buffer.dumpHex.

Generate a hex dump of this Buffer's content.

public BuffersBuffer
duplicate()

Implements org.glassfish.grizzly.Buffer.duplicate.

Creates a new Buffer that shares this buffer's content.

private BuffersBuffer
private void
ensureBuffersCapacity(final int newElementsNum)

public boolean
equals(Object obj)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

private void
fillByteBuffer(final ByteBuffer bb, final ByteBufferArray array)

public BuffersBuffer
flip()

Implements org.glassfish.grizzly.Buffer.flip.

Flips this buffer.

public byte
get()

Implements org.glassfish.grizzly.Buffer.get.

Relative get method.

public byte
get(final int index)

Implements org.glassfish.grizzly.Buffer.get.

Absolute get method.

public BuffersBuffer
get(final byte[] dst)

Implements org.glassfish.grizzly.Buffer.get.

Relative bulk get method.

public BuffersBuffer
get(final byte[] dst, int offset, int length)

Implements org.glassfish.grizzly.Buffer.get.

Relative bulk get method.

public BuffersBuffer
get(final ByteBuffer dst)

Implements org.glassfish.grizzly.Buffer.get.

Relative bulk get method.

public BuffersBuffer
get(final ByteBuffer dst, int offset, int length)

Implements org.glassfish.grizzly.Buffer.get.

Relative bulk get method.

public char
getChar()

Implements org.glassfish.grizzly.Buffer.getChar.

Relative get method for reading a char value.

public char
getChar(final int index)

Implements org.glassfish.grizzly.Buffer.getChar.

Absolute get method for reading a char value.

public double
getDouble()

Implements org.glassfish.grizzly.Buffer.getDouble.

Relative get method for reading a double value.

public double
getDouble(int index)

Implements org.glassfish.grizzly.Buffer.getDouble.

Absolute get method for reading a double value.

public float
getFloat()

Implements org.glassfish.grizzly.Buffer.getFloat.

Relative get method for reading a float value.

public float
getFloat(int index)

Implements org.glassfish.grizzly.Buffer.getFloat.

Absolute get method for reading a float value.

public int
getInt()

Implements org.glassfish.grizzly.Buffer.getInt.

Relative get method for reading an int value.

public int
getInt(final int index)

Implements org.glassfish.grizzly.Buffer.getInt.

Absolute get method for reading an int value.

public long
getLong()

Implements org.glassfish.grizzly.Buffer.getLong.

Relative get method for reading a long value.

public long
getLong(final int index)

Implements org.glassfish.grizzly.Buffer.getLong.

Absolute get method for reading a long value.

public short
getShort()

Implements org.glassfish.grizzly.Buffer.getShort.

Relative get method for reading a short value.

public short
getShort(final int index)

Implements org.glassfish.grizzly.Buffer.getShort.

Absolute get method for reading a short value.

public boolean
hasArray()

Implements org.glassfish.grizzly.Buffer.hasArray.

Tells whether or not this buffer is backed by an accessible byte array.

public int

Returns:

The current hash code of this buffer
hashCode
()

Overrides java.lang.Object.hashCode.

Returns the current hash code of this buffer.

public boolean
hasRemaining()

Implements org.glassfish.grizzly.Buffer.hasRemaining.

Tells whether there are any elements between the current position and the limit.

private void
initBuffers(final Buffer[] buffers, final int bufferSize)

public boolean
public boolean
isDirect()

Implements org.glassfish.grizzly.Buffer.isDirect.

Tells whether or not this buffer is direct.

public boolean
isExternal()

Implements org.glassfish.grizzly.asyncqueue.WritableMessage.isExternal.

Returns true if the message represents an external resource (for example org.glassfish.grizzly.FileTransfer), which is not loaded in memory.

public boolean
isReadOnly()

Implements org.glassfish.grizzly.Buffer.isReadOnly.

Tells whether or not this buffer is read-only.

public int
limit()

Implements org.glassfish.grizzly.Buffer.limit.

Returns this buffer's limit.

public BuffersBuffer
limit(final int newLimit)

Implements org.glassfish.grizzly.Buffer.limit.

Sets this buffer's limit.

private char
makeCharB(int index)

private char
makeCharL(int index)

private int
makeIntB(int index)

private int
makeIntL(int index)

private long
makeLongB(int index)

private long
makeLongL(int index)

private short
makeShortB(int index)

private short
makeShortL(int index)

public BuffersBuffer
mark()

Implements org.glassfish.grizzly.Buffer.mark.

Sets this buffer's mark at its position.

public ByteOrder
order()

Implements org.glassfish.grizzly.Buffer.order.

Retrieves this buffer's byte order.

public BuffersBuffer
order(final ByteOrder bo)

Implements org.glassfish.grizzly.Buffer.order.

Modifies this buffer's byte order.

public int
position()

Implements org.glassfish.grizzly.Buffer.position.

Returns this buffer's position.

public BuffersBuffer
position(final int newPosition)

Implements org.glassfish.grizzly.Buffer.position.

Sets this buffer's position.

public BuffersBuffer
prepend(final Buffer buffer)

Implements abstract org.glassfish.grizzly.memory.CompositeBuffer.prepend.

Implements org.glassfish.grizzly.Buffer.prepend.

Prepend data from header.position() to header.limit() to the current buffer.

public BuffersBuffer
put(byte b)

Implements org.glassfish.grizzly.Buffer.put.

Relative put method  (optional operation).

public BuffersBuffer
put(int index, byte b)

Implements org.glassfish.grizzly.Buffer.put.

Absolute put method  (optional operation).

public BuffersBuffer
put(final byte[] src)

Implements org.glassfish.grizzly.Buffer.put.

Relative bulk put method  (optional operation).

public BuffersBuffer
put(final byte[] src, int offset, int length)

Implements org.glassfish.grizzly.Buffer.put.

Relative bulk put method  (optional operation).

public BuffersBuffer
put(final ByteBuffer src)

Implements org.glassfish.grizzly.Buffer.put.

Relative bulk put method  (optional operation).

public BuffersBuffer
put(final ByteBuffer src, int offset, int length)

Implements org.glassfish.grizzly.Buffer.put.

Relative bulk put method  (optional operation).

public BuffersBuffer
put(Buffer src)

Implements org.glassfish.grizzly.Buffer.put.

Relative bulk put method  (optional operation).

public Buffer
put(Buffer src, int position, int length)

Implements org.glassfish.grizzly.Buffer.put.

Relative bulk put method  (optional operation).

public BuffersBuffer
put8BitString(final String s)

Implements org.glassfish.grizzly.Buffer.put8BitString.

Relative bulk put method  (optional operation).

public BuffersBuffer
putChar(final char value)

Implements org.glassfish.grizzly.Buffer.putChar.

Relative put method for writing a char value  (optional operation).

public BuffersBuffer
putChar(int index, final char value)

Implements org.glassfish.grizzly.Buffer.putChar.

Absolute put method for writing a char value  (optional operation).

private void
putCharB(int index, char value)

private void
putCharL(int index, char value)

public BuffersBuffer
putDouble(double value)

Implements org.glassfish.grizzly.Buffer.putDouble.

Relative put method for writing a double value  (optional operation).

public BuffersBuffer
putDouble(int index, double value)

Implements org.glassfish.grizzly.Buffer.putDouble.

Absolute put method for writing a double value  (optional operation).

public BuffersBuffer
putFloat(float value)

Implements org.glassfish.grizzly.Buffer.putFloat.

Relative put method for writing a float value  (optional operation).

public BuffersBuffer
putFloat(int index, float value)

Implements org.glassfish.grizzly.Buffer.putFloat.

Absolute put method for writing a float value  (optional operation).

public BuffersBuffer
putInt(final int value)

Implements org.glassfish.grizzly.Buffer.putInt.

Relative put method for writing an int value  (optional operation).

public BuffersBuffer
putInt(int index, final int value)

Implements org.glassfish.grizzly.Buffer.putInt.

Absolute put method for writing an int value  (optional operation).

private void
putIntB(int index, int value)

private void
putIntL(int index, int value)

public BuffersBuffer
putLong(final long value)

Implements org.glassfish.grizzly.Buffer.putLong.

Relative put method for writing a long value  (optional operation).

public BuffersBuffer
putLong(final int index, final long value)

Implements org.glassfish.grizzly.Buffer.putLong.

Absolute put method for writing a long value  (optional operation).

private void
putLongB(int index, long value)

private void
putLongL(int index, long value)

public BuffersBuffer
putShort(final short value)

Implements org.glassfish.grizzly.Buffer.putShort.

Relative put method for writing a short value  (optional operation).

public BuffersBuffer
putShort(int index, final short value)

Implements org.glassfish.grizzly.Buffer.putShort.

Absolute put method for writing a short value  (optional operation).

private void
putShortB(int index, short value)

private void
putShortL(int index, short value)

private void
recalcIndex(final int index)

private void
public boolean
release()

Implements org.glassfish.grizzly.asyncqueue.WritableMessage.release.

Perform message specific actions to release resources held by the entity backing this WritableMessage.

public int
remaining()

Implements org.glassfish.grizzly.Buffer.remaining.

Returns the number of elements between the current position and the limit.

public void
removeAll()

Implements abstract org.glassfish.grizzly.memory.CompositeBuffer.removeAll.

Removes underlying Buffers, without disposing

private void
protected int
removeRightBuffers(int startIndex)

public boolean
replace(final Buffer oldBuffer, final Buffer newBuffer)

Implements abstract org.glassfish.grizzly.memory.CompositeBuffer.replace.

Replace one internal Buffer with another one.

public BuffersBuffer
reset()

Implements org.glassfish.grizzly.Buffer.reset.

Resets this buffer's position to the previously-marked position.

private void
public BuffersBuffer
rewind()

Implements org.glassfish.grizzly.Buffer.rewind.

Rewinds this buffer.

private void
set(final MemoryManager<E extends Buffer> memoryManager, final Buffer[] buffers, final int buffersSize, final boolean isReadOnly)

private void
setPosLim(final int position, final int limit)

public void
shrink()

Implements org.glassfish.grizzly.Buffer.shrink.

Disposes the buffer part, outside [position, limit] interval if possible.

public Buffer
slice()

Implements org.glassfish.grizzly.Buffer.slice.

Creates a new Buffer whose content is a shared subsequence of this buffer's content.

public Buffer
slice(final int position, final int limit)

Implements org.glassfish.grizzly.Buffer.slice.

Creates a new Buffer whose content is a shared subsequence of this buffer's content.

public Buffer
split(final int splitPosition)

Implements org.glassfish.grizzly.Buffer.split.

Split up the buffer into two parts: [0..splitPosition) and [splitPosition, capacity).

private int
toActiveBufferPos(final int index)

public BufferArray
toBufferArray()

Implements org.glassfish.grizzly.Buffer.toBufferArray.

Returns a new BufferArray instance with this Buffer added as an element to the BufferArray.

public BufferArray
toBufferArray(final BufferArray array)

Implements org.glassfish.grizzly.Buffer.toBufferArray.

Returns the specified BufferArray after adding this Buffer.

public BufferArray
toBufferArray(final int position, final int limit)

Implements org.glassfish.grizzly.Buffer.toBufferArray.

Updates this Buffer's position and limit and adds it to a new BufferArray instance.

public BufferArray
toBufferArray(final BufferArray array, final int position, final int limit)

Implements org.glassfish.grizzly.Buffer.toBufferArray.

Updates this Buffer's position and limit and adds it to the specified BufferArray.

public ByteBuffer
toByteBuffer()

Implements org.glassfish.grizzly.Buffer.toByteBuffer.

Converts this Buffer to a ByteBuffer.

public ByteBuffer
toByteBuffer(int position, int limit)

Implements org.glassfish.grizzly.Buffer.toByteBuffer.

Converts this Buffer to a ByteBuffer.

public ByteBufferArray
toByteBufferArray()

Implements org.glassfish.grizzly.Buffer.toByteBufferArray.

Converts this Buffer to a ByteBuffer per toByteBuffer() and returns a ByteBufferArray containing the converted ByteBuffer.

public ByteBufferArray
toByteBufferArray(final ByteBufferArray array)

Implements org.glassfish.grizzly.Buffer.toByteBufferArray.

Converts this Buffer to a ByteBuffer per toByteBuffer() and adds the result to the provided ByteBufferArray.

public ByteBufferArray
toByteBufferArray(final int position, final int limit)

Implements org.glassfish.grizzly.Buffer.toByteBufferArray.

Converts this Buffer to a ByteBuffer per toByteBuffer(int, int) and returns a ByteBufferArray containing the converted ByteBuffer.

public ByteBufferArray
toByteBufferArray(final ByteBufferArray array, final int position, final int limit)

Implements org.glassfish.grizzly.Buffer.toByteBufferArray.

Converts this Buffer to a ByteBuffer per toByteBuffer(int, int) and adds the result to the provided ByteBufferArray.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public String
toStringContent()

Implements org.glassfish.grizzly.Buffer.toStringContent.

Returns Buffer content as String, using default Charset

public String
public String
toStringContent(Charset charset, final int position, final int limit)

Implements org.glassfish.grizzly.Buffer.toStringContent.

Returns Buffer's chunk content as String

public void
trim()

Implements org.glassfish.grizzly.Buffer.trim.

Trim the buffer by reducing capacity to position, if possible.

public boolean
tryDispose()

Implements org.glassfish.grizzly.Buffer.tryDispose.

Try to dispose Buffer if it's allowed.

public Buffer[]
Inherited from org.glassfish.grizzly.memory.CompositeBuffer:
disposeOrderdisposeOrdernewBuffernewBuffernewBuffernewBuffer