コード例 #1
0
  @Override
  protected ByteBuf newBuffer(int length) {
    buffers = new ArrayList<ByteBuf>();
    for (int i = 0; i < length + 45; i += 45) {
      buffers.add(EMPTY_BUFFER);
      buffers.add(wrappedBuffer(new byte[1]));
      buffers.add(EMPTY_BUFFER);
      buffers.add(wrappedBuffer(new byte[2]));
      buffers.add(EMPTY_BUFFER);
      buffers.add(wrappedBuffer(new byte[3]));
      buffers.add(EMPTY_BUFFER);
      buffers.add(wrappedBuffer(new byte[4]));
      buffers.add(EMPTY_BUFFER);
      buffers.add(wrappedBuffer(new byte[5]));
      buffers.add(EMPTY_BUFFER);
      buffers.add(wrappedBuffer(new byte[6]));
      buffers.add(EMPTY_BUFFER);
      buffers.add(wrappedBuffer(new byte[7]));
      buffers.add(EMPTY_BUFFER);
      buffers.add(wrappedBuffer(new byte[8]));
      buffers.add(EMPTY_BUFFER);
      buffers.add(wrappedBuffer(new byte[9]));
      buffers.add(EMPTY_BUFFER);
    }

    buffer =
        Unpooled.wrappedBuffer(Integer.MAX_VALUE, buffers.toArray(new ByteBuf[buffers.size()]))
            .order(order);

    // Truncate to the requested capacity.
    buffer.capacity(length);

    assertEquals(length, buffer.capacity());
    assertEquals(length, buffer.readableBytes());
    assertFalse(buffer.isWritable());
    buffer.writerIndex(0);
    return buffer;
  }
コード例 #2
0
ファイル: WrappedByteBuf.java プロジェクト: 289/netty
 @Override
 public boolean isWritable(int size) {
   return buf.isWritable(size);
 }
コード例 #3
0
ファイル: WrappedByteBuf.java プロジェクト: 289/netty
 @Override
 public boolean isWritable() {
   return buf.isWritable();
 }