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

public Class ByteBufferWrapper

extends Object
implements Buffer
Class Inheritance
All Implemented Interfaces
org.glassfish.grizzly.Buffer, org.glassfish.grizzly.asyncqueue.WritableMessage, java.lang.Comparable
Known Direct Subclasses
org.glassfish.grizzly.memory.HeapMemoryManager.RecyclableByteBufferWrapper, org.glassfish.grizzly.memory.PooledMemoryManager.PoolByteBufferWrapper, org.glassfish.grizzly.ssl.InputBufferWrapper, org.glassfish.grizzly.memory.ByteBufferManager.TrimAwareWrapper, org.glassfish.grizzly.memory.ByteBufferManager.SmallByteBufferWrapper
Imports
java.nio.BufferOverflowException, .BufferUnderflowException, .ByteBuffer, .ByteOrder, .InvalidMarkException, java.nio.charset.Charset, org.glassfish.grizzly.Buffer

Buffer implementation, which uses the ByteBuffer underneath.
Authors
Ken Cavanaugh, John Vieten, Alexey Stashok
See Also
Buffer, MemoryManager, ByteBuffer

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
protected boolean
public static volatile boolean
protected Exception
protected int
protected ByteBuffer

Constructor Summary

AccessConstructor and Description
protected
public
ByteBufferWrapper(final ByteBuffer underlyingByteBuffer)

Method Summary

Modifier and TypeMethod and Description
public final boolean
public final void
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 ByteBufferWrapper
asReadOnlyBuffer()

Implements org.glassfish.grizzly.Buffer.asReadOnlyBuffer.

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

public final int
capacity()

Implements org.glassfish.grizzly.Buffer.capacity.

Returns this buffer's capacity.

protected void
public final ByteBufferWrapper
clear()

Implements org.glassfish.grizzly.Buffer.clear.

Clears this buffer.

public ByteBufferWrapper
compact()

Implements org.glassfish.grizzly.Buffer.compact.

Compacts this buffer  (optional operation).

public int
compareTo(Buffer o)

Implements java.lang.Comparable.compareTo.

Compares this object with the specified object for order.

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 ByteBufferWrapper
duplicate()

Implements org.glassfish.grizzly.Buffer.duplicate.

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

public boolean
equals(Object obj)

Overrides java.lang.Object.equals.

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

public final ByteBufferWrapper
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(int index)

Implements org.glassfish.grizzly.Buffer.get.

Absolute get method.

public ByteBufferWrapper
get(final byte[] dst)

Implements org.glassfish.grizzly.Buffer.get.

Relative bulk get method.

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

Implements org.glassfish.grizzly.Buffer.get.

Relative bulk get method.

public Buffer
get(final ByteBuffer dst)

Implements org.glassfish.grizzly.Buffer.get.

Relative bulk get method.

public Buffer
get(final ByteBuffer dst, final int position, final 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(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(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(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(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
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public final boolean
hasRemaining()

Implements org.glassfish.grizzly.Buffer.hasRemaining.

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

public final 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 final int
limit()

Implements org.glassfish.grizzly.Buffer.limit.

Returns this buffer's limit.

public final ByteBufferWrapper
limit(final int newLimit)

Implements org.glassfish.grizzly.Buffer.limit.

Sets this buffer's limit.

public final ByteBufferWrapper
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 ByteBufferWrapper
order(ByteOrder bo)

Implements org.glassfish.grizzly.Buffer.order.

Modifies this buffer's byte order.

public final int
position()

Implements org.glassfish.grizzly.Buffer.position.

Returns this buffer's position.

public final ByteBufferWrapper
position(final int newPosition)

Implements org.glassfish.grizzly.Buffer.position.

Sets this buffer's position.

protected final void
public ByteBufferWrapper
prepend(final Buffer header)

Implements org.glassfish.grizzly.Buffer.prepend.

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

public ByteBufferWrapper
put(byte b)

Implements org.glassfish.grizzly.Buffer.put.

Relative put method  (optional operation).

public ByteBufferWrapper
put(int index, byte b)

Implements org.glassfish.grizzly.Buffer.put.

Absolute put method  (optional operation).

public ByteBufferWrapper
put(final Buffer src)

Implements org.glassfish.grizzly.Buffer.put.

Relative bulk put method  (optional operation).

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

Implements org.glassfish.grizzly.Buffer.put.

Relative bulk put method  (optional operation).

public Buffer
put(final ByteBuffer src)

Implements org.glassfish.grizzly.Buffer.put.

Relative bulk put method  (optional operation).

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

Implements org.glassfish.grizzly.Buffer.put.

Relative bulk put method  (optional operation).

public ByteBufferWrapper
put(byte[] src)

Implements org.glassfish.grizzly.Buffer.put.

Relative bulk put method  (optional operation).

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

Implements org.glassfish.grizzly.Buffer.put.

Relative bulk put method  (optional operation).

public Buffer
put8BitString(final String s)

Implements org.glassfish.grizzly.Buffer.put8BitString.

Relative bulk put method  (optional operation).

public ByteBufferWrapper
putChar(char value)

Implements org.glassfish.grizzly.Buffer.putChar.

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

public ByteBufferWrapper
putChar(int index, char value)

Implements org.glassfish.grizzly.Buffer.putChar.

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

public ByteBufferWrapper
putDouble(double value)

Implements org.glassfish.grizzly.Buffer.putDouble.

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

public ByteBufferWrapper
putDouble(int index, double value)

Implements org.glassfish.grizzly.Buffer.putDouble.

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

public ByteBufferWrapper
putFloat(float value)

Implements org.glassfish.grizzly.Buffer.putFloat.

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

public ByteBufferWrapper
putFloat(int index, float value)

Implements org.glassfish.grizzly.Buffer.putFloat.

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

public ByteBufferWrapper
putInt(int value)

Implements org.glassfish.grizzly.Buffer.putInt.

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

public ByteBufferWrapper
putInt(int index, int value)

Implements org.glassfish.grizzly.Buffer.putInt.

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

public ByteBufferWrapper
putLong(long value)

Implements org.glassfish.grizzly.Buffer.putLong.

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

public ByteBufferWrapper
putLong(int index, long value)

Implements org.glassfish.grizzly.Buffer.putLong.

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

public ByteBufferWrapper
putShort(short value)

Implements org.glassfish.grizzly.Buffer.putShort.

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

public ByteBufferWrapper
putShort(int index, short value)

Implements org.glassfish.grizzly.Buffer.putShort.

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

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 final int
remaining()

Implements org.glassfish.grizzly.Buffer.remaining.

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

public final ByteBufferWrapper
reset()

Implements org.glassfish.grizzly.Buffer.reset.

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

public final ByteBufferWrapper
rewind()

Implements org.glassfish.grizzly.Buffer.rewind.

Rewinds this buffer.

public void
shrink()

Implements org.glassfish.grizzly.Buffer.shrink.

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

public ByteBufferWrapper
slice()

Implements org.glassfish.grizzly.Buffer.slice.

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

public ByteBufferWrapper
slice(int position, 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).

public final BufferArray
toBufferArray()

Implements org.glassfish.grizzly.Buffer.toBufferArray.

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

public final 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 final BufferArray
toBufferArray(final BufferArray array)

Implements org.glassfish.grizzly.Buffer.toBufferArray.

Returns the specified BufferArray after adding this Buffer.

public final 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 final ByteBuffer
toByteBuffer()

Implements org.glassfish.grizzly.Buffer.toByteBuffer.

Converts this Buffer to a ByteBuffer.

public final ByteBuffer
toByteBuffer(int position, int limit)

Implements org.glassfish.grizzly.Buffer.toByteBuffer.

Converts this Buffer to a ByteBuffer.

public final 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 final 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 final 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 final 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, int position, 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 final boolean
tryDispose()

Implements org.glassfish.grizzly.Buffer.tryDispose.

Try to dispose Buffer if it's allowed.

public ByteBuffer
underlying()

Implements org.glassfish.grizzly.Buffer.underlying.

Return the underlying buffer

protected ByteBufferWrapper
wrapByteBuffer(final ByteBuffer byteBuffer)

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait