com.couchbase.client.deps.io.netty.buffer.ByteBuf.readUnsignedByte()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(6.4k)|赞(0)|评价(0)|浏览(189)

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

ByteBuf.readUnsignedByte介绍

[英]Gets an unsigned byte at the current readerIndex and increases the readerIndex by 1 in this buffer.
[中]获取当前readerIndex处的无符号字节,并在此缓冲区中将readerIndex增加1。

代码示例

代码示例来源:origin: com.couchbase.client/core-io

@Override
public short readUnsignedByte() {
  return buf.readUnsignedByte();
}

代码示例来源:origin: com.couchbase.client/core-io

@Override
public short readUnsignedByte() {
  return buf.readUnsignedByte();
}

代码示例来源:origin: couchbase/couchbase-jvm-core

@Override
public short readUnsignedByte() {
  return buf.readUnsignedByte();
}

代码示例来源:origin: couchbase/couchbase-jvm-core

@Override
public short readUnsignedByte() {
  return buf.readUnsignedByte();
}

代码示例来源:origin: couchbase/couchbase-jvm-core

@Override
public short readUnsignedByte() {
  checkReadableBytes(1);
  return buffer.readUnsignedByte();
}

代码示例来源:origin: com.couchbase.client/core-io

private void verifyCrc(ByteBuf in) {
  long crcValue = 0;
  for (int i = 0; i < 4; ++i) {
    crcValue |= (long) in.readUnsignedByte() << i * 8;
  }
  long readCrc = crc.getValue();
  if (crcValue != readCrc) {
    throw new DecompressionException(
        "CRC value mismatch. Expected: " + crcValue + ", Got: " + readCrc);
  }
}

代码示例来源:origin: com.couchbase.client/core-io

@Override
public short readUnsignedByte() {
  checkReadableBytes(1);
  return buffer.readUnsignedByte();
}

代码示例来源:origin: couchbase/couchbase-jvm-core

private void verifyCrc(ByteBuf in) {
  long crcValue = 0;
  for (int i = 0; i < 4; ++i) {
    crcValue |= (long) in.readUnsignedByte() << i * 8;
  }
  long readCrc = crc.getValue();
  if (crcValue != readCrc) {
    throw new DecompressionException(
        "CRC value mismatch. Expected: " + crcValue + ", Got: " + readCrc);
  }
}

代码示例来源:origin: com.couchbase.client/core-io

private static void skipControlCharactersStandard(ByteBuf undecodedChunk) {
  for (;;) {
    char c = (char) undecodedChunk.readUnsignedByte();
    if (!Character.isISOControl(c) && !Character.isWhitespace(c)) {
      undecodedChunk.readerIndex(undecodedChunk.readerIndex() - 1);
      break;
    }
  }
}

代码示例来源:origin: couchbase/couchbase-jvm-core

private static void skipControlCharactersStandard(ByteBuf undecodedChunk) {
  for (;;) {
    char c = (char) undecodedChunk.readUnsignedByte();
    if (!Character.isISOControl(c) && !Character.isWhitespace(c)) {
      undecodedChunk.readerIndex(undecodedChunk.readerIndex() - 1);
      break;
    }
  }
}

代码示例来源:origin: com.couchbase.client/core-io

/**
 * Reads the length varint (a series of bytes, where the lower 7 bits
 * are data and the upper bit is a flag to indicate more bytes to be
 * read).
 *
 * @param in The input buffer to read the preamble from
 * @return The calculated length based on the input buffer, or 0 if
 *   no preamble is able to be calculated
 */
private static int readPreamble(ByteBuf in) {
  int length = 0;
  int byteIndex = 0;
  while (in.isReadable()) {
    int current = in.readUnsignedByte();
    length |= (current & 0x7f) << byteIndex++ * 7;
    if ((current & 0x80) == 0) {
      return length;
    }
    if (byteIndex >= 4) {
      throw new DecompressionException("Preamble is greater than 4 bytes");
    }
  }
  return 0;
}

代码示例来源:origin: couchbase/couchbase-jvm-core

/**
 * Reads the length varint (a series of bytes, where the lower 7 bits
 * are data and the upper bit is a flag to indicate more bytes to be
 * read).
 *
 * @param in The input buffer to read the preamble from
 * @return The calculated length based on the input buffer, or 0 if
 *   no preamble is able to be calculated
 */
private static int readPreamble(ByteBuf in) {
  int length = 0;
  int byteIndex = 0;
  while (in.isReadable()) {
    int current = in.readUnsignedByte();
    length |= (current & 0x7f) << byteIndex++ * 7;
    if ((current & 0x80) == 0) {
      return length;
    }
    if (byteIndex >= 4) {
      throw new DecompressionException("Preamble is greater than 4 bytes");
    }
  }
  return 0;
}

代码示例来源:origin: couchbase/java-dcp-client

/**
 * Reads the length varint (a series of bytes, where the lower 7 bits
 * are data and the upper bit is a flag to indicate more bytes to be
 * read).
 *
 * @param in The input buffer to read the preamble from
 * @return The calculated length based on the input buffer, or 0 if
 * no preamble is able to be calculated
 */
public static int readPreamble(ByteBuf in) {
  int length = 0;
  int byteIndex = 0;
  while (in.isReadable()) {
    int current = in.readUnsignedByte();
    length |= (current & 0x7f) << byteIndex++ * 7;
    if ((current & 0x80) == 0) {
      return length;
    }
    if (byteIndex >= 4) {
      throw new DecompressionException("Preamble is greater than 4 bytes");
    }
  }
  return 0;
}

代码示例来源:origin: com.couchbase.client/core-io

@Override
public String readLine() throws IOException {
  lineBuf.setLength(0);
  loop: while (true) {
    if (!buffer.isReadable()) {
      return lineBuf.length() > 0 ? lineBuf.toString() : null;
    }
    int c = buffer.readUnsignedByte();
    switch (c) {
      case '\n':
        break loop;
      case '\r':
        if (buffer.isReadable() && (char) buffer.getUnsignedByte(buffer.readerIndex()) == '\n') {
          buffer.skipBytes(1);
        }
        break loop;
      default:
        lineBuf.append((char) c);
    }
  }
  return lineBuf.toString();
}

代码示例来源:origin: couchbase/couchbase-jvm-core

@Override
public String readLine() throws IOException {
  lineBuf.setLength(0);
  loop: while (true) {
    if (!buffer.isReadable()) {
      return lineBuf.length() > 0 ? lineBuf.toString() : null;
    }
    int c = buffer.readUnsignedByte();
    switch (c) {
      case '\n':
        break loop;
      case '\r':
        if (buffer.isReadable() && (char) buffer.getUnsignedByte(buffer.readerIndex()) == '\n') {
          buffer.skipBytes(1);
        }
        break loop;
      default:
        lineBuf.append((char) c);
    }
  }
  return lineBuf.toString();
}

代码示例来源:origin: com.couchbase.client/core-io

private boolean readGZIPFooter(ByteBuf buf) {
  if (buf.readableBytes() < 8) {
    return false;
  }
  verifyCrc(buf);
  // read ISIZE and verify
  int dataLength = 0;
  for (int i = 0; i < 4; ++i) {
    dataLength |= buf.readUnsignedByte() << i * 8;
  }
  int readLength = inflater.getTotalOut();
  if (dataLength != readLength) {
    throw new DecompressionException(
        "Number of bytes mismatch. Expected: " + dataLength + ", Got: " + readLength);
  }
  return true;
}

代码示例来源:origin: couchbase/couchbase-jvm-core

private boolean readGZIPFooter(ByteBuf buf) {
  if (buf.readableBytes() < 8) {
    return false;
  }
  verifyCrc(buf);
  // read ISIZE and verify
  int dataLength = 0;
  for (int i = 0; i < 4; ++i) {
    dataLength |= buf.readUnsignedByte() << i * 8;
  }
  int readLength = inflater.getTotalOut();
  if (dataLength != readLength) {
    throw new DecompressionException(
        "Number of bytes mismatch. Expected: " + dataLength + ", Got: " + readLength);
  }
  return true;
}

代码示例来源:origin: couchbase/couchbase-jvm-core

int offset = (tag & 0x0e0) << 8 >> 5 | in.readUnsignedByte();

代码示例来源:origin: com.couchbase.client/core-io

int offset = (tag & 0x0e0) << 8 >> 5 | in.readUnsignedByte();

代码示例来源:origin: couchbase/java-dcp-client

int offset = (tag & 0x0e0) << 8 >> 5 | in.readUnsignedByte();

相关文章