io.netty.buffer.ByteBuf.nioBuffers()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(5.6k)|赞(0)|评价(0)|浏览(157)

本文整理了Java中io.netty.buffer.ByteBuf.nioBuffers()方法的一些代码示例,展示了ByteBuf.nioBuffers()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteBuf.nioBuffers()方法的具体详情如下:
包路径:io.netty.buffer.ByteBuf
类名称:ByteBuf
方法名:nioBuffers

ByteBuf.nioBuffers介绍

[英]Exposes this buffer's readable bytes as an NIO ByteBuffer's. The returned buffer either share or contains the copied content of this buffer, while changing the position and limit of the returned NIO buffer does not affect the indexes and marks of this buffer. This method does not modify readerIndex or writerIndex of this buffer. Please note that the returned NIO buffer will not see the changes of this buffer if this buffer is a dynamic buffer and it adjusted its capacity.
[中]将此缓冲区的可读字节公开为NIO字节缓冲区。返回的缓冲区共享或包含此缓冲区的复制内容,而更改返回的NIO缓冲区的位置和限制不会影响此缓冲区的索引和标记。此方法不修改此缓冲区的readerIndex或writerIndex。请注意,如果此缓冲区是动态缓冲区并且已调整其容量,则返回的NIO缓冲区将不会看到此缓冲区的更改。

代码示例

代码示例来源:origin: netty/netty

@Override
public ByteBuffer[] nioBuffers(int index, int length) {
  return buf.nioBuffers(index, length);
}

代码示例来源:origin: netty/netty

@Override
public ByteBuffer[] nioBuffers() {
  return buf.nioBuffers();
}

代码示例来源:origin: redisson/redisson

@Override
public ByteBuffer[] nioBuffers() {
  return buf.nioBuffers();
}

代码示例来源:origin: netty/netty

@Override
public ByteBuffer[] nioBuffers() {
  ByteBuffer[] nioBuffers = buf.nioBuffers();
  for (int i = 0; i < nioBuffers.length; i++) {
    nioBuffers[i] = nioBuffers[i].order(order);
  }
  return nioBuffers;
}

代码示例来源:origin: netty/netty

@Override
public ByteBuffer[] nioBuffers(int index, int length) {
  ByteBuffer[] nioBuffers = buf.nioBuffers(index, length);
  for (int i = 0; i < nioBuffers.length; i++) {
    nioBuffers[i] = nioBuffers[i].order(order);
  }
  return nioBuffers;
}

代码示例来源:origin: redisson/redisson

@Override
public ByteBuffer[] nioBuffers(int index, int length) {
  ByteBuffer[] nioBuffers = buf.nioBuffers(index, length);
  for (int i = 0; i < nioBuffers.length; i++) {
    nioBuffers[i] = nioBuffers[i].order(order);
  }
  return nioBuffers;
}

代码示例来源:origin: netty/netty

private static int nioBuffers(Entry entry, ByteBuf buf, ByteBuffer[] nioBuffers, int nioBufferCount, int maxCount) {
  ByteBuffer[] nioBufs = entry.bufs;
  if (nioBufs == null) {
    // cached ByteBuffers as they may be expensive to create in terms
    // of Object allocation
    entry.bufs = nioBufs = buf.nioBuffers();
  }
  for (int i = 0; i < nioBufs.length && nioBufferCount < maxCount; ++i) {
    ByteBuffer nioBuf = nioBufs[i];
    if (nioBuf == null) {
      break;
    } else if (!nioBuf.hasRemaining()) {
      continue;
    }
    nioBuffers[nioBufferCount++] = nioBuf;
  }
  return nioBufferCount;
}

代码示例来源:origin: redisson/redisson

@Override
public ByteBuffer[] nioBuffers() {
  ByteBuffer[] nioBuffers = buf.nioBuffers();
  for (int i = 0; i < nioBuffers.length; i++) {
    nioBuffers[i] = nioBuffers[i].order(order);
  }
  return nioBuffers;
}

代码示例来源:origin: netty/netty

@Override
public ByteBuffer[] nioBuffers(int index, int length) {
  checkIndex(index, length);
  return buffer.nioBuffers(index, length);
}

代码示例来源:origin: netty/netty

@Override
public ByteBuffer[] nioBuffers(int index, int length) {
  return unwrap().nioBuffers(index, length);
}

代码示例来源:origin: netty/netty

@Override
public ByteBuffer[] nioBuffers(int index, int length) {
  return unwrap().nioBuffers(index, length);
}

代码示例来源:origin: redisson/redisson

@Override
public ByteBuffer[] nioBuffers(int index, int length) {
  checkIndex(index, length);
  return buffer.nioBuffers(index, length);
}

代码示例来源:origin: redisson/redisson

@Override
public ByteBuffer[] nioBuffers(int index, int length) {
  return unwrap().nioBuffers(index, length);
}

代码示例来源:origin: netty/netty

@Override
public ByteBuffer[] nioBuffers(int index, int length) {
  checkIndex0(index, length);
  return unwrap().nioBuffers(idx(index), length);
}

代码示例来源:origin: redisson/redisson

@Override
public ByteBuffer[] nioBuffers(int index, int length) {
  checkIndex0(index, length);
  return unwrap().nioBuffers(idx(index), length);
}

代码示例来源:origin: netty/netty

@Override
public ByteBuf setBytes(int index, ByteBuf src, int srcIndex, int length) {
  checkSrcIndex(index, length, srcIndex, src.capacity());
  if (src.nioBufferCount() > 0) {
    for (ByteBuffer bb: src.nioBuffers(srcIndex, length)) {
      int bbLen = bb.remaining();
      setBytes(index, bb);
      index += bbLen;
    }
  } else {
    src.getBytes(srcIndex, this, index, length);
  }
  return this;
}

代码示例来源:origin: netty/netty

@Override
public ByteBuf getBytes(int index, ByteBuf dst, int dstIndex, int length) {
  checkDstIndex(index, length, dstIndex, dst.capacity());
  if (dst.hasArray()) {
    getBytes(index, dst.array(), dst.arrayOffset() + dstIndex, length);
  } else if (dst.nioBufferCount() > 0) {
    for (ByteBuffer bb: dst.nioBuffers(dstIndex, length)) {
      int bbLen = bb.remaining();
      getBytes(index, bb);
      index += bbLen;
    }
  } else {
    dst.setBytes(dstIndex, this, index, length);
  }
  return this;
}

代码示例来源:origin: netty/netty

@Override
public ByteBuf getBytes(int index, ByteBuf dst, int dstIndex, int length) {
  checkDstIndex(index, length, dstIndex, dst.capacity());
  if (dst.hasArray()) {
    getBytes(index, dst.array(), dst.arrayOffset() + dstIndex, length);
  } else if (dst.nioBufferCount() > 0) {
    for (ByteBuffer bb: dst.nioBuffers(dstIndex, length)) {
      int bbLen = bb.remaining();
      getBytes(index, bb);
      index += bbLen;
    }
  } else {
    dst.setBytes(dstIndex, this, index, length);
  }
  return this;
}

代码示例来源:origin: netty/netty

@Override
public ByteBuf getBytes(int index, ByteBuf dst, int dstIndex, int length) {
  checkDstIndex(index, length, dstIndex, dst.capacity());
  if (dst.hasArray()) {
    getBytes(index, dst.array(), dst.arrayOffset() + dstIndex, length);
  } else if (dst.nioBufferCount() > 0) {
    for (ByteBuffer bb: dst.nioBuffers(dstIndex, length)) {
      int bbLen = bb.remaining();
      getBytes(index, bb);
      index += bbLen;
    }
  } else {
    dst.setBytes(dstIndex, this, index, length);
  }
  return this;
}

代码示例来源:origin: netty/netty

@Override
public ByteBuf setBytes(int index, ByteBuf src, int srcIndex, int length) {
  checkSrcIndex(index, length, srcIndex, src.capacity());
  if (src.hasArray()) {
    setBytes(index, src.array(), src.arrayOffset() + srcIndex, length);
  } else if (src.nioBufferCount() > 0) {
    for (ByteBuffer bb: src.nioBuffers(srcIndex, length)) {
      int bbLen = bb.remaining();
      setBytes(index, bb);
      index += bbLen;
    }
  } else {
    src.getBytes(srcIndex, this, index, length);
  }
  return this;
}

相关文章

ByteBuf类方法