|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.grizzly.memory.ByteBufferManager
public class ByteBufferManager
The simple Buffer manager implementation, which works as wrapper above
ByteBuffers. It's possible to work either with direct or heap
ByteBuffers.
MemoryManager,
ByteBuffer| Field Summary | |
|---|---|
protected boolean |
isDirect
Is direct ByteBuffer should be used? |
| Constructor Summary | |
|---|---|
ByteBufferManager()
|
|
ByteBufferManager(boolean isDirect)
|
|
| Method Summary | |
|---|---|
ByteBufferWrapper |
allocate(int size)
Allocated Buffer of the required size. |
protected ByteBuffer |
allocate0(int size)
Allocates ByteBuffer of required size. |
boolean |
isDirect()
Returns true, if ByteBufferManager works with direct ByteBuffers, or false otherwise. |
ByteBufferWrapper |
reallocate(ByteBufferWrapper oldBuffer,
int newSize)
Reallocate Buffer to a required size. |
void |
release(ByteBufferWrapper buffer)
Lets JVM Garbage collector to release buffer. |
void |
setDirect(boolean isDirect)
Set true, if ByteBufferManager works with direct ByteBuffers, or false otherwise. |
ByteBufferWrapper |
wrap(byte[] data)
Returns Buffer, which wraps the byte array. |
ByteBufferWrapper |
wrap(byte[] data,
int offset,
int length)
Returns Buffer, which wraps the part of byte array with
specific offset and length. |
ByteBufferWrapper |
wrap(ByteBuffer byteBuffer)
Returns Buffer, which wraps the ByteBuffer. |
ByteBufferWrapper |
wrap(String s)
Returns Buffer, which wraps the String. |
ByteBufferWrapper |
wrap(String s,
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 |
|---|
protected boolean isDirect
| Constructor Detail |
|---|
public ByteBufferManager()
public ByteBufferManager(boolean isDirect)
| Method Detail |
|---|
protected ByteBuffer allocate0(int size)
ByteBuffer of required size.
size - ByteBuffer size.
ByteBuffer.public ByteBufferWrapper allocate(int size)
Buffer of the required size.
allocate in interface MemoryManager<ByteBufferWrapper>size - Buffer size to be allocated.
Buffer.
public ByteBufferWrapper reallocate(ByteBufferWrapper oldBuffer,
int newSize)
Buffer to a required size.
Implementation may choose the way, how reallocation could be done, either
by allocating new Buffer of required size and copying old
Buffer content there, or perform more complex logic related to
memory pooling etc.
reallocate in interface MemoryManager<ByteBufferWrapper>oldBuffer - old Buffer to be reallocated.newSize - new Buffer required size.
Buffer.public void release(ByteBufferWrapper buffer)
release in interface MemoryManager<ByteBufferWrapper>buffer - Buffer to be released.public boolean isDirect()
ByteBuffers, or false otherwise.
ByteBuffers, or false otherwise.public void setDirect(boolean isDirect)
ByteBuffers, or false otherwise.
isDirect - true, if ByteBufferManager works with
direct ByteBuffers, or false otherwise.public ByteBufferWrapper wrap(byte[] data)
Buffer, which wraps the byte array.
wrap in interface WrapperAware<ByteBufferWrapper>data - byte array to wrap
Buffer wrapper on top of passed byte array.
public ByteBufferWrapper wrap(byte[] data,
int offset,
int length)
Buffer, which wraps the part of byte array with
specific offset and length.
wrap in interface WrapperAware<ByteBufferWrapper>data - byte array to wrapoffset - byte buffer offsetlength - byte buffer length
Buffer wrapper on top of passed byte array.public ByteBufferWrapper wrap(String s)
Buffer, which wraps the String.
wrap in interface WrapperAware<ByteBufferWrapper>s - String
Buffer wrapper on top of passed String.
public ByteBufferWrapper wrap(String s,
Charset charset)
Buffer, which wraps the String with the specific
Charset.
wrap in interface WrapperAware<ByteBufferWrapper>s - Stringcharset - Charset, which will be used, when converting
String to byte array.
Buffer wrapper on top of passed String.public ByteBufferWrapper wrap(ByteBuffer byteBuffer)
Buffer, which wraps the ByteBuffer.
wrap in interface WrapperAware<ByteBufferWrapper>byteBuffer - ByteBuffer to wrap
Buffer wrapper on top of passed ByteBuffer.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||