|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.glassfish.grizzly.memory.Buffers
public class Buffers
Class has useful methods to simplify the work with Buffers.
Buffer| Field Summary | |
|---|---|
static Appender<Buffer> |
BUFFER_APPENDER
|
static Buffer |
EMPTY_BUFFER
|
static java.nio.ByteBuffer |
EMPTY_BYTE_BUFFER
|
static java.nio.ByteBuffer[] |
EMPTY_BYTE_BUFFER_ARRAY
|
| Constructor Summary | |
|---|---|
Buffers()
|
|
| Method Summary | |
|---|---|
static Buffer |
appendBuffers(MemoryManager memoryManager,
Buffer buffer1,
Buffer buffer2)
|
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)
Fill the Buffer's part [position, limit) with the specific byte value starting from the
Buffer's position won't be changed. |
static void |
fill(java.nio.ByteBuffer byteBuffer,
byte b)
Fill the ByteBuffer with the specific byte value. |
static void |
fill(java.nio.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(java.nio.ByteBuffer srcBuffer,
byte[] dstBytes,
int dstOffset,
int length)
|
static void |
put(Buffer src,
int position,
int length,
Buffer dstBuffer)
|
static void |
put(byte[] srcBytes,
int srcOffset,
int length,
java.nio.ByteBuffer dstBuffer)
|
static void |
put(java.nio.ByteBuffer srcBuffer,
int srcOffset,
int length,
java.nio.ByteBuffer dstBuffer)
|
static void |
setPositionLimit(Buffer buffer,
int position,
int limit)
|
static void |
setPositionLimit(java.nio.ByteBuffer buffer,
int position,
int limit)
|
static java.nio.ByteBuffer |
slice(java.nio.ByteBuffer chunk,
int size)
Slice ByteBuffer of required size from big chunk. |
static java.nio.ByteBuffer |
slice(java.nio.ByteBuffer byteBuffer,
int position,
int limit)
Get the ByteBuffer's slice basing on its passed position and limit. |
static java.lang.String |
toStringContent(java.nio.ByteBuffer byteBuffer,
java.nio.charset.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,
java.nio.ByteBuffer byteBuffer)
Returns Buffer, which wraps the ByteBuffer. |
static Buffer |
wrap(MemoryManager memoryManager,
java.lang.String s)
Returns Buffer, which wraps the String. |
static Buffer |
wrap(MemoryManager memoryManager,
java.lang.String s,
java.nio.charset.Charset charset)
Returns Buffer, which wraps the String with the specific
Charset. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final Appender<Buffer> BUFFER_APPENDER
public static final java.nio.ByteBuffer EMPTY_BYTE_BUFFER
public static final java.nio.ByteBuffer[] EMPTY_BYTE_BUFFER_ARRAY
public static final Buffer EMPTY_BUFFER
| Constructor Detail |
|---|
public Buffers()
| Method Detail |
|---|
public static Buffer wrap(MemoryManager memoryManager,
java.lang.String s)
Buffer, which wraps the String.
memoryManager - MemoryManager, which should be
used for wrapping.s - String
Buffer wrapper on top of passed String.
public static Buffer wrap(MemoryManager memoryManager,
java.lang.String s,
java.nio.charset.Charset charset)
Buffer, which wraps the String with the specific
Charset.
memoryManager - MemoryManager, which should be
used for wrapping.s - Stringcharset - Charset, which will be used, when converting
String to byte array.
Buffer wrapper on top of passed String.
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 length
Buffer wrapper on top of passed byte array.
public static Buffer wrap(MemoryManager memoryManager,
java.nio.ByteBuffer byteBuffer)
Buffer, which wraps the ByteBuffer.
memoryManager - MemoryManager, which should be
used for wrapping.byteBuffer - ByteBuffer to wrap
Buffer wrapper on top of passed ByteBuffer.
public static java.nio.ByteBuffer slice(java.nio.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 java.nio.ByteBuffer slice(java.nio.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 java.lang.String toStringContent(java.nio.ByteBuffer byteBuffer,
java.nio.charset.Charset charset,
int position,
int limit)
public static void setPositionLimit(Buffer buffer,
int position,
int limit)
public static void setPositionLimit(java.nio.ByteBuffer buffer,
int position,
int limit)
public static void put(java.nio.ByteBuffer srcBuffer,
int srcOffset,
int length,
java.nio.ByteBuffer dstBuffer)
public static void put(Buffer src,
int position,
int length,
Buffer dstBuffer)
public static void get(java.nio.ByteBuffer srcBuffer,
byte[] dstBytes,
int dstOffset,
int length)
public static void put(byte[] srcBytes,
int srcOffset,
int length,
java.nio.ByteBuffer dstBuffer)
public static Buffer appendBuffers(MemoryManager memoryManager,
Buffer buffer1,
Buffer buffer2)
public static void fill(Buffer buffer,
byte b)
Buffer with the specific byte value. Buffer's
position won't be changed.
buffer - Bufferb - value
public static void fill(Buffer buffer,
int position,
int limit,
byte b)
Buffer's part [position, limit) with the specific byte value starting from the
Buffer's position won't be changed.
buffer - Bufferposition - Buffer position to start with (inclusive)limit - Buffer limit, where filling ends (exclusive)b - value
public static void fill(java.nio.ByteBuffer byteBuffer,
byte b)
ByteBuffer with the specific byte value. ByteBuffer's
position won't be changed.
byteBuffer - ByteBufferb - value
public static void fill(java.nio.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 Buffer cloneBuffer(Buffer srcBuffer)
Buffer.
The method returns a new Buffer instance, which has the same content.
Please note, source and result Buffers have the same content,
but it is *not* shared, so the following content changes in one of the
Buffers won't be visible in another one.
srcBuffer - the source Buffer.
Buffer.
public static Buffer cloneBuffer(Buffer srcBuffer,
int position,
int limit)
Buffer.
The method returns a new Buffer instance, which has the same content.
Please note, source and result Buffers have the same content,
but it is *not* shared, so the following content changes in one of the
Buffers won't be visible in another one.
srcBuffer - the source Buffer.position - the start position in the srcBufferlimit - the end position in the srcBuffer
Buffer.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||