Esempio n. 1
0
 /**
  * Allocates buffer of the given size using the given allocator.
  *
  * @param buffersize the buffer size.
  * @param allocator allocator to be used to allocate {@link ByteBuffer}s.
  */
 public ExpandableBuffer(final int buffersize, final ByteBufferAllocator allocator) {
   super();
   Args.notNull(allocator, "ByteBuffer allocator");
   this.allocator = allocator;
   this.buffer = allocator.allocate(buffersize);
   this.mode = INPUT_MODE;
 }
Esempio n. 2
0
 private void expandCapacity(final int capacity) {
   final ByteBuffer oldbuffer = this.buffer;
   this.buffer = allocator.allocate(capacity);
   oldbuffer.flip();
   this.buffer.put(oldbuffer);
 }