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

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

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

Buffer.getUnsignedShort介绍

[英]Returns the unsigned short at position pos in the Buffer, as an int.
[中]

代码示例

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

static Http2Settings decodeSettings(String base64Settings) {
 try {
  Http2Settings settings = new Http2Settings();
  Buffer buffer = Buffer.buffer(Base64.getUrlDecoder().decode(base64Settings));
  int pos = 0;
  int len = buffer.length();
  while (pos < len) {
   int i = buffer.getUnsignedShort(pos);
   pos += 2;
   long j = buffer.getUnsignedInt(pos);
   pos += 4;
   settings.put((char)i, (Long)j);
  }
  return settings;
 } catch (Exception ignore) {
 }
 return null;
}

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

private void testGetSetUnsignedShort(boolean isLE) throws Exception {
 int numShorts = 100;
 Buffer b = Buffer.buffer(numShorts * 2);
 for (short i = 0; i < numShorts; i++) {
  if (isLE) {
   b.setUnsignedShortLE(i * 2, (short) (Short.MAX_VALUE + (int) i));
  } else {
   b.setUnsignedShort(i * 2, (short) (Short.MAX_VALUE + (int) i));
  }
 }
 for (short i = 0; i < numShorts; i++) {
  if (isLE) {
   assertEquals(Integer.toUnsignedLong(Short.MAX_VALUE + i), b.getUnsignedShortLE(i * 2));
  } else {
   assertEquals(Integer.toUnsignedLong(Short.MAX_VALUE + i), b.getUnsignedShort(i * 2));
  }
 }
}

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

private void testSetUnsignedShort(Buffer buff) throws Exception {
 for (int i = 0; i < numSets; i++) {
  int val = Short.MAX_VALUE + i;
  buff.setUnsignedShort(i * 2, val);
 }
 for (int i = 0; i < numSets; i++) {
  int val = Short.MAX_VALUE + i;
  assertEquals(val, buff.getUnsignedShort(i * 2));
 }
}

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

private void testGetSetUnsignedShort(boolean isLE) throws Exception {
 int numShorts = 100;
 Buffer b = Buffer.buffer(numShorts * 2);
 for (short i = 0; i < numShorts; i++) {
  if (isLE) {
   b.setUnsignedShortLE(i * 2, (short) (Short.MAX_VALUE + (int) i));
  } else {
   b.setUnsignedShort(i * 2, (short) (Short.MAX_VALUE + (int) i));
  }
 }
 for (short i = 0; i < numShorts; i++) {
  if (isLE) {
   assertEquals(Integer.toUnsignedLong(Short.MAX_VALUE + i), b.getUnsignedShortLE(i * 2));
  } else {
   assertEquals(Integer.toUnsignedLong(Short.MAX_VALUE + i), b.getUnsignedShort(i * 2));
  }
 }
}

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

int port = buffer.getUnsignedShort(2);
String ip = getByte4(buffer.getBuffer(4, 8));

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

buffer2.getUnsignedByte(6) + "." +
  buffer2.getUnsignedByte(7);
 port = buffer2.getUnsignedShort(8);
} else if(addressType == 3) {
 int stringLen = buffer2.getUnsignedByte(4);
 port = buffer2.getUnsignedShort(5 + stringLen);
} else {
 throw new IllegalStateException("expected address type ip (v4) or name, got " + addressType);

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

static Http2Settings decodeSettings(String base64Settings) {
 try {
  Http2Settings settings = new Http2Settings();
  Buffer buffer = Buffer.buffer(Base64.getUrlDecoder().decode(base64Settings));
  int pos = 0;
  int len = buffer.length();
  while (pos < len) {
   int i = buffer.getUnsignedShort(pos);
   pos += 2;
   long j = buffer.getUnsignedInt(pos);
   pos += 4;
   settings.put((char)i, (Long)j);
  }
  return settings;
 } catch (Exception ignore) {
 }
 return null;
}

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

private void testSetUnsignedShort(Buffer buff) throws Exception {
 for (int i = 0; i < numSets; i++) {
  int val = Short.MAX_VALUE + i;
  buff.setUnsignedShort(i * 2, val);
 }
 for (int i = 0; i < numSets; i++) {
  int val = Short.MAX_VALUE + i;
  assertEquals(val, buff.getUnsignedShort(i * 2));
 }
}

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

/**
 * Returns the unsigned <code>short</code> at position <code>pos</code> in the Buffer, as an <code>int</code>.
 * @param pos 
 * @return 
 */
public int getUnsignedShort(int pos) { 
 int ret = delegate.getUnsignedShort(pos);
 return ret;
}

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

/**
 * Returns the unsigned <code>short</code> at position <code>pos</code> in the Buffer, as an <code>int</code>.
 * @param pos 
 * @return 
 */
public int getUnsignedShort(int pos) { 
 int ret = delegate.getUnsignedShort(pos);
 return ret;
}

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

int port = buffer.getUnsignedShort(2);
String ip = getByte4(buffer.getBuffer(4, 8));

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

buffer2.getUnsignedByte(6) + "." +
  buffer2.getUnsignedByte(7);
 port = buffer2.getUnsignedShort(8);
} else if(addressType == 3) {
 int stringLen = buffer2.getUnsignedByte(4);
 port = buffer2.getUnsignedShort(5 + stringLen);
} else {
 throw new IllegalStateException("expected address type ip (v4) or name, got " + addressType);

相关文章