本文整理了Java中io.vertx.core.buffer.Buffer.getInt()
方法的一些代码示例,展示了Buffer.getInt()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Buffer.getInt()
方法的具体详情如下:
包路径:io.vertx.core.buffer.Buffer
类名称:Buffer
方法名:getInt
[英]Returns the int at position pos in the Buffer.
[中]返回缓冲区中位置pos处的整数。
代码示例来源:origin: eclipse-vertx/vert.x
@Override
public Integer decodeFromWire(int pos, Buffer buffer) {
return buffer.getInt(pos);
}
代码示例来源:origin: eclipse-vertx/vert.x
private void testGetSetInt(boolean isLE) throws Exception {
int numInts = 100;
Buffer b = Buffer.buffer(numInts * 4);
for (int i = 0; i < numInts; i++) {
if (isLE) {
b.setIntLE(i * 4, i);
} else {
b.setInt(i * 4, i);
}
}
for (int i = 0; i < numInts; i++) {
if (isLE) {
assertEquals(i, b.getIntLE(i * 4));
} else {
assertEquals(i, b.getInt(i * 4));
}
}
}
代码示例来源:origin: eclipse-vertx/vert.x
@Override
public JsonArray decodeFromWire(int pos, Buffer buffer) {
int length = buffer.getInt(pos);
pos += 4;
return new JsonArray(buffer.slice(pos, pos + length));
}
代码示例来源:origin: eclipse-vertx/vert.x
@Override
public Buffer decodeFromWire(int pos, Buffer buffer) {
int length = buffer.getInt(pos);
pos += 4;
return buffer.getBuffer(pos, pos + length);
}
代码示例来源:origin: eclipse-vertx/vert.x
@Override
public String decodeFromWire(int pos, Buffer buffer) {
int length = buffer.getInt(pos);
pos += 4;
byte[] bytes = buffer.getBytes(pos, pos + length);
return new String(bytes, CharsetUtil.UTF_8);
}
代码示例来源:origin: eclipse-vertx/vert.x
@Override
public byte[] decodeFromWire(int pos, Buffer buffer) {
int length = buffer.getInt(pos);
pos += 4;
return buffer.getBytes(pos, pos + length);
}
代码示例来源:origin: eclipse-vertx/vert.x
@Override
public JsonObject decodeFromWire(int pos, Buffer buffer) {
int length = buffer.getInt(pos);
pos += 4;
return new JsonObject(buffer.slice(pos, pos + length));
}
代码示例来源:origin: eclipse-vertx/vert.x
@Override
public Integer decodeFromWire(int pos, Buffer buffer) {
return buffer.getInt(pos);
}
代码示例来源:origin: eclipse-vertx/vert.x
@Override
public int readFromBuffer(int pos, Buffer buffer) {
int length = buffer.getInt(pos);
int start = pos + 4;
String encoded = buffer.getString(start, start + length);
fromJson(encoded);
return pos + length + 4;
}
代码示例来源:origin: eclipse-vertx/vert.x
@Override
public int readFromBuffer(int pos, Buffer buffer) {
int len = buffer.getInt(pos);
Buffer b = buffer.getBuffer(pos + 4, pos + 4 + len);
this.buffer = b.getByteBuf();
return pos + 4 + len;
}
}
代码示例来源:origin: eclipse-vertx/vert.x
@Override
public int readFromBuffer(int pos, Buffer buffer) {
int length = buffer.getInt(pos);
int start = pos + 4;
String encoded = buffer.getString(start, start + length);
fromJson(encoded);
return pos + length + 4;
}
代码示例来源:origin: eclipse-vertx/vert.x
@Override
public String decodeFromWire(int pos, Buffer buffer) {
int length = buffer.getInt(pos);
pos += 4;
byte[] bytes = buffer.getBytes(pos, pos + length);
return new String(bytes, CharsetUtil.UTF_8);
}
代码示例来源:origin: eclipse-vertx/vert.x
@Override
public int readFromBuffer(int pos, Buffer buffer) {
int length = buffer.getInt(pos);
str = buffer.getString(pos + 4, pos + 4 + length);
return pos + 4 + length;
}
}
代码示例来源:origin: eclipse-vertx/vert.x
@Override
public ReplyException decodeFromWire(int pos, Buffer buffer) {
int i = (int) buffer.getByte(pos);
ReplyFailure rf = ReplyFailure.fromInt(i);
pos++;
int failureCode = buffer.getInt(pos);
pos += 4;
boolean isNull = buffer.getByte(pos) == (byte)0;
String message;
if (!isNull) {
pos++;
int strLength = buffer.getInt(pos);
pos += 4;
byte[] bytes = buffer.getBytes(pos, pos + strLength);
message = new String(bytes, CharsetUtil.UTF_8);
} else {
message = null;
}
return new ReplyException(rf, failureCode, message);
}
代码示例来源:origin: eclipse-vertx/vert.x
private void viaString(Buffer buffer) throws Exception {
int pos = 0;
int length = buffer.getInt(pos);
pos += 4;
byte[] encoded = buffer.getBytes(pos, pos + length);
String str = new String(encoded, CharsetUtil.UTF_8);
consume(new JsonObject(str));
}
代码示例来源:origin: eclipse-vertx/vert.x
private void direct(Buffer buffer) throws Exception {
int pos = 0;
int length = buffer.getInt(pos);
pos += 4;
consume(new JsonObject(buffer.slice(pos, pos + length)));
}
}
代码示例来源:origin: eclipse-vertx/vert.x
@Override
public MyPOJO decodeFromWire(int pos, Buffer buffer) {
int length = buffer.getInt(pos);
pos += 4;
byte[] bytes = buffer.getBytes(pos, pos + length);
String str = new String(bytes, CharsetUtil.UTF_8);
return new MyPOJO(str);
}
代码示例来源:origin: eclipse-vertx/vert.x
@Override
public MyReplyException decodeFromWire(int pos, Buffer buffer) {
int failureCode = buffer.getInt(pos);
pos += 4;
boolean isNull = buffer.getByte(pos) == (byte)0;
String message;
if (!isNull) {
pos++;
int strLength = buffer.getInt(pos);
pos += 4;
byte[] bytes = buffer.getBytes(pos, pos + strLength);
message = new String(bytes, CharsetUtil.UTF_8);
} else {
message = null;
}
return new MyReplyException(failureCode, message);
}
代码示例来源:origin: eclipse-vertx/vert.x
private void testSetInt(Buffer buff) throws Exception {
for (int i = 0; i < numSets; i++) {
buff.setInt(i * 4, i);
}
for (int i = 0; i < numSets; i++) {
assertEquals(i, buff.getInt(i * 4));
}
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testSetGetInt() throws Exception {
final int size = 10;
Buffer buffer = Buffer.buffer(size);
for (int i = 0; i < size; i++) {
buffer.setInt(i * 4, (i + 1) * 10);
}
for (int i = 0; i < size; i++) {
assertEquals((i + 1) * 10, buffer.getInt(i * 4));
}
}
内容来源于网络,如有侵权,请联系作者删除!