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

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

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

ByteBuf.writeBytes介绍

[英]Transfers the specified source buffer's data to this buffer starting at the current writerIndex until the source buffer becomes unreadable, and increases the writerIndex by the number of the transferred bytes. This method is basically same with #writeBytes(ByteBuf,int,int), except that this method increases the readerIndex of the source buffer by the number of the transferred bytes while #writeBytes(ByteBuf,int,int)does not.
[中]从当前writerIndex开始将指定源缓冲区的数据传输到此缓冲区,直到源缓冲区变得不可读,并将writerIndex增加传输的字节数。此方法与#writeBytes(ByteBuf,int,int)基本相同,只是此方法将源缓冲区的readerIndex增加传输的字节数,而#writeBytes(ByteBuf,int,int)不增加。

代码示例

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

@Override
public void write(byte[] b, int off, int len) throws IOException {
  if (len == 0) {
    return;
  }
  buffer.writeBytes(b, off, len);
}

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

@Override
public ByteBuf writeBytes(ByteBuf src, int srcIndex, int length) {
  buf.writeBytes(src, srcIndex, length);
  return this;
}

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

@Override
public ByteBuf writeBytes(byte[] src) {
  buf.writeBytes(src);
  return this;
}

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

boolean encode(ByteBuf buf) {
    buf.writeBytes(bytes);
    return separatorLen > 0;
  }
}

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

@Override
public ByteBuf writeBytes(ByteBuffer src) {
  buf.writeBytes(src);
  return this;
}

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

/**
 * Encode the key.
 *
 * @param buf the {@link ByteBuf} to write into.
 * @param key the key to encode.
 */
private static void encodeKey(ByteBuf buf, byte[] key) {
  if (key == null || key.length == 0) {
    return;
  }
  buf.writeBytes(key);
}

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

@Override
public ByteBuf writeBytes(ByteBuf src, int length) {
  buf.writeBytes(src, length);
  return this;
}

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

@Override
public ByteBuf writeBytes(ByteBuffer src) {
  buf.writeBytes(src);
  return this;
}

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

@Override
public ByteBuf writeBytes(byte[] src) {
  buf.writeBytes(src);
  return this;
}

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

@SuppressWarnings("deprecation")
static void encode(CharSequence key, CharSequence value, ByteBuf buf) {
  if (!encodeAscii(key, buf)) {
    buf.writeBytes(HEADER_SEPERATOR);
  }
  if (!encodeAscii(value, buf)) {
    buf.writeBytes(CRLF);
  }
}

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

void encode(ByteBuf buf) {
    if (bytes == null) {
      HttpHeaders.encodeAscii0(text, buf);
    } else {
      buf.writeBytes(bytes);
    }
  }
}

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

@Override
public ByteBuf copy(int index, int length) {
  ensureAccessible();
  ByteBuffer src;
  try {
    src = (ByteBuffer) buffer.duplicate().clear().position(index).limit(index + length);
  } catch (IllegalArgumentException ignored) {
    throw new IndexOutOfBoundsException("Too many bytes to read - Need " + (index + length));
  }
  return alloc().directBuffer(length, maxCapacity()).writeBytes(src);
}

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

private static ByteBuf newDirectBuffer0(Object holder, ByteBuf buf, ByteBufAllocator alloc, int capacity) {
  final ByteBuf directBuf = alloc.directBuffer(capacity);
  directBuf.writeBytes(buf, buf.readerIndex(), capacity);
  ReferenceCountUtil.safeRelease(holder);
  return directBuf;
}

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

void encode(ByteBuf buf) {
    if (bytes == null) {
      HttpHeaders.encodeAscii0(String.valueOf(code()), buf);
      buf.writeByte(SP);
      HttpHeaders.encodeAscii0(String.valueOf(reasonPhrase()), buf);
    } else {
      buf.writeBytes(bytes);
    }
  }
}

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

@Override
public ByteBuf readBytes(int length) {
  checkReadableBytes(length);
  if (length == 0) {
    return Unpooled.EMPTY_BUFFER;
  }
  ByteBuf buf = alloc().buffer(length, maxCapacity);
  buf.writeBytes(this, readerIndex, length);
  readerIndex += length;
  return buf;
}

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

@Override
public ByteBuf copy(int index, int length) {
  checkIndex(index, length);
  ByteBuf copy = alloc().directBuffer(length, maxCapacity());
  copy.writeBytes(this, index, length);
  return copy;
}

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

@Override
public final ByteBuf copy(int index, int length) {
  checkIndex(index, length);
  ByteBuf copy = alloc().heapBuffer(length, maxCapacity());
  copy.writeBytes(memory, idx(index), length);
  return copy;
}

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

public ByteBuf encodeDataFrame(ByteBufAllocator allocator, int streamId, boolean last, ByteBuf data) {
  byte flags = last ? SPDY_DATA_FLAG_FIN : 0;
  int length = data.readableBytes();
  ByteBuf frame = allocator.ioBuffer(SPDY_HEADER_SIZE + length).order(ByteOrder.BIG_ENDIAN);
  frame.writeInt(streamId & 0x7FFFFFFF);
  frame.writeByte(flags);
  frame.writeMedium(length);
  frame.writeBytes(data, data.readerIndex(), length);
  return frame;
}

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

private RawQueryResponse handleRawQueryResponse(boolean lastChunk, ChannelHandlerContext ctx) {
  if (!lastChunk) {
    return null;
  }
  ResponseStatus status = ResponseStatusConverter.fromHttp(responseHeader.getStatus().code());
  ByteBuf responseCopy = ctx.alloc().buffer(responseContent.readableBytes(), responseContent.readableBytes());
  responseCopy.writeBytes(responseContent);
  return new RawQueryResponse(status, currentRequest(), responseCopy,
      responseHeader.getStatus().code(),
      responseHeader.getStatus().reasonPhrase());
}

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

private RawAnalyticsResponse handleRawAnalyticsResponse(boolean lastChunk, ChannelHandlerContext ctx) {
  if (!lastChunk) {
    return null;
  }
  ResponseStatus status = ResponseStatusConverter.fromHttp(responseHeader.getStatus().code());
  ByteBuf responseCopy = ctx.alloc().buffer(responseContent.readableBytes(), responseContent.readableBytes());
  responseCopy.writeBytes(responseContent);
  return new RawAnalyticsResponse(status, currentRequest(), responseCopy,
      responseHeader.getStatus().code(),
      responseHeader.getStatus().reasonPhrase());
}

相关文章