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

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

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

Buffer.getLong介绍

[英]Returns the long at position pos in the Buffer.
[中]返回缓冲区中的long at位置pos。

代码示例

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

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

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

private void testGetSetLong(boolean isLE) throws Exception {
 int numLongs = 100;
 Buffer b = Buffer.buffer(numLongs * 8);
 for (int i = 0; i < numLongs; i++) {
  if (isLE) {
   b.setLongLE(i * 8, i);
  } else {
   b.setLong(i * 8, i);
  }
 }
 for (int i = 0; i < numLongs; i++) {
  if (isLE) {
   assertEquals(i, b.getLongLE(i * 8));
  } else {
   assertEquals(i, b.getLong(i * 8));
  }
 }
}

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

@Override
public HttpConnection ping(Buffer data, Handler<AsyncResult<Buffer>> pongHandler) {
 if (data.length() != 8) {
  throw new IllegalArgumentException("Ping data must be exactly 8 bytes");
 }
 handler.writePing(data.getLong(0)).addListener(fut -> {
  if (fut.isSuccess()) {
   synchronized (Http2ConnectionBase.this) {
    pongHandlers.add(pongHandler);
   }
  } else {
   pongHandler.handle(Future.failedFuture(fut.cause()));
  }
 });
 return this;
}

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

private void testGetSetLong(boolean isLE) throws Exception {
 int numLongs = 100;
 Buffer b = Buffer.buffer(numLongs * 8);
 for (int i = 0; i < numLongs; i++) {
  if (isLE) {
   b.setLongLE(i * 8, i);
  } else {
   b.setLong(i * 8, i);
  }
 }
 for (int i = 0; i < numLongs; i++) {
  if (isLE) {
   assertEquals(i, b.getLongLE(i * 8));
  } else {
   assertEquals(i, b.getLong(i * 8));
  }
 }
}

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

private void testSetLong(Buffer buff) throws Exception {
 for (int i = 0; i < numSets; i++) {
  buff.setLong(i * 8, i);
 }
 for (int i = 0; i < numSets; i++) {
  assertEquals(i, buff.getLong(i * 8));
 }
}

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

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

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

@Test
public void testSlice1() throws Exception {
 Buffer buff = TestUtils.randomBuffer(100);
 Buffer sliced = buff.slice();
 assertEquals(buff, sliced);
 long rand = TestUtils.randomLong();
 sliced.setLong(0, rand);
 assertEquals(rand, buff.getLong(0));
 buff.appendString(TestUtils.randomUnicodeString(100));
 assertEquals(100, sliced.length());
}

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

@Test
public void testSlice2() throws Exception {
 Buffer buff = TestUtils.randomBuffer(100);
 Buffer sliced = buff.slice(10, 20);
 for (int i = 0; i < 10; i++) {
  assertEquals(buff.getByte(10 + i), sliced.getByte(i));
 }
 long rand = TestUtils.randomLong();
 sliced.setLong(0, rand);
 assertEquals(rand, buff.getLong(10));
 buff.appendString(TestUtils.randomUnicodeString(100));
 assertEquals(10, sliced.length());
}

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

@Override
public HttpConnection ping(Buffer data, Handler<AsyncResult<Buffer>> pongHandler) {
 if (data.length() != 8) {
  throw new IllegalArgumentException("Ping data must be exactly 8 bytes");
 }
 handler.writePing(data.getLong(0)).addListener(fut -> {
  if (fut.isSuccess()) {
   synchronized (Http2ConnectionBase.this) {
    pongHandlers.add(pongHandler);
   }
  } else {
   pongHandler.handle(Future.failedFuture(fut.cause()));
  }
 });
 return this;
}

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

assertIndexOutOfBoundsException(() -> b.getInt(-1));
assertIndexOutOfBoundsException(() -> b.getInt(-100));
assertIndexOutOfBoundsException(() -> b.getLong(bytesLen));
assertIndexOutOfBoundsException(() -> b.getLong(bytesLen + 1));
assertIndexOutOfBoundsException(() -> b.getLong(bytesLen + 100));
assertIndexOutOfBoundsException(() -> b.getLong(-1));
assertIndexOutOfBoundsException(() -> b.getLong(-100));
assertIndexOutOfBoundsException(() -> b.getFloat(bytesLen));
assertIndexOutOfBoundsException(() -> b.getFloat(bytesLen + 1));

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

@Override
public int readFromBuffer(int pos, Buffer buffer) {
 int len = buffer.getInt(pos);
 pos += 4;
 byte[] bytes = buffer.getBytes(pos, pos + len);
 pos += len;
 setId(new String(bytes, UTF8));
 setTimeout(buffer.getLong(pos));
 pos += 8;
 setLastAccessed(buffer.getLong(pos));
 pos += 8;
 setVersion(buffer.getInt(pos));
 pos += 4;
 int start = pos;
 pos = readDataFromBuffer(pos, buffer);
 int end = pos;
 return pos;
}

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

private void testSetLong(Buffer buff) throws Exception {
 for (int i = 0; i < numSets; i++) {
  buff.setLong(i * 8, i);
 }
 for (int i = 0; i < numSets; i++) {
  assertEquals(i, buff.getLong(i * 8));
 }
}

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

switch (type) {
 case TYPE_LONG:
  val = buffer.getLong(pos);
  pos += 8;
  break;

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

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

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

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

代码示例来源:origin: net.consensys.cava/cava-bytes

@Override
public long getLong(int i) {
 return buffer.getLong(i);
}

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

public static long getLong(Buffer buffer, int pos) {
 return Long.reverseBytes(buffer.getLong(pos));
}

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

@Test
public void testSlice1() throws Exception {
 Buffer buff = TestUtils.randomBuffer(100);
 Buffer sliced = buff.slice();
 assertEquals(buff, sliced);
 long rand = TestUtils.randomLong();
 sliced.setLong(0, rand);
 assertEquals(rand, buff.getLong(0));
 buff.appendString(TestUtils.randomUnicodeString(100));
 assertEquals(100, sliced.length());
}

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

@Test
public void testSlice2() throws Exception {
 Buffer buff = TestUtils.randomBuffer(100);
 Buffer sliced = buff.slice(10, 20);
 for (int i = 0; i < 10; i++) {
  assertEquals(buff.getByte(10 + i), sliced.getByte(i));
 }
 long rand = TestUtils.randomLong();
 sliced.setLong(0, rand);
 assertEquals(rand, buff.getLong(10));
 buff.appendString(TestUtils.randomUnicodeString(100));
 assertEquals(10, sliced.length());
}

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

assertIndexOutOfBoundsException(() -> b.getInt(-1));
assertIndexOutOfBoundsException(() -> b.getInt(-100));
assertIndexOutOfBoundsException(() -> b.getLong(bytesLen));
assertIndexOutOfBoundsException(() -> b.getLong(bytesLen + 1));
assertIndexOutOfBoundsException(() -> b.getLong(bytesLen + 100));
assertIndexOutOfBoundsException(() -> b.getLong(-1));
assertIndexOutOfBoundsException(() -> b.getLong(-100));
assertIndexOutOfBoundsException(() -> b.getFloat(bytesLen));
assertIndexOutOfBoundsException(() -> b.getFloat(bytesLen + 1));

相关文章