io.vertx.core.buffer.Buffer.appendShort()方法的使用及代码示例

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

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

Buffer.appendShort介绍

[英]Appends the specified short to the end of the Buffer.The buffer will expand as necessary to accommodate any bytes written.

Returns a reference to this so multiple operations can be appended together.
[中]将指定的短字符追加到缓冲区的末尾。缓冲区将根据需要扩展以容纳写入的任何字节。
返回对此的引用,以便可以将多个操作附加在一起。

代码示例

代码示例来源:origin: eclipse-vertx/vert.x

@Override
public void encodeToWire(Buffer buffer, Short s) {
 buffer.appendShort(s);
}

代码示例来源:origin: eclipse-vertx/vert.x

@Test
public void testAppendShort() {
 Buffer b = Buffer.buffer(TestUtils.randomByteArray(100));
 b.appendShort(Short.MAX_VALUE);
 assertEquals(102, b.length());
 b.appendShortLE(Short.MAX_VALUE);
 assertEquals(104, b.length());
}

代码示例来源:origin: eclipse-vertx/vert.x

@Override
public void encodeToWire(Buffer buffer, Character chr) {
 buffer.appendShort((short)chr.charValue());
}

代码示例来源:origin: eclipse-vertx/vert.x

@Test
public void testLE() {
 checkBEAndLE(2, Buffer.buffer().appendShort(Short.MAX_VALUE), Buffer.buffer().appendShortLE(Short.MAX_VALUE));
 checkBEAndLE(2, Buffer.buffer().appendUnsignedShort(Short.MAX_VALUE), Buffer.buffer().appendUnsignedShortLE(Short.MAX_VALUE));
 checkBEAndLE(3, Buffer.buffer().appendMedium(Integer.MAX_VALUE / 2), Buffer.buffer().appendMediumLE(Integer.MAX_VALUE / 2));
 checkBEAndLE(4, Buffer.buffer().appendInt(Integer.MAX_VALUE), Buffer.buffer().appendIntLE(Integer.MAX_VALUE));
 checkBEAndLE(4, Buffer.buffer().appendUnsignedInt(Integer.MAX_VALUE), Buffer.buffer().appendUnsignedIntLE(Integer.MAX_VALUE));
 checkBEAndLE(8, Buffer.buffer().appendLong(Long.MAX_VALUE), Buffer.buffer().appendLongLE(Long.MAX_VALUE));
}

代码示例来源:origin: io.vertx/vertx-core

@Override
public void encodeToWire(Buffer buffer, Short s) {
 buffer.appendShort(s);
}

代码示例来源:origin: io.vertx/vertx-core

@Test
public void testAppendShort() {
 Buffer b = Buffer.buffer(TestUtils.randomByteArray(100));
 b.appendShort(Short.MAX_VALUE);
 assertEquals(102, b.length());
 b.appendShortLE(Short.MAX_VALUE);
 assertEquals(104, b.length());
}

代码示例来源:origin: io.vertx/vertx-core

@Override
public void encodeToWire(Buffer buffer, Character chr) {
 buffer.appendShort((short)chr.charValue());
}

代码示例来源:origin: io.vertx/vertx-core

@Test
public void testLE() {
 checkBEAndLE(2, Buffer.buffer().appendShort(Short.MAX_VALUE), Buffer.buffer().appendShortLE(Short.MAX_VALUE));
 checkBEAndLE(2, Buffer.buffer().appendUnsignedShort(Short.MAX_VALUE), Buffer.buffer().appendUnsignedShortLE(Short.MAX_VALUE));
 checkBEAndLE(3, Buffer.buffer().appendMedium(Integer.MAX_VALUE / 2), Buffer.buffer().appendMediumLE(Integer.MAX_VALUE / 2));
 checkBEAndLE(4, Buffer.buffer().appendInt(Integer.MAX_VALUE), Buffer.buffer().appendIntLE(Integer.MAX_VALUE));
 checkBEAndLE(4, Buffer.buffer().appendUnsignedInt(Integer.MAX_VALUE), Buffer.buffer().appendUnsignedIntLE(Integer.MAX_VALUE));
 checkBEAndLE(8, Buffer.buffer().appendLong(Long.MAX_VALUE), Buffer.buffer().appendLongLE(Long.MAX_VALUE));
}

代码示例来源:origin: advantageous/qbit

public static void writeString(final Buffer buffer, final String value) {
  byte[] string = value.getBytes(StandardCharsets.UTF_8);
  buffer.appendShort((short) string.length);
  buffer.appendBytes(string);
}

代码示例来源:origin: advantageous/qbit

public static void writeMap(final Buffer buffer, final MultiMap<String, String> params) {
  buffer.appendShort((short) params.size());
  final Set<String> keys = params.keySet();
  for (String key : keys) {
    writeString(buffer, key);
    final Collection<String> values = (Collection<String>) params.getAll(key);
    buffer.appendShort((short) values.size());
    for (String value : values) {
      writeString(buffer, value);
    }
  }
}

代码示例来源:origin: vert-x3/vertx-web

buffer.appendByte(TYPE_INT).appendInt((int) val);
} else if (val instanceof Short) {
 buffer.appendByte(TYPE_SHORT).appendShort((short) val);
} else if (val instanceof Byte) {
 buffer.appendByte(TYPE_BYTE).appendByte((byte) val);
 buffer.appendByte(TYPE_FLOAT).appendFloat((float) val);
} else if (val instanceof Character) {
 buffer.appendByte(TYPE_CHAR).appendShort((short) ((Character) val).charValue());
} else if (val instanceof Boolean) {
 buffer.appendByte(TYPE_BOOLEAN).appendByte((byte) ((boolean) val ? 1 : 0));

代码示例来源:origin: io.vertx/vertx-rx-java

/**
 * Appends the specified <code>short</code> to the end of the Buffer.The buffer will expand as necessary to accommodate any bytes written.<p>
 * Returns a reference to <code>this</code> so multiple operations can be appended together.
 * @param s 
 * @return 
 */
public io.vertx.rxjava.core.buffer.Buffer appendShort(short s) { 
 delegate.appendShort(s);
 return this;
}

代码示例来源:origin: vert-x3/vertx-rx

/**
 * Appends the specified <code>short</code> to the end of the Buffer.The buffer will expand as necessary to accommodate any bytes written.<p>
 * Returns a reference to <code>this</code> so multiple operations can be appended together.
 * @param s 
 * @return 
 */
public io.vertx.rxjava.core.buffer.Buffer appendShort(short s) { 
 delegate.appendShort(s);
 return this;
}

代码示例来源:origin: io.advantageous.qbit/qbit-vertx

public static void writeString(final Buffer buffer, final String value) {
  byte[] string = value.getBytes(StandardCharsets.UTF_8);
  buffer.appendShort((short) string.length);
  buffer.appendBytes(string);
}

代码示例来源:origin: pmlopes/vertx-bson-codec

public static void appendShort(Buffer buffer, short value) {
 buffer.appendShort(Short.reverseBytes(value));
}

代码示例来源:origin: io.advantageous.qbit/qbit-vertx

public static void writeMap(final Buffer buffer, final MultiMap<String, String> params) {
  buffer.appendShort((short) params.size());
  final Set<String> keys = params.keySet();
  for (String key : keys) {
    writeString(buffer, key);
    final Collection<String> values = (Collection<String>) params.getAll(key);
    buffer.appendShort((short) values.size());
    for (String value : values) {
      writeString(buffer, value);
    }
  }
}

代码示例来源:origin: io.vertx/vertx-web

buffer.appendByte(TYPE_INT).appendInt((int) val);
} else if (val instanceof Short) {
 buffer.appendByte(TYPE_SHORT).appendShort((short) val);
} else if (val instanceof Byte) {
 buffer.appendByte(TYPE_BYTE).appendByte((byte) val);
 buffer.appendByte(TYPE_FLOAT).appendFloat((float) val);
} else if (val instanceof Character) {
 buffer.appendByte(TYPE_CHAR).appendShort((short) ((Character) val).charValue());
} else if (val instanceof Boolean) {
 buffer.appendByte(TYPE_BOOLEAN).appendByte((byte) ((boolean) val ? 1 : 0));

相关文章

微信公众号

最新文章

更多