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

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

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

ByteBuf.writeShort介绍

[英]Sets the specified 16-bit short integer at the current writerIndex and increases the writerIndex by 2in this buffer. The 16 high-order bits of the specified value are ignored.
[中]在当前writerIndex处设置指定的16位短整数,并在此缓冲区中将writerIndex增加2。指定值的16个高位将被忽略。

代码示例

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

@Override
public ByteBuf writeShort(int value) {
  buf.writeShort(value);
  return this;
}

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

@Override
public ByteBuf writeShort(int value) {
  buf.writeShort(value);
  return this;
}

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

@Override
public void writeShort(int v) throws IOException {
  buffer.writeShort((short) v);
}

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

private void writeControlFrameHeader(ByteBuf buffer, int type, byte flags, int length) {
  buffer.writeShort(version | 0x8000);
  buffer.writeShort(type);
  buffer.writeByte(flags);
  buffer.writeMedium(length);
}

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

@Override
public ByteBuf writeShort(int value) {
  buf.writeShort(ByteBufUtil.swapShort((short) value));
  return this;
}

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

/**
 * Creates a new 2-byte big-endian buffer that holds the specified 16-bit integer.
 */
public static ByteBuf copyShort(int value) {
  ByteBuf buf = buffer(2);
  buf.writeShort(value);
  return buf;
}

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

@Override
public ByteBuf writeShort(int value) {
  buf.writeShort(ByteBufUtil.swapShort((short) value));
  return this;
}

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

/**
 * Create a new big-endian buffer that holds a sequence of the specified 16-bit integers.
 */
public static ByteBuf copyShort(int... values) {
  if (values == null || values.length == 0) {
    return EMPTY_BUFFER;
  }
  ByteBuf buffer = buffer(values.length * 2);
  for (int v: values) {
    buffer.writeShort(v);
  }
  return buffer;
}

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

/**
 * Create a new big-endian buffer that holds a sequence of the specified 16-bit integers.
 */
public static ByteBuf copyShort(short... values) {
  if (values == null || values.length == 0) {
    return EMPTY_BUFFER;
  }
  ByteBuf buffer = buffer(values.length * 2);
  for (int v: values) {
    buffer.writeShort(v);
  }
  return buffer;
}

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

/**
 * Creates a new 2-byte big-endian buffer that holds the specified 16-bit integer.
 */
public static ByteBuf copyShort(int value) {
  ByteBuf buf = buffer(2);
  buf.writeShort(value);
  return buf;
}

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

private void writeControlFrameHeader(ByteBuf buffer, int type, byte flags, int length) {
  buffer.writeShort(version | 0x8000);
  buffer.writeShort(type);
  buffer.writeByte(flags);
  buffer.writeMedium(length);
}

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

/**
 * Create a new big-endian buffer that holds a sequence of the specified 16-bit integers.
 */
public static ByteBuf copyShort(short... values) {
  if (values == null || values.length == 0) {
    return EMPTY_BUFFER;
  }
  ByteBuf buffer = buffer(values.length * 2);
  for (int v: values) {
    buffer.writeShort(v);
  }
  return buffer;
}

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

private static ByteBuf newBinaryData(int statusCode, String reasonText) {
  byte[] reasonBytes = EmptyArrays.EMPTY_BYTES;
  if (reasonText != null) {
    reasonBytes = reasonText.getBytes(CharsetUtil.UTF_8);
  }
  ByteBuf binaryData = Unpooled.buffer(2 + reasonBytes.length);
  binaryData.writeShort(statusCode);
  if (reasonBytes.length > 0) {
    binaryData.writeBytes(reasonBytes);
  }
  binaryData.readerIndex(0);
  return binaryData;
}

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

private static ByteBuf newBinaryData(int statusCode, String reasonText) {
  byte[] reasonBytes = EmptyArrays.EMPTY_BYTES;
  if (reasonText != null) {
    reasonBytes = reasonText.getBytes(CharsetUtil.UTF_8);
  }
  ByteBuf binaryData = Unpooled.buffer(2 + reasonBytes.length);
  binaryData.writeShort(statusCode);
  if (reasonBytes.length > 0) {
    binaryData.writeBytes(reasonBytes);
  }
  binaryData.readerIndex(0);
  return binaryData;
}

代码示例来源:origin: couchbase/java-dcp-client

public static void init(ByteBuf buffer, short vbid, long seqno) {
  buffer.writeByte(MessageUtil.MAGIC_INT);
  buffer.writeByte(MessageUtil.INTERNAL_ROLLBACK_OPCODE);
  buffer.writeShort(vbid);
  buffer.writeLong(seqno);
}

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

/**
 * Creates the request to load the error map.
 */
private FullBinaryMemcacheRequest errorMapRequest() {
  LOGGER.debug("Requesting error map in version {}", MAP_VERSION);
  ByteBuf content = Unpooled.buffer(2).writeShort(MAP_VERSION);
  FullBinaryMemcacheRequest request = new DefaultFullBinaryMemcacheRequest(
    new byte[] {}, Unpooled.EMPTY_BUFFER, content
  );
  request.setOpcode(GET_ERROR_MAP_CMD);
  request.setTotalBodyLength(content.readableBytes());
  return request;
}

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

@Override
protected void encodeHeader(ByteBuf buf, BinaryMemcacheResponse msg) {
  buf.writeByte(msg.getMagic());
  buf.writeByte(msg.getOpcode());
  buf.writeShort(msg.getKeyLength());
  buf.writeByte(msg.getExtrasLength());
  buf.writeByte(msg.getDataType());
  buf.writeShort(msg.getStatus());
  buf.writeInt(msg.getTotalBodyLength());
  buf.writeInt(msg.getOpaque());
  buf.writeLong(msg.getCAS());
}

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

@Override
protected void encodeHeader(ByteBuf buf, BinaryMemcacheRequest msg) {
  buf.writeByte(msg.getMagic());
  buf.writeByte(msg.getOpcode());
  buf.writeShort(msg.getKeyLength());
  buf.writeByte(msg.getExtrasLength());
  buf.writeByte(msg.getDataType());
  buf.writeShort(msg.getReserved());
  buf.writeInt(msg.getTotalBodyLength());
  buf.writeInt(msg.getOpaque());
  buf.writeLong(msg.getCAS());
}

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

@Override
protected void encodeHeader(ByteBuf buf, BinaryMemcacheRequest msg) {
  buf.writeByte(msg.getMagic());
  buf.writeByte(msg.getOpcode());
  buf.writeShort(msg.getKeyLength());
  buf.writeByte(msg.getExtrasLength());
  buf.writeByte(msg.getDataType());
  buf.writeShort(msg.getReserved());
  buf.writeInt(msg.getTotalBodyLength());
  buf.writeInt(msg.getOpaque());
  buf.writeLong(msg.getCAS());
}

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

@Override
protected void encodeHeader(ByteBuf buf, BinaryMemcacheResponse msg) {
  buf.writeByte(msg.getMagic());
  buf.writeByte(msg.getOpcode());
  buf.writeShort(msg.getKeyLength());
  buf.writeByte(msg.getExtrasLength());
  buf.writeByte(msg.getDataType());
  buf.writeShort(msg.getStatus());
  buf.writeInt(msg.getTotalBodyLength());
  buf.writeInt(msg.getOpaque());
  buf.writeLong(msg.getCAS());
}

相关文章