| Modifier and Type | Field and Description |
|---|---|
static Buffer |
EMPTY_BUFFER |
static ByteBuffer |
EMPTY_BYTE_BUFFER |
static ByteBuffer[] |
EMPTY_BYTE_BUFFER_ARRAY |
| Constructor and Description |
|---|
Buffers() |
| Modifier and Type | Method and Description |
|---|---|
static Buffer |
appendBuffers(MemoryManager memoryManager,
Buffer buffer1,
Buffer buffer2)
Append two
Buffers. |
static Buffer |
appendBuffers(MemoryManager memoryManager,
Buffer buffer1,
Buffer buffer2,
boolean isCompositeBufferDisposable)
Append two
Buffers. |
static Buffer |
cloneBuffer(Buffer srcBuffer)
Clones the source
Buffer. |
static Buffer |
cloneBuffer(Buffer srcBuffer,
int position,
int limit)
Clones the source
Buffer. |
static void |
fill(Buffer buffer,
byte b)
Fill the
Buffer with the specific byte value. |
static void |
fill(Buffer buffer,
int position,
int limit,
byte b)
|
static void |
fill(ByteBuffer byteBuffer,
byte b)
Fill the
ByteBuffer with the specific byte value. |
static void |
fill(ByteBuffer byteBuffer,
int position,
int limit,
byte b)
Fill the
ByteBuffer's part [position, limit) with the specific byte value starting from the
ByteBuffer's position won't be changed. |
static void |
get(ByteBuffer srcBuffer,
byte[] dstBytes,
int dstOffset,
int length) |
static Appender<Buffer> |
getBufferAppender(boolean isCompositeBufferDisposable)
|
static void |
put(Buffer src,
int position,
int length,
Buffer dstBuffer) |
static void |
put(byte[] srcBytes,
int srcOffset,
int length,
ByteBuffer dstBuffer) |
static void |
put(ByteBuffer srcBuffer,
int srcOffset,
int length,
ByteBuffer dstBuffer) |
static long |
readFromFileChannel(FileChannel fileChannel,
Buffer buffer)
Reads data from the
FileChannel into the Buffer. |
static void |
setPositionLimit(Buffer buffer,
int position,
int limit) |
static void |
setPositionLimit(ByteBuffer buffer,
int position,
int limit) |
static ByteBuffer |
slice(ByteBuffer chunk,
int size)
Slice
ByteBuffer of required size from big chunk. |
static ByteBuffer |
slice(ByteBuffer byteBuffer,
int position,
int limit)
Get the
ByteBuffer's slice basing on its passed position and limit. |
String |
toStringContent(Buffer buffer,
int headBytesCount,
int tailBytesCount)
|
String |
toStringContent(Buffer buffer,
int headBytesCount,
int tailBytesCount,
Charset charset)
|
static String |
toStringContent(ByteBuffer byteBuffer,
Charset charset,
int position,
int limit) |
static Buffer |
wrap(MemoryManager memoryManager,
byte[] array)
Returns
Buffer, which wraps the byte array. |
static Buffer |
wrap(MemoryManager memoryManager,
byte[] array,
int offset,
int length)
Returns
Buffer, which wraps the part of byte array with
specific offset and length. |
static Buffer |
wrap(MemoryManager memoryManager,
ByteBuffer byteBuffer)
Returns
Buffer, which wraps the ByteBuffer. |
static Buffer |
wrap(MemoryManager memoryManager,
String s)
|
static Buffer |
wrap(MemoryManager memoryManager,
String s,
Charset charset)
|
static long |
writeToFileChannel(FileChannel fileChannel,
Buffer buffer)
Writes data from the
Buffer into the FileChannel. |
public static final ByteBuffer EMPTY_BYTE_BUFFER
public static final ByteBuffer[] EMPTY_BYTE_BUFFER_ARRAY
public static final Buffer EMPTY_BUFFER
public static Appender<Buffer> getBufferAppender(boolean isCompositeBufferDisposable)
Appender which knows how to append Buffers.
Returned Appender uses the same Buffer appending rules as
described here appendBuffers(org.glassfish.grizzly.memory.MemoryManager, org.glassfish.grizzly.Buffer, org.glassfish.grizzly.Buffer, boolean).isCompositeBufferDisposable - if as the result of Buffers
appending a new CompositeBuffer will be created - its
Buffer.allowBufferDispose(boolean) value will be set
according to this parameter.Buffer Appender.public static Buffer wrap(MemoryManager memoryManager, String s)
memoryManager - MemoryManager, which should be
used for wrapping.s - StringBuffer wrapper on top of passed String.public static Buffer wrap(MemoryManager memoryManager, String s, Charset charset)
public static Buffer wrap(MemoryManager memoryManager, byte[] array)
Buffer, which wraps the byte array.memoryManager - MemoryManager, which should be
used for wrapping.array - byte array to wrap.Buffer wrapper on top of passed byte array.public static Buffer wrap(MemoryManager memoryManager, byte[] array, int offset, int length)
Buffer, which wraps the part of byte array with
specific offset and length.memoryManager - MemoryManager, which should be
used for wrapping.array - byte array to wrapoffset - byte buffer offsetlength - byte buffer lengthBuffer wrapper on top of passed byte array.public static Buffer wrap(MemoryManager memoryManager, ByteBuffer byteBuffer)
Buffer, which wraps the ByteBuffer.memoryManager - MemoryManager, which should be
used for wrapping.byteBuffer - ByteBuffer to wrapBuffer wrapper on top of passed ByteBuffer.public static ByteBuffer slice(ByteBuffer chunk, int size)
ByteBuffer of required size from big chunk.
Passed chunk position will be changed, after the slicing (chunk.position += size).chunk - big ByteBuffer pool.size - required slice size.ByteBuffer of required size.public static ByteBuffer slice(ByteBuffer byteBuffer, int position, int limit)
ByteBuffer's slice basing on its passed position and limit.
Position and limit values of the passed ByteBuffer won't be changed.
The result ByteBuffer position will be equal to 0, and limit
equal to number of sliced bytes (limit - position).byteBuffer - ByteBuffer to slice/position - the position in the passed byteBuffer, the slice will start from.limit - the limit in the passed byteBuffer, the slice will be ended.ByteBuffer of required size.public static String toStringContent(ByteBuffer byteBuffer, Charset charset, int position, int limit)
public static void setPositionLimit(Buffer buffer, int position, int limit)
public static void setPositionLimit(ByteBuffer buffer, int position, int limit)
public static void put(ByteBuffer srcBuffer, int srcOffset, int length, ByteBuffer dstBuffer)
public static void get(ByteBuffer srcBuffer, byte[] dstBytes, int dstOffset, int length)
public static void put(byte[] srcBytes,
int srcOffset,
int length,
ByteBuffer dstBuffer)
public static Buffer appendBuffers(MemoryManager memoryManager, Buffer buffer1, Buffer buffer2)
Buffers.
If one of the Buffers is null - then another Buffer will
be returned as result.
If the first Buffer is CompositeBuffer then the second
Buffer will be appended to it via
CompositeBuffer#append(java.lang.Object), else if the second
Buffer is CompositeBuffer then the first Buffer
will be prepended to it via
CompositeBuffer.prepend(org.glassfish.grizzly.Buffer).
If none of the Buffer parameters is null nor
CompositeBuffers - then new CompositeBuffer will be created
and both Buffers will be added there. The resulting
CompositeBuffer will be disallowed for disposal.memoryManager - the MemoryManager to use if a new Buffer
needs to be allocated in order to perform the requested
operation.buffer1 - the Buffer to append to.buffer2 - the Buffer to append.Buffers.public static Buffer appendBuffers(MemoryManager memoryManager, Buffer buffer1, Buffer buffer2, boolean isCompositeBufferDisposable)
Buffers.
If one of the Buffers is null - then another Buffer will
be returned as result.
If the first Buffer is CompositeBuffer then the second
Buffer will be appended to it via
CompositeBuffer#append(java.lang.Object), else if the second
Buffer is CompositeBuffer then the first Buffer
will be prepended to it via
CompositeBuffer.prepend(org.glassfish.grizzly.Buffer).
If none of the Buffer parameters is null nor
CompositeBuffers - then new CompositeBuffer will be created
and both Buffers will be added there. The resulting
CompositeBuffer will be assigned according to the
isCompositeBufferDisposable parameter.memoryManager - the MemoryManager to use if a new Buffer
needs to be allocated in order to perform the requested
operation.buffer1 - the Buffer to append to.buffer2 - the Buffer to append.isCompositeBufferDisposable - flag indicating whether or not the
resulting composite buffer may be disposed.Buffers.public static void fill(Buffer buffer, int position, int limit, byte b)
public static void fill(ByteBuffer byteBuffer, byte b)
ByteBuffer with the specific byte value. ByteBuffer's
position won't be changed.byteBuffer - ByteBufferb - valuepublic static void fill(ByteBuffer byteBuffer, int position, int limit, byte b)
ByteBuffer's part [position, limit) with the specific byte value starting from the
ByteBuffer's position won't be changed.byteBuffer - ByteBufferposition - ByteBuffer position to start with (inclusive)limit - Buffer limit, where filling ends (exclusive)b - valuepublic static long readFromFileChannel(FileChannel fileChannel, Buffer buffer) throws IOException
FileChannel into the Buffer.fileChannel - the FileChannel to read data from.buffer - the destination Buffer.IOExceptionpublic static long writeToFileChannel(FileChannel fileChannel, Buffer buffer) throws IOException
Buffer into the FileChannel.fileChannel - the FileChannel to write data to.buffer - the source Buffer.IOExceptionpublic String toStringContent(Buffer buffer, int headBytesCount, int tailBytesCount)
public String toStringContent(Buffer buffer, int headBytesCount, int tailBytesCount, Charset charset)
Buffer's String representation in a form:
Buffer#toString() + "[" + HeapBuffer (1781633478) [pos=0 lim=285 cap=285][abcde...xyz]
buffer - the Buffer, could be nullheadBytesCount - the number of heading bytes to include (larger or equal to 0)tailBytesCount - the number of tailing bytes to include (larger or equal to 0)charset - Charset, if null the Charset.defaultCharset() will
be usedBuffer's String representation, or null,
if the Buffer is nullCopyright © 2015 Oracle Corporation. All Rights Reserved.