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

pack-priv Class ReadOnlyHeapBuffer

extends HeapBuffer
Class Inheritance
Imports
java.nio.ByteBuffer, .ReadOnlyBufferException, org.glassfish.grizzly.Buffer

Read-only implementation.
Since
2.0

Field Summary

Inherited from org.glassfish.grizzly.memory.HeapBuffer:
allowBufferDisposebigEndianbyteBuffercapDEBUG_MODEdisposeStackTraceheaplimmarkoffsetorderposreadOnly

Constructor Summary

AccessConstructor and Description
pack-priv
ReadOnlyHeapBuffer(byte[] heap, int offset, int cap)

Method Summary

Modifier and TypeMethod and Description
public HeapBuffer
asReadOnlyBuffer()

Overrides org.glassfish.grizzly.memory.HeapBuffer.asReadOnlyBuffer.

Implements org.glassfish.grizzly.Buffer.asReadOnlyBuffer.

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

protected HeapBuffer
createHeapBuffer(final int offset, final int capacity)

Overrides org.glassfish.grizzly.memory.HeapBuffer.createHeapBuffer.

Create a new HeapBuffer based on the current heap.

public boolean
isReadOnly()

Overrides org.glassfish.grizzly.memory.HeapBuffer.isReadOnly.

Implements org.glassfish.grizzly.Buffer.isReadOnly.

Tells whether or not this buffer is read-only.

public HeapBuffer
prepend(Buffer header)

Overrides org.glassfish.grizzly.memory.HeapBuffer.prepend.

Implements org.glassfish.grizzly.Buffer.prepend.

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

public HeapBuffer
put(int index, byte b)

Overrides org.glassfish.grizzly.memory.HeapBuffer.put.

Implements org.glassfish.grizzly.Buffer.put.

Absolute put method  (optional operation).

public HeapBuffer
put(Buffer src)

Overrides org.glassfish.grizzly.memory.HeapBuffer.put.

Implements org.glassfish.grizzly.Buffer.put.

Relative bulk put method  (optional operation).

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

Overrides org.glassfish.grizzly.memory.HeapBuffer.put.

Implements org.glassfish.grizzly.Buffer.put.

Relative bulk put method  (optional operation).

public Buffer
put(ByteBuffer src)

Overrides org.glassfish.grizzly.memory.HeapBuffer.put.

Implements org.glassfish.grizzly.Buffer.put.

Relative bulk put method  (optional operation).

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

Overrides org.glassfish.grizzly.memory.HeapBuffer.put.

Implements org.glassfish.grizzly.Buffer.put.

Relative bulk put method  (optional operation).

public HeapBuffer
put(byte b)

Overrides org.glassfish.grizzly.memory.HeapBuffer.put.

Implements org.glassfish.grizzly.Buffer.put.

Relative put method  (optional operation).

public HeapBuffer
put(byte[] src)

Overrides org.glassfish.grizzly.memory.HeapBuffer.put.

Implements org.glassfish.grizzly.Buffer.put.

Relative bulk put method  (optional operation).

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

Overrides org.glassfish.grizzly.memory.HeapBuffer.put.

Implements org.glassfish.grizzly.Buffer.put.

Relative bulk put method  (optional operation).

public HeapBuffer
putChar(char value)

Overrides org.glassfish.grizzly.memory.HeapBuffer.putChar.

Implements org.glassfish.grizzly.Buffer.putChar.

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

public HeapBuffer
putChar(int index, char value)

Overrides org.glassfish.grizzly.memory.HeapBuffer.putChar.

Implements org.glassfish.grizzly.Buffer.putChar.

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

public HeapBuffer
putDouble(double value)

Overrides org.glassfish.grizzly.memory.HeapBuffer.putDouble.

Implements org.glassfish.grizzly.Buffer.putDouble.

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

public HeapBuffer
putDouble(int index, double value)

Overrides org.glassfish.grizzly.memory.HeapBuffer.putDouble.

Implements org.glassfish.grizzly.Buffer.putDouble.

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

public HeapBuffer
putFloat(float value)

Overrides org.glassfish.grizzly.memory.HeapBuffer.putFloat.

Implements org.glassfish.grizzly.Buffer.putFloat.

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

public HeapBuffer
putFloat(int index, float value)

Overrides org.glassfish.grizzly.memory.HeapBuffer.putFloat.

Implements org.glassfish.grizzly.Buffer.putFloat.

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

public HeapBuffer
putInt(int value)

Overrides org.glassfish.grizzly.memory.HeapBuffer.putInt.

Implements org.glassfish.grizzly.Buffer.putInt.

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

public HeapBuffer
putInt(int index, int value)

Overrides org.glassfish.grizzly.memory.HeapBuffer.putInt.

Implements org.glassfish.grizzly.Buffer.putInt.

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

public HeapBuffer
putLong(long value)

Overrides org.glassfish.grizzly.memory.HeapBuffer.putLong.

Implements org.glassfish.grizzly.Buffer.putLong.

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

public HeapBuffer
putLong(int index, long value)

Overrides org.glassfish.grizzly.memory.HeapBuffer.putLong.

Implements org.glassfish.grizzly.Buffer.putLong.

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

public HeapBuffer
putShort(short value)

Overrides org.glassfish.grizzly.memory.HeapBuffer.putShort.

Implements org.glassfish.grizzly.Buffer.putShort.

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

public HeapBuffer
putShort(int index, short value)

Overrides org.glassfish.grizzly.memory.HeapBuffer.putShort.

Implements org.glassfish.grizzly.Buffer.putShort.

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

public ByteBuffer
public ByteBuffer
toByteBuffer(int position, int limit)

Overrides org.glassfish.grizzly.memory.HeapBuffer.toByteBuffer.

Implements org.glassfish.grizzly.Buffer.toByteBuffer.

Converts this Buffer to a ByteBuffer.

Inherited from org.glassfish.grizzly.memory.HeapBuffer:
allowBufferDisposeallowBufferDisposearrayarrayOffsetcapacitycheckDisposeclearcompactcompareTodisposedumpHexduplicateequalsflipgetgetgetgetgetgetgetChargetChargetDoublegetDoublegetFloatgetFloatgetIntgetIntgetLonggetLonggetShortgetShorthasArrayhashCodehasRemainingisCompositeisDirectisExternallimitlimitmarkonShareHeaporderorderpositionpositionprepareDisposeput8BitStringreleaseremainingresetrewindshrinksliceslicesplittoBufferArraytoBufferArraytoBufferArraytoBufferArraytoByteBuffer0toByteBufferArraytoByteBufferArraytoByteBufferArraytoByteBufferArraytoStringtoStringContenttoStringContenttoStringContenttrimtryDisposeunderlyingwrapwrap

Constructor Detail

ReadOnlyHeapBufferback to summary
pack-priv ReadOnlyHeapBuffer(byte[] heap, int offset, int cap)

Method Detail

asReadOnlyBufferback to summary
public HeapBuffer asReadOnlyBuffer()

Overrides org.glassfish.grizzly.memory.HeapBuffer.asReadOnlyBuffer.

Implements org.glassfish.grizzly.Buffer.asReadOnlyBuffer.

Doc from org.glassfish.grizzly.Buffer.asReadOnlyBuffer.

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

The content of the new buffer will be that of this buffer. Changes to this buffer's content will be visible in the new buffer; the new buffer itself, however, will be read-only and will not allow the shared content to be modified. The two buffer's position, limit, and mark values will be independent.

The new buffer's capacity, limit, position, and mark values will be identical to those of this buffer.

If this buffer is itself read-only then this method behaves in exactly the same way as the duplicate method.

Annotations
@Override
createHeapBufferback to summary
protected HeapBuffer createHeapBuffer(final int offset, final int capacity)

Overrides org.glassfish.grizzly.memory.HeapBuffer.createHeapBuffer.

Doc from org.glassfish.grizzly.memory.HeapBuffer.createHeapBuffer.

Create a new HeapBuffer based on the current heap.

Annotations
@Override
isReadOnlyback to summary
public boolean isReadOnly()

Overrides org.glassfish.grizzly.memory.HeapBuffer.isReadOnly.

Implements org.glassfish.grizzly.Buffer.isReadOnly.

Doc from org.glassfish.grizzly.Buffer.isReadOnly.

Tells whether or not this buffer is read-only.

Annotations
@Override
prependback to summary
public HeapBuffer prepend(Buffer header)

Overrides org.glassfish.grizzly.memory.HeapBuffer.prepend.

Implements org.glassfish.grizzly.Buffer.prepend.

Doc from org.glassfish.grizzly.Buffer.prepend.

Prepend data from header.position() to header.limit() to the current buffer. This will change the value returned by buffer()!

Annotations
@Override
putback to summary
public HeapBuffer put(int index, byte b)

Overrides org.glassfish.grizzly.memory.HeapBuffer.put.

Implements org.glassfish.grizzly.Buffer.put.

Doc from org.glassfish.grizzly.Buffer.put.

Absolute put method  (optional operation).

Writes the given byte into this buffer at the given index.

Annotations
@Override
putback to summary
public HeapBuffer put(Buffer src)

Overrides org.glassfish.grizzly.memory.HeapBuffer.put.

Implements org.glassfish.grizzly.Buffer.put.

Doc from org.glassfish.grizzly.Buffer.put.

Relative bulk put method  (optional operation).

This method transfers the bytes remaining in the given source buffer into this buffer. If there are more bytes remaining in the source buffer than in this buffer, that is, if src.remaining() > remaining(), then no bytes are transferred and a BufferOverflowException is thrown.

Otherwise, this method copies n = src.remaining() bytes from the given buffer into this buffer, starting at each buffer's current position. The positions of both buffers are then incremented by n.

In other words, an invocation of this method of the form dst.put(src) has exactly the same effect as the loop

while (src.hasRemaining())
    dst.put(src.get());
except that it first checks that there is sufficient space in this buffer and it is potentially much more efficient.
Annotations
@Override
putback to summary
public HeapBuffer put(Buffer src, int position, int length)

Overrides org.glassfish.grizzly.memory.HeapBuffer.put.

Implements org.glassfish.grizzly.Buffer.put.

Doc from org.glassfish.grizzly.Buffer.put.

Relative bulk put method  (optional operation).

This method transfers the "length" bytes from the given source buffer into this buffer. If this buffer has less bytes remaining than length, that is, if length > remaining(), then no bytes are transferred and a BufferOverflowException is thrown.

Otherwise, this method copies n = length bytes from the given position in the source buffer into this buffer, starting from the current buffer position. The positions of this buffer is then incremented by length.

In other words, an invocation of this method of the form dst.put(src, position, length) has exactly the same effect as the loop

for (int i = 0; i < length; i++)
    dst.put(src.get(i + position));
except that it first checks that there is sufficient space in this buffer and it is potentially much more efficient.
Annotations
@Override
putback to summary
public Buffer put(ByteBuffer src)

Overrides org.glassfish.grizzly.memory.HeapBuffer.put.

Implements org.glassfish.grizzly.Buffer.put.

Doc from org.glassfish.grizzly.Buffer.put.

Relative bulk put method  (optional operation).

This method transfers the bytes remaining in the given source buffer into this buffer. If there are more bytes remaining in the source buffer than in this buffer, that is, if src.remaining() > remaining(), then no bytes are transferred and a BufferOverflowException is thrown.

Otherwise, this method copies n = src.remaining() bytes from the given buffer into this buffer, starting at each buffer's current position. The positions of both buffers are then incremented by n.

In other words, an invocation of this method of the form dst.put(src) has exactly the same effect as the loop

while (src.hasRemaining())
    dst.put(src.get());
except that it first checks that there is sufficient space in this buffer and it is potentially much more efficient.
Annotations
@Override
putback to summary
public Buffer put(ByteBuffer src, int position, int length)

Overrides org.glassfish.grizzly.memory.HeapBuffer.put.

Implements org.glassfish.grizzly.Buffer.put.

Doc from org.glassfish.grizzly.Buffer.put.

Relative bulk put method  (optional operation).

This method transfers the "length" bytes from the given source buffer into this buffer. If this buffer has less bytes remaining than length, that is, if length > remaining(), then no bytes are transferred and a BufferOverflowException is thrown.

Otherwise, this method copies n = length bytes from the given position in the source buffer into this buffer, starting from the current buffer position. The positions of this buffer is then incremented by length.

In other words, an invocation of this method of the form dst.put(src, position, length) has exactly the same effect as the loop

for (int i = 0; i < length; i++)
    dst.put(src.get(i + position));
except that it first checks that there is sufficient space in this buffer and it is potentially much more efficient.
Annotations
@Override
putback to summary
public HeapBuffer put(byte b)

Overrides org.glassfish.grizzly.memory.HeapBuffer.put.

Implements org.glassfish.grizzly.Buffer.put.

Doc from org.glassfish.grizzly.Buffer.put.

Relative put method  (optional operation).

Writes the given byte into this buffer at the current position, and then increments the position.

Annotations
@Override
putback to summary
public HeapBuffer put(byte[] src)

Overrides org.glassfish.grizzly.memory.HeapBuffer.put.

Implements org.glassfish.grizzly.Buffer.put.

Doc from org.glassfish.grizzly.Buffer.put.

Relative bulk put method  (optional operation).

This method transfers the entire content of the given source byte array into this buffer. An invocation of this method of the form dst.put(a) behaves in exactly the same way as the invocation

dst.put(a, 0, a.length)
Annotations
@Override
putback to summary
public HeapBuffer put(byte[] src, int offset, int length)

Overrides org.glassfish.grizzly.memory.HeapBuffer.put.

Implements org.glassfish.grizzly.Buffer.put.

Doc from org.glassfish.grizzly.Buffer.put.

Relative bulk put method  (optional operation).

This method transfers bytes into this buffer from the given source array. If there are more bytes to be copied from the array than remain in this buffer, that is, if length > remaining(), then no bytes are transferred and a BufferOverflowException is thrown.

Otherwise, this method copies length bytes from the given array into this buffer, starting at the given offset in the array and at the current position of this buffer. The position of this buffer is then incremented by length.

In other words, an invocation of this method of the form dst.put(src, off, len) has exactly the same effect as the loop

for (int i = off; i < off + len; i++)
    dst.put(a[i]);
except that it first checks that there is sufficient space in this buffer and it is potentially much more efficient.
Annotations
@Override
putCharback to summary
public HeapBuffer putChar(char value)

Overrides org.glassfish.grizzly.memory.HeapBuffer.putChar.

Implements org.glassfish.grizzly.Buffer.putChar.

Doc from org.glassfish.grizzly.Buffer.putChar.

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

Writes two bytes containing the given char value, in the current byte order, into this buffer at the current position, and then increments the position by two.

Annotations
@Override
putCharback to summary
public HeapBuffer putChar(int index, char value)

Overrides org.glassfish.grizzly.memory.HeapBuffer.putChar.

Implements org.glassfish.grizzly.Buffer.putChar.

Doc from org.glassfish.grizzly.Buffer.putChar.

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

Writes two bytes containing the given char value, in the current byte order, into this buffer at the given index.

Annotations
@Override
putDoubleback to summary
public HeapBuffer putDouble(double value)

Overrides org.glassfish.grizzly.memory.HeapBuffer.putDouble.

Implements org.glassfish.grizzly.Buffer.putDouble.

Doc from org.glassfish.grizzly.Buffer.putDouble.

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

Writes eight bytes containing the given double value, in the current byte order, into this buffer at the current position, and then increments the position by eight.

Annotations
@Override
putDoubleback to summary
public HeapBuffer putDouble(int index, double value)

Overrides org.glassfish.grizzly.memory.HeapBuffer.putDouble.

Implements org.glassfish.grizzly.Buffer.putDouble.

Doc from org.glassfish.grizzly.Buffer.putDouble.

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

Writes eight bytes containing the given double value, in the current byte order, into this buffer at the given index.

Annotations
@Override
putFloatback to summary
public HeapBuffer putFloat(float value)

Overrides org.glassfish.grizzly.memory.HeapBuffer.putFloat.

Implements org.glassfish.grizzly.Buffer.putFloat.

Doc from org.glassfish.grizzly.Buffer.putFloat.

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

Writes four bytes containing the given float value, in the current byte order, into this buffer at the current position, and then increments the position by four.

Annotations
@Override
putFloatback to summary
public HeapBuffer putFloat(int index, float value)

Overrides org.glassfish.grizzly.memory.HeapBuffer.putFloat.

Implements org.glassfish.grizzly.Buffer.putFloat.

Doc from org.glassfish.grizzly.Buffer.putFloat.

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

Writes four bytes containing the given float value, in the current byte order, into this buffer at the given index.

Annotations
@Override
putIntback to summary
public HeapBuffer putInt(int value)

Overrides org.glassfish.grizzly.memory.HeapBuffer.putInt.

Implements org.glassfish.grizzly.Buffer.putInt.

Doc from org.glassfish.grizzly.Buffer.putInt.

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

Writes four bytes containing the given int value, in the current byte order, into this buffer at the current position, and then increments the position by four.

Annotations
@Override
putIntback to summary
public HeapBuffer putInt(int index, int value)

Overrides org.glassfish.grizzly.memory.HeapBuffer.putInt.

Implements org.glassfish.grizzly.Buffer.putInt.

Doc from org.glassfish.grizzly.Buffer.putInt.

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

Writes four bytes containing the given int value, in the current byte order, into this buffer at the given index.

Annotations
@Override
putLongback to summary
public HeapBuffer putLong(long value)

Overrides org.glassfish.grizzly.memory.HeapBuffer.putLong.

Implements org.glassfish.grizzly.Buffer.putLong.

Doc from org.glassfish.grizzly.Buffer.putLong.

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

Writes eight bytes containing the given long value, in the current byte order, into this buffer at the current position, and then increments the position by eight.

Annotations
@Override
putLongback to summary
public HeapBuffer putLong(int index, long value)

Overrides org.glassfish.grizzly.memory.HeapBuffer.putLong.

Implements org.glassfish.grizzly.Buffer.putLong.

Doc from org.glassfish.grizzly.Buffer.putLong.

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

Writes eight bytes containing the given long value, in the current byte order, into this buffer at the given index.

Annotations
@Override
putShortback to summary
public HeapBuffer putShort(short value)

Overrides org.glassfish.grizzly.memory.HeapBuffer.putShort.

Implements org.glassfish.grizzly.Buffer.putShort.

Doc from org.glassfish.grizzly.Buffer.putShort.

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

Writes two bytes containing the given short value, in the current byte order, into this buffer at the current position, and then increments the position by two.

Annotations
@Override
putShortback to summary
public HeapBuffer putShort(int index, short value)

Overrides org.glassfish.grizzly.memory.HeapBuffer.putShort.

Implements org.glassfish.grizzly.Buffer.putShort.

Doc from org.glassfish.grizzly.Buffer.putShort.

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

Writes two bytes containing the given short value, in the current byte order, into this buffer at the given index.

Annotations
@Override
toByteBufferback to summary
public ByteBuffer toByteBuffer()

Overrides org.glassfish.grizzly.memory.HeapBuffer.toByteBuffer.

Implements org.glassfish.grizzly.Buffer.toByteBuffer.

Doc from org.glassfish.grizzly.memory.HeapBuffer.toByteBuffer.

Converts this Buffer to a ByteBuffer. If this Buffer is not composite - then returned ByteBuffer's content is a shared subsequence of this buffer's content, with CompositeBuffer this is not guaranteed. The position of the returned ByteBuffer is not guaranteed to be 0, the capacity of the returned ByteBuffer is not guaranteed to be equal to the capacity of this Buffer. It is guaranteed that the result of the returned ByteBuffer's ByteBuffer#remaining() call will be equal to this Buffer's remaining() call. The Buffer's and ByteBuffer's position, limit, and mark values are not guaranteed to be independent, so it's recommended to save and restore position, limit values if it is planned to change them or ByteBuffer#slice() the returned ByteBuffer.

Annotations
@Override
toByteBufferback to summary
public ByteBuffer toByteBuffer(int position, int limit)

Overrides org.glassfish.grizzly.memory.HeapBuffer.toByteBuffer.

Implements org.glassfish.grizzly.Buffer.toByteBuffer.

Doc from org.glassfish.grizzly.memory.HeapBuffer.toByteBuffer.

Converts this Buffer to a ByteBuffer. If this Buffer is not composite - then returned ByteBuffer's content is a shared subsequence of this buffer's content, with CompositeBuffer this is not guaranteed. The position of the returned ByteBuffer is not guaranteed to be 0, the capacity of the returned ByteBuffer is not guaranteed to be equal to the capacity of this Buffer. It is guaranteed that the result of the returned ByteBuffer's ByteBuffer#remaining() call will be equal (limit - position). The Buffer's and ByteBuffer's position, limit, and mark values are not guaranteed to be independent, so it's recommended to save and restore position, limit values if it is planned to change them or ByteBuffer#slice() the returned ByteBuffer.

Annotations
@Override