本文整理了Java中io.vertx.core.buffer.Buffer.getByte()
方法的一些代码示例,展示了Buffer.getByte()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Buffer.getByte()
方法的具体详情如下:
包路径:io.vertx.core.buffer.Buffer
类名称:Buffer
方法名:getByte
[英]Returns the byte at position pos in the Buffer.
[中]返回缓冲区中位置pos处的字节。
代码示例来源:origin: eclipse-vertx/vert.x
@Override
public Byte decodeFromWire(int pos, Buffer buffer) {
return buffer.getByte(pos);
}
代码示例来源: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
public void readFromWire(Buffer buffer, CodecManager codecManager) {
int pos = 0;
byte protocolVersion = buffer.getByte(pos);
if (protocolVersion > WIRE_PROTOCOL_VERSION) {
throw new IllegalStateException("Invalid wire protocol version " + protocolVersion +
byte systemCodecCode = buffer.getByte(pos);
pos++;
if (systemCodecCode == -1) {
messageCodec = codecManager.systemCodecs()[systemCodecCode];
byte bsend = buffer.getByte(pos);
send = bsend == 0;
pos++;
代码示例来源:origin: eclipse-vertx/vert.x
@Override
public Boolean decodeFromWire(int pos, Buffer buffer) {
return buffer.getByte(pos) == 0;
}
代码示例来源: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 String getByte4(Buffer buffer) {
return String.format("%d.%d.%d.%d", buffer.getByte(0), buffer.getByte(1), buffer.getByte(2), buffer.getByte(3));
}
代码示例来源:origin: eclipse-vertx/vert.x
assertIndexOutOfBoundsException(() -> b.getByte(bytesLen));
assertIndexOutOfBoundsException(() -> b.getByte(bytesLen + 1));
assertIndexOutOfBoundsException(() -> b.getByte(bytesLen + 100));
assertIndexOutOfBoundsException(() -> b.getByte(-1));
assertIndexOutOfBoundsException(() -> b.getByte(-100));
assertIndexOutOfBoundsException(() -> b.getInt(bytesLen));
assertIndexOutOfBoundsException(() -> b.getInt(bytesLen + 1));
代码示例来源:origin: eclipse-vertx/vert.x
private int parseDelimited() {
int len = buff.length();
for (; pos < len; pos++) {
if (buff.getByte(pos) == delim[delimPos]) {
delimPos++;
if (delimPos == delim.length) {
pos++;
delimPos = 0;
return pos - delim.length;
}
} else {
if (delimPos > 0) {
pos -= delimPos;
delimPos = 0;
}
}
}
return -1;
}
代码示例来源:origin: eclipse-vertx/vert.x
private void checkBEAndLE(int size, Buffer big, Buffer little) {
for (int i = 0; i < size; i++) {
byte bigByte = big.getByte(i);
byte littleByte = little.getByte(size - 1 - i);
assertEquals(bigByte, littleByte);
}
}
代码示例来源:origin: eclipse-vertx/vert.x
private String toHex(Buffer buffer) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < buffer.length(); i++) {
sb.append(String.format("%02X ", buffer.getByte(i)));
}
return sb.toString();
}
代码示例来源:origin: eclipse-vertx/vert.x
private String toHex(Buffer buffer) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < buffer.length(); i++) {
sb.append(String.format("%02X ", buffer.getByte(i)));
}
return sb.toString();
}
代码示例来源:origin: eclipse-vertx/vert.x
private void testSetByte(Buffer buff) throws Exception {
for (int i = 0; i < numSets; i++) {
buff.setByte(i, (byte) i);
}
for (int i = 0; i < numSets; i++) {
assertEquals(i, buff.getByte(i));
}
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testGetByte() throws Exception {
int bytesLen = 100;
byte[] bytes = TestUtils.randomByteArray(bytesLen);
Buffer b = Buffer.buffer(bytes);
for (int i = 0; i < bytesLen; i++) {
assertEquals(bytes[i], b.getByte(i));
}
}
代码示例来源:origin: eclipse-vertx/vert.x
private void delimited(Buffer delim) {
int lines = 50;
Buffer[] expected = new Buffer[lines];
//We create lines of length zero to <lines> and shuffle them
List<Buffer> lineList = generateLines(lines, true, delim.getByte(0));
expected = lineList.toArray(expected);
int totLength = lines * (lines - 1) / 2; // The sum of 0...(lines - 1)
Buffer inp = Buffer.buffer(totLength + lines * delim.length());
for (int i = 0; i < lines; i++) {
inp.appendBuffer(expected[i]);
inp.appendBuffer(delim);
}
//We then try every combination of chunk size up to twice the input string length
for (int i = 1; i < inp.length() * 2; i++) {
doTestDelimited(inp, delim, new Integer[]{i}, expected);
}
//Then we try a sequence of random chunk sizes
List<Integer> chunkSizes = generateChunkSizes(lines);
//Repeat a few times
for (int i = 0; i < 10; i++) {
Collections.shuffle(chunkSizes);
doTestDelimited(inp, delim, chunkSizes.toArray(new Integer[]{}), expected);
}
}
代码示例来源:origin: vert-x3/vertx-examples
recordParser.fixedSizeMode(4);
final char type = (char) buffer.getByte(0);
代码示例来源:origin: io.vertx/vertx-core
@Override
public Byte decodeFromWire(int pos, Buffer buffer) {
return buffer.getByte(pos);
}
代码示例来源: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
private void checkBEAndLE(int size, Buffer big, Buffer little) {
for (int i = 0; i < size; i++) {
byte bigByte = big.getByte(i);
byte littleByte = little.getByte(size - 1 - i);
assertEquals(bigByte, littleByte);
}
}
代码示例来源:origin: io.vertx/vertx-core
private String toHex(Buffer buffer) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < buffer.length(); i++) {
sb.append(String.format("%02X ", buffer.getByte(i)));
}
return sb.toString();
}
代码示例来源:origin: io.vertx/vertx-core
@Test
public void testGetByte() throws Exception {
int bytesLen = 100;
byte[] bytes = TestUtils.randomByteArray(bytesLen);
Buffer b = Buffer.buffer(bytes);
for (int i = 0; i < bytesLen; i++) {
assertEquals(bytes[i], b.getByte(i));
}
}
内容来源于网络,如有侵权,请联系作者删除!