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

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

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

Buffer.getUnsignedByte介绍

[英]Returns the unsigned byte at position pos in the Buffer, as a short.
[中]返回缓冲区中位置pos处的无符号字节(短)。

代码示例

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

private int readByte() throws VertxException {
 if (pos + 1 >= in.length()) {
  throw new VertxException("Invalid DER: stream too short, missing tag");
 }
 return in.getUnsignedByte(pos++);
}

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

private void testSetUnsignedByte(Buffer buff) throws Exception {
 for (int i = 0; i < numSets; i++) {
  int val = Byte.MAX_VALUE + i;
  buff.setUnsignedByte(i, (short) val);
 }
 for (int i = 0; i < numSets; i++) {
  int val = Byte.MAX_VALUE + i;
  assertEquals(val, buff.getUnsignedByte(i));
 }
}

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

@Test
public void testGetUnsignedByte() throws Exception {
 int bytesLen = 100;
 byte[] bytes = TestUtils.randomByteArray(bytesLen);
 Buffer b = Buffer.buffer(bytes);
 for (int i = 0; i < bytesLen; i++) {
  assertEquals(Byte.toUnsignedLong(bytes[i]), b.getUnsignedByte(i));
 }
}

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

throw new IllegalStateException("expected " + toHex(clientRequest) + ", got " + toHex(buffer2));
int addressType = buffer2.getUnsignedByte(3);
String host;
int port;
  throw new IllegalStateException("format error in client request (attribute type ipv4), got " + toHex(buffer2));
 host = buffer2.getUnsignedByte(4) + "." +
  buffer2.getUnsignedByte(5) + "." +
  buffer2.getUnsignedByte(6) + "." +
  buffer2.getUnsignedByte(7);
 port = buffer2.getUnsignedShort(8);
} else if(addressType == 3) {
 int stringLen = buffer2.getUnsignedByte(4);
 log.debug("string len " + stringLen);
 if (buffer2.length() != 7 + stringLen) {

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

private int readByte() throws VertxException {
 if (pos + 1 >= in.length()) {
  throw new VertxException("Invalid DER: stream too short, missing tag");
 }
 return in.getUnsignedByte(pos++);
}

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

protected static Buffer normalizeLineEndingsFor(Buffer buff) {
 int buffLen = buff.length();
 Buffer normalized = Buffer.buffer(buffLen);
 for (int i = 0; i < buffLen; i++) {
  short unsignedByte = buff.getUnsignedByte(i);
  if (unsignedByte != '\r' || i + 1 == buffLen || buff.getUnsignedByte(i + 1) != '\n') {
   normalized.appendUnsignedByte(unsignedByte);
  }
 }
 return normalized;
}

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

private void testSetUnsignedByte(Buffer buff) throws Exception {
 for (int i = 0; i < numSets; i++) {
  int val = Byte.MAX_VALUE + i;
  buff.setUnsignedByte(i, (short) val);
 }
 for (int i = 0; i < numSets; i++) {
  int val = Byte.MAX_VALUE + i;
  assertEquals(val, buff.getUnsignedByte(i));
 }
}

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

@Test
public void testGetUnsignedByte() throws Exception {
 int bytesLen = 100;
 byte[] bytes = TestUtils.randomByteArray(bytesLen);
 Buffer b = Buffer.buffer(bytes);
 for (int i = 0; i < bytesLen; i++) {
  assertEquals(Byte.toUnsignedLong(bytes[i]), b.getUnsignedByte(i));
 }
}

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

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

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

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

代码示例来源:origin: silentbalanceyh/vertx-zero

protected static Buffer normalizeLineEndingsFor(final Buffer buff) {
  final int buffLen = buff.length();
  final Buffer normalized = Buffer.buffer(buffLen);
  for (int i = 0; i < buffLen; i++) {
    final short unsignedByte = buff.getUnsignedByte(i);
    if (unsignedByte != '\r' || i + 1 == buffLen || buff.getUnsignedByte(i + 1) != '\n') {
      normalized.appendUnsignedByte(unsignedByte);
    }
  }
  return normalized;
}

代码示例来源:origin: cn.vertxup/vertx-co

protected static Buffer normalizeLineEndingsFor(final Buffer buff) {
  final int buffLen = buff.length();
  final Buffer normalized = Buffer.buffer(buffLen);
  for (int i = 0; i < buffLen; i++) {
    final short unsignedByte = buff.getUnsignedByte(i);
    if (unsignedByte != '\r' || i + 1 == buffLen || buff.getUnsignedByte(i + 1) != '\n') {
      normalized.appendUnsignedByte(unsignedByte);
    }
  }
  return normalized;
}

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

throw new IllegalStateException("expected " + toHex(clientRequest) + ", got " + toHex(buffer2));
int addressType = buffer2.getUnsignedByte(3);
String host;
int port;
  throw new IllegalStateException("format error in client request (attribute type ipv4), got " + toHex(buffer2));
 host = buffer2.getUnsignedByte(4) + "." +
  buffer2.getUnsignedByte(5) + "." +
  buffer2.getUnsignedByte(6) + "." +
  buffer2.getUnsignedByte(7);
 port = buffer2.getUnsignedShort(8);
} else if(addressType == 3) {
 int stringLen = buffer2.getUnsignedByte(4);
 log.debug("string len " + stringLen);
 if (buffer2.length() != 7 + stringLen) {

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

protected static Buffer normalizeLineEndingsFor(Buffer buff) {
 int buffLen = buff.length();
 Buffer normalized = Buffer.buffer(buffLen);
 for (int i = 0; i < buffLen; i++) {
  short unsignedByte = buff.getUnsignedByte(i);
  if (unsignedByte != '\r' || i + 1 == buffLen || buff.getUnsignedByte(i + 1) != '\n') {
   normalized.appendUnsignedByte(unsignedByte);
  }
 }
 return normalized;
}

相关文章

微信公众号

最新文章

更多