rabbit.io
Interface BufferHandle

All Known Implementing Classes:
CacheBufferHandle, SimpleBufferHandle

public interface BufferHandle

A handle to a ByteBuffer

Author:
Robert Olofsson

Method Summary
 ByteBuffer getBuffer()
          Get a byte buffer of reasonable size, the buffer will have been cleared.
 ByteBuffer getLargeBuffer()
          Get a byte buffer of reasonable size, the buffer will have been cleared.
 boolean isEmpty()
          Check if this handle is empty, that is if no buffer exists or the buffer is empty.
 boolean isLarge(ByteBuffer buffer)
          Check if the given buffer is a large buffer
 void possiblyFlush()
          release a buffer if possible.
 void setMayBeFlushed(boolean mayBeFlushed)
          Flag that the internal ByteBuffer may not be flushed.
 

Method Detail

isEmpty

boolean isEmpty()
Check if this handle is empty, that is if no buffer exists or the buffer is empty.

Returns:
true if the buffer currently is empty

getBuffer

ByteBuffer getBuffer()
Get a byte buffer of reasonable size, the buffer will have been cleared.

Returns:
the actual ByteBuffer

getLargeBuffer

ByteBuffer getLargeBuffer()
Get a byte buffer of reasonable size, the buffer will have been cleared.

Returns:
the large buffer to use

isLarge

boolean isLarge(ByteBuffer buffer)
Check if the given buffer is a large buffer

Parameters:
buffer - the ByteBuffer to check
Returns:
true if the given buffer is large

possiblyFlush

void possiblyFlush()
release a buffer if possible.


setMayBeFlushed

void setMayBeFlushed(boolean mayBeFlushed)
Flag that the internal ByteBuffer may not be flushed.

Parameters:
mayBeFlushed - if true the buffer may be returned, if false the putBuffer call will throw an exception