com.couchbase.client.deps.io.netty.buffer.ByteBuf.writerIndex()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(5.5k)|赞(0)|评价(0)|浏览(258)

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

ByteBuf.writerIndex介绍

[英]Returns the writerIndex of this buffer.
[中]

代码示例

代码示例来源:origin: com.couchbase.client/core-io

  1. /**
  2. * Returns the number of written bytes by this stream so far.
  3. */
  4. public int writtenBytes() {
  5. return buffer.writerIndex() - startIndex;
  6. }

代码示例来源:origin: com.couchbase.client/core-io

  1. @Override
  2. public final ByteBuf writerIndex(int writerIndex) {
  3. buf.writerIndex(writerIndex);
  4. return this;
  5. }

代码示例来源:origin: com.couchbase.client/core-io

  1. private void checkIndex(int index, int length) {
  2. if (index + length > buffer.writerIndex()) {
  3. throw REPLAY;
  4. }
  5. }

代码示例来源:origin: com.couchbase.client/core-io

  1. @Override
  2. public ByteBuf writerIndex(int writerIndex) {
  3. buf.writerIndex(writerIndex);
  4. return this;
  5. }

代码示例来源:origin: couchbase/couchbase-jvm-core

  1. private void checkIndex(int index, int length) {
  2. if (index + length > buffer.writerIndex()) {
  3. throw REPLAY;
  4. }
  5. }

代码示例来源:origin: com.couchbase.client/core-io

  1. @Override
  2. public ByteBuf getBytes(int index, ByteBuf dst, int length) {
  3. getBytes(index, dst, dst.writerIndex(), length);
  4. dst.writerIndex(dst.writerIndex() + length);
  5. return this;
  6. }

代码示例来源:origin: com.couchbase.client/core-io

  1. /**
  2. * Creates a new stream which writes data to the specified {@code buffer}.
  3. */
  4. public ByteBufOutputStream(ByteBuf buffer) {
  5. if (buffer == null) {
  6. throw new NullPointerException("buffer");
  7. }
  8. this.buffer = buffer;
  9. startIndex = buffer.writerIndex();
  10. }

代码示例来源:origin: com.couchbase.client/core-io

  1. private boolean compressInto(ByteBuf compressed) {
  2. byte[] out = compressed.array();
  3. int off = compressed.arrayOffset() + compressed.writerIndex();
  4. int toWrite = compressed.writableBytes();
  5. int numBytes = compressor.deflate(out, off, toWrite, Deflater.SYNC_FLUSH);
  6. compressed.writerIndex(compressed.writerIndex() + numBytes);
  7. return numBytes == toWrite;
  8. }

代码示例来源:origin: com.couchbase.client/core-io

  1. @Override
  2. public ByteBuf readBytes(ByteBuf dst, int length) {
  3. if (length > dst.writableBytes()) {
  4. throw new IndexOutOfBoundsException(String.format(
  5. "length(%d) exceeds dst.writableBytes(%d) where dst is: %s", length, dst.writableBytes(), dst));
  6. }
  7. readBytes(dst, dst.writerIndex(), length);
  8. dst.writerIndex(dst.writerIndex() + length);
  9. return this;
  10. }

代码示例来源:origin: com.couchbase.client/core-io

  1. @Override
  2. SSLEngineResult unwrap(SslHandler handler, ByteBuf in, int readerIndex, int len, ByteBuf out)
  3. throws SSLException {
  4. int writerIndex = out.writerIndex();
  5. final SSLEngineResult result = handler.engine.unwrap(toByteBuffer(in, readerIndex, len),
  6. toByteBuffer(out, writerIndex, out.writableBytes()));
  7. out.writerIndex(writerIndex + result.bytesProduced());
  8. return result;
  9. }

代码示例来源:origin: com.couchbase.client/core-io

  1. @Override
  2. public int indexOf(int fromIndex, int toIndex, byte value) {
  3. if (fromIndex == toIndex) {
  4. return -1;
  5. }
  6. if (Math.max(fromIndex, toIndex) > buffer.writerIndex()) {
  7. throw REPLAY;
  8. }
  9. return buffer.indexOf(fromIndex, toIndex, value);
  10. }

代码示例来源:origin: couchbase/couchbase-jvm-core

  1. @Override
  2. public int indexOf(int fromIndex, int toIndex, byte value) {
  3. if (fromIndex == toIndex) {
  4. return -1;
  5. }
  6. if (Math.max(fromIndex, toIndex) > buffer.writerIndex()) {
  7. throw REPLAY;
  8. }
  9. return buffer.indexOf(fromIndex, toIndex, value);
  10. }

代码示例来源:origin: com.couchbase.client/core-io

  1. @Override
  2. public int bytesBefore(int length, byte value) {
  3. final int readerIndex = buffer.readerIndex();
  4. return bytesBefore(readerIndex, buffer.writerIndex() - readerIndex, value);
  5. }

代码示例来源:origin: couchbase/couchbase-jvm-core

  1. @Override
  2. public int bytesBefore(int length, byte value) {
  3. final int readerIndex = buffer.readerIndex();
  4. return bytesBefore(readerIndex, buffer.writerIndex() - readerIndex, value);
  5. }

代码示例来源:origin: com.couchbase.client/core-io

  1. public static ByteBuf encode(ByteBuf src, boolean breakLines, Base64Dialect dialect) {
  2. if (src == null) {
  3. throw new NullPointerException("src");
  4. }
  5. ByteBuf dest = encode(src, src.readerIndex(), src.readableBytes(), breakLines, dialect);
  6. src.readerIndex(src.writerIndex());
  7. return dest;
  8. }

代码示例来源:origin: com.couchbase.client/core-io

  1. private static void setChunkLength(ByteBuf out, int lengthIdx) {
  2. int chunkLength = out.writerIndex() - lengthIdx - 3;
  3. if (chunkLength >>> 24 != 0) {
  4. throw new CompressionException("compressed data too large: " + chunkLength);
  5. }
  6. out.setMedium(lengthIdx, ByteBufUtil.swapMedium(chunkLength));
  7. }

代码示例来源:origin: couchbase/couchbase-jvm-core

  1. public static ByteBuf decode(ByteBuf src, Base64Dialect dialect) {
  2. if (src == null) {
  3. throw new NullPointerException("src");
  4. }
  5. ByteBuf dest = decode(src, src.readerIndex(), src.readableBytes(), dialect);
  6. src.readerIndex(src.writerIndex());
  7. return dest;
  8. }

代码示例来源:origin: com.couchbase.client/core-io

  1. public ReadOnlyByteBuf(ByteBuf buffer) {
  2. super(buffer.maxCapacity());
  3. if (buffer instanceof ReadOnlyByteBuf || buffer instanceof DuplicatedByteBuf) {
  4. this.buffer = buffer.unwrap();
  5. } else {
  6. this.buffer = buffer;
  7. }
  8. setIndex(buffer.readerIndex(), buffer.writerIndex());
  9. }

代码示例来源:origin: com.couchbase.client/core-io

  1. /**
  2. * Same as {@link Base64#encode(ByteBuf, boolean)} but allows the use of a custom {@link ByteBufAllocator}.
  3. *
  4. * @see Base64#encode(ByteBuf, boolean)
  5. */
  6. static ByteBuf toBase64(ByteBufAllocator allocator, ByteBuf src) {
  7. ByteBuf dst = Base64.encode(src, src.readerIndex(),
  8. src.readableBytes(), true, Base64Dialect.STANDARD, allocator);
  9. src.readerIndex(src.writerIndex());
  10. return dst;
  11. }

代码示例来源:origin: com.couchbase.client/core-io

  1. public DuplicatedByteBuf(ByteBuf buffer) {
  2. super(buffer.maxCapacity());
  3. if (buffer instanceof DuplicatedByteBuf) {
  4. this.buffer = ((DuplicatedByteBuf) buffer).buffer;
  5. } else {
  6. this.buffer = buffer;
  7. }
  8. setIndex(buffer.readerIndex(), buffer.writerIndex());
  9. markReaderIndex();
  10. markWriterIndex();
  11. }

相关文章