io.netty.buffer.ByteBuf.bytesBefore()方法的使用及代码示例

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

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

ByteBuf.bytesBefore介绍

[英]Locates the first occurrence of the specified value in this buffer. The search takes place from the current readerIndex(inclusive) to the current writerIndex (exclusive).

This method does not modify readerIndex or writerIndex of this buffer.
[中]查找此缓冲区中指定值的第一个匹配项。搜索从当前readerIndex(包含)到当前writerIndex(独占)。
此方法不修改此缓冲区的readerIndex或writerIndex。

代码示例

代码示例来源:origin: netty/netty

@Override
public int bytesBefore(byte value) {
  int bytes = buffer.bytesBefore(value);
  if (bytes < 0) {
    throw REPLAY;
  }
  return bytes;
}

代码示例来源:origin: netty/netty

@Override
public int bytesBefore(int index, int length, byte value) {
  return buf.bytesBefore(index, length, value);
}

代码示例来源:origin: netty/netty

@Override
public int bytesBefore(int length, byte value) {
  return buf.bytesBefore(length, value);
}

代码示例来源:origin: netty/netty

@Override
public int bytesBefore(byte value) {
  return buf.bytesBefore(value);
}

代码示例来源:origin: netty/netty

@Override
public int bytesBefore(byte value) {
  return buf.bytesBefore(value);
}

代码示例来源:origin: netty/netty

@Override
public int bytesBefore(int length, byte value) {
  return buf.bytesBefore(length, value);
}

代码示例来源:origin: netty/netty

@Override
public int bytesBefore(int index, int length, byte value) {
  return buf.bytesBefore(index, length, value);
}

代码示例来源:origin: redisson/redisson

@Override
public int bytesBefore(byte value) {
  int bytes = buffer.bytesBefore(value);
  if (bytes < 0) {
    throw REPLAY;
  }
  return bytes;
}

代码示例来源:origin: apache/incubator-shardingsphere

/**
 * Bytes before zero.
 *
 * @return the number of bytes before zero
 */
public int bytesBeforeZero() {
  return byteBuf.bytesBefore((byte) 0);
}

代码示例来源:origin: redisson/redisson

@Override
public int bytesBefore(int index, int length, byte value) {
  return buf.bytesBefore(index, length, value);
}

代码示例来源:origin: redisson/redisson

@Override
public int bytesBefore(byte value) {
  return buf.bytesBefore(value);
}

代码示例来源:origin: redisson/redisson

@Override
public int bytesBefore(int index, int length, byte value) {
  return buf.bytesBefore(index, length, value);
}

代码示例来源:origin: redisson/redisson

@Override
public int bytesBefore(byte value) {
  return buf.bytesBefore(value);
}

代码示例来源:origin: redisson/redisson

@Override
public int bytesBefore(int length, byte value) {
  return buf.bytesBefore(length, value);
}

代码示例来源:origin: redisson/redisson

@Override
public int bytesBefore(int length, byte value) {
  return buf.bytesBefore(length, value);
}

代码示例来源:origin: netty/netty

@Override
public int bytesBefore(int index, int length, byte value) {
  final int writerIndex = buffer.writerIndex();
  if (index >= writerIndex) {
    throw REPLAY;
  }
  if (index <= writerIndex - length) {
    return buffer.bytesBefore(index, length, value);
  }
  int res = buffer.bytesBefore(index, writerIndex - index, value);
  if (res < 0) {
    throw REPLAY;
  } else {
    return res;
  }
}

代码示例来源:origin: apache/incubator-shardingsphere

/**
 * Read null terminated string from byte buffers and return bytes.
 *
 * @return null terminated bytes
 */
public byte[] readStringNulByBytes() {
  byte[] result = new byte[byteBuf.bytesBefore((byte) 0)];
  byteBuf.readBytes(result);
  byteBuf.skipBytes(1);
  return result;
}

代码示例来源:origin: redisson/redisson

@Override
public String decode(ByteBuf buf, State state) {
  String status = buf.readBytes(buf.bytesBefore((byte) '\r')).toString(CharsetUtil.UTF_8);
  buf.skipBytes(2);
  return status;
}

代码示例来源:origin: redisson/redisson

@Override
public String decode(ByteBuf buf, State state) {
  String status = buf.readBytes(buf.bytesBefore((byte) '\r')).toString(CharsetUtil.UTF_8);
  buf.skipBytes(2);
  return status;
}

代码示例来源:origin: apache/incubator-shardingsphere

/**
 * Read null terminated string from byte buffers.
 * 
 * @return null terminated string
 */
public String readStringNul() {
  byte[] result = new byte[byteBuf.bytesBefore((byte) 0)];
  byteBuf.readBytes(result);
  byteBuf.skipBytes(1);
  return new String(result);
}

相关文章

ByteBuf类方法