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

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

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

Buffer.getShort介绍

[英]Returns the short at position pos in the Buffer.
[中]

代码示例

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

@Override
public Character decodeFromWire(int pos, Buffer buffer) {
 return (char)buffer.getShort(pos);
}

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

private void testGetSetShort(boolean isLE) throws Exception {
 int numShorts = 100;
 Buffer b = Buffer.buffer(numShorts * 2);
 for (short i = 0; i < numShorts; i++) {
  if (isLE) {
   b.setShortLE(i * 2, i);
  } else {
   b.setShort(i * 2, i);
  }
 }
 for (short i = 0; i < numShorts; i++) {
  if (isLE) {
   assertEquals(i, b.getShortLE(i * 2));
  } else {
   assertEquals(i, b.getShort(i * 2));
  }
 }
}

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

@Override
public Short decodeFromWire(int pos, Buffer buffer) {
 return buffer.getShort(pos);
}

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

private void testGetSetShort(boolean isLE) throws Exception {
 int numShorts = 100;
 Buffer b = Buffer.buffer(numShorts * 2);
 for (short i = 0; i < numShorts; i++) {
  if (isLE) {
   b.setShortLE(i * 2, i);
  } else {
   b.setShort(i * 2, i);
  }
 }
 for (short i = 0; i < numShorts; i++) {
  if (isLE) {
   assertEquals(i, b.getShortLE(i * 2));
  } else {
   assertEquals(i, b.getShort(i * 2));
  }
 }
}

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

private void testSetShort(Buffer buff) throws Exception {
 for (int i = 0; i < numSets; i++) {
  buff.setShort(i * 2, (short) i);
 }
 for (int i = 0; i < numSets; i++) {
  assertEquals(i, buff.getShort(i * 2));
 }
}

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

@Override
public Character decodeFromWire(int pos, Buffer buffer) {
 return (char)buffer.getShort(pos);
}

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

@Override
public Short decodeFromWire(int pos, Buffer buffer) {
 return buffer.getShort(pos);
}

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

public static String readString(final Buffer buffer, final int[] location) {
  final short size = buffer.getShort(location[0]);
  int start = location[0] + 2;
  int end = start + size;
  final String utf_8 = buffer.getString(start, end, StandardCharsets.UTF_8.displayName());
  location[0] = end;
  return utf_8;
}

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

assertIndexOutOfBoundsException(() -> b.getDouble(-1));
assertIndexOutOfBoundsException(() -> b.getDouble(-100));
assertIndexOutOfBoundsException(() -> b.getShort(bytesLen));
assertIndexOutOfBoundsException(() -> b.getShort(bytesLen + 1));
assertIndexOutOfBoundsException(() -> b.getShort(bytesLen + 100));
assertIndexOutOfBoundsException(() -> b.getShort(-1));
assertIndexOutOfBoundsException(() -> b.getShort(-100));
assertIndexOutOfBoundsException(() -> b.getBytes(bytesLen + 1, bytesLen + 1));
assertIndexOutOfBoundsException(() -> b.getBytes(bytesLen + 100, bytesLen + 100));

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

public static MultiMap<String, String> readMap(Buffer buffer, int[] locationHolder) {
  int location = locationHolder[0];
  final short size = buffer.getShort(location);
  MultiMap<String, String> map = size > 0 ? new MultiMapImpl<>() : MultiMap.EMPTY;
  location += 2;
  locationHolder[0] = location;
  for (int index = 0; index < size; index++) {
    String key = readString(buffer, locationHolder);
    location = locationHolder[0];
    short valuesSize = buffer.getShort(location);
    location += 2;
    locationHolder[0] = location;
    for (int valueIndex = 0; valueIndex < valuesSize; valueIndex++) {
      String value = readString(buffer, locationHolder);
      map.add(key, value);
    }
  }
  return map;
}

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

private void testSetShort(Buffer buff) throws Exception {
 for (int i = 0; i < numSets; i++) {
  buff.setShort(i * 2, (short) i);
 }
 for (int i = 0; i < numSets; i++) {
  assertEquals(i, buff.getShort(i * 2));
 }
}

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

@Test
public void testWriteString() throws Exception {
  Buffer buffer = Buffer.buffer();
  BufferUtils.writeString(buffer, "hi mom");
  final short size = buffer.getShort(0);
  ok = size == 6 || die();
  final String utf_8 = buffer.getString(2, size + 2, StandardCharsets.UTF_8.displayName());
  puts(utf_8);
  ok = utf_8.equals("hi mom") || die();
}

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

break;
case TYPE_SHORT:
 val = buffer.getShort(pos);
 pos += 2;
 break;
 break;
case TYPE_CHAR:
 short s = buffer.getShort(pos);
 pos += 2;
 val = (char) s;

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

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

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

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

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

public static String readString(final Buffer buffer, final int[] location) {
  final short size = buffer.getShort(location[0]);
  int start = location[0] + 2;
  int end = start + size;
  final String utf_8 = buffer.getString(start, end, StandardCharsets.UTF_8.displayName());
  location[0] = end;
  return utf_8;
}

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

public static MultiMap<String, String> readMap(Buffer buffer, int[] locationHolder) {
  int location = locationHolder[0];
  final short size = buffer.getShort(location);
  MultiMap<String, String> map = size > 0 ? new MultiMapImpl<>() : MultiMap.EMPTY;
  location += 2;
  locationHolder[0] = location;
  for (int index = 0; index < size; index++) {
    String key = readString(buffer, locationHolder);
    location = locationHolder[0];
    short valuesSize = buffer.getShort(location);
    location += 2;
    locationHolder[0] = location;
    for (int valueIndex = 0; valueIndex < valuesSize; valueIndex++) {
      String value = readString(buffer, locationHolder);
      map.add(key, value);
    }
  }
  return map;
}

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

assertIndexOutOfBoundsException(() -> b.getDouble(-1));
assertIndexOutOfBoundsException(() -> b.getDouble(-100));
assertIndexOutOfBoundsException(() -> b.getShort(bytesLen));
assertIndexOutOfBoundsException(() -> b.getShort(bytesLen + 1));
assertIndexOutOfBoundsException(() -> b.getShort(bytesLen + 100));
assertIndexOutOfBoundsException(() -> b.getShort(-1));
assertIndexOutOfBoundsException(() -> b.getShort(-100));
assertIndexOutOfBoundsException(() -> b.getBytes(bytesLen + 1, bytesLen + 1));
assertIndexOutOfBoundsException(() -> b.getBytes(bytesLen + 100, bytesLen + 100));

代码示例来源:origin: com.jukusoft/vertx-binary-serializer

short version = msg.getShort(_pos);
_pos += 2;
        char character = (char) msg.getShort(_pos);
        _pos += 2;
        short s = msg.getShort(_pos);
        _pos += 2;

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

break;
case TYPE_SHORT:
 val = buffer.getShort(pos);
 pos += 2;
 break;
 break;
case TYPE_CHAR:
 short s = buffer.getShort(pos);
 pos += 2;
 val = (char) s;

相关文章