本文整理了Java中io.netty.buffer.ByteBuf.getByte()
方法的一些代码示例,展示了ByteBuf.getByte()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteBuf.getByte()
方法的具体详情如下:
包路径:io.netty.buffer.ByteBuf
类名称:ByteBuf
方法名:getByte
[英]Gets a byte at the specified absolute index in this buffer. This method does not modify readerIndex or writerIndex of this buffer.
[中]获取此缓冲区中指定绝对索引处的字节。此方法不修改此缓冲区的readerIndex或writerIndex。
代码示例来源:origin: mrniko/netty-socketio
private static boolean isValueFound(ByteBuf buffer, int index, ByteBuf search) {
for (int i = 0; i < search.readableBytes(); i++) {
if (buffer.getByte(index + i) != search.getByte(i)) {
return false;
}
}
return true;
}
代码示例来源:origin: neo4j/neo4j
@Override
public byte peekByte()
{
return buf.getByte( buf.readerIndex() );
}
代码示例来源:origin: netty/netty
@Override
protected void decodeLast(ChannelHandlerContext ctx, ByteBuf buffer, List<Object> out) throws Exception {
switch (buffer.readableBytes()) {
case 0:
return;
case 1:
// Ignore the last TC_RESET
if (buffer.getByte(buffer.readerIndex()) == ObjectStreamConstants.TC_RESET) {
buffer.skipBytes(1);
return;
}
}
decode(ctx, buffer, out);
}
代码示例来源:origin: line/armeria
.map(DnsRawRecord.class::cast)
.anyMatch(r -> r.type() == DnsRecordType.A &&
r.content().getByte(r.content().readerIndex()) == 127);
final int contentLen = content.readableBytes();
content.getBytes(content.readerIndex(), addrBytes);
代码示例来源:origin: mrniko/netty-socketio
private boolean hasLengthHeader(ByteBuf buffer) {
for (int i = 0; i < Math.min(buffer.readableBytes(), 10); i++) {
byte b = buffer.getByte(buffer.readerIndex() + i);
if (b == (byte)':' && i > 0) {
return true;
}
if (b > 57 || b < 48) {
return false;
}
}
return false;
}
代码示例来源:origin: alibaba/fescar
private static int getMagicIndex(ByteBuf in) {
boolean found = false;
int readIndex = in.readerIndex();
int begin = 0;
while (readIndex < in.writerIndex()) {
if (in.getByte(readIndex) == MAGIC_HALF && in.getByte(readIndex + 1) == MAGIC_HALF) {
begin = readIndex;
found = true;
break;
}
++readIndex;
}
return found ? begin : NOT_FOUND_INDEX;
}
}
代码示例来源:origin: traccar/traccar
DeviceSession deviceSession;
if (buf.getByte(0) == 'E' && buf.getByte(1) == 'L') {
buf.skipBytes(2 + 2 + 2); // udp header
uniqueId = ByteBufUtil.hexDump(buf.readSlice(8)).substring(1);
} else if (type == MSG_HEARTBEAT && buf.readableBytes() >= 2) {
代码示例来源:origin: netty/netty
/**
* Returns the index in the buffer of the end of line found.
* Returns -1 if no end of line was found in the buffer.
*/
private int findEndOfLine(final ByteBuf buffer) {
int totalLength = buffer.readableBytes();
int i = buffer.forEachByte(buffer.readerIndex() + offset, totalLength - offset, ByteProcessor.FIND_LF);
if (i >= 0) {
offset = 0;
if (i > 0 && buffer.getByte(i - 1) == '\r') {
i--;
}
} else {
offset = totalLength;
}
return i;
}
}
代码示例来源:origin: mrniko/netty-socketio
private boolean isStringPacket(ByteBuf content) {
return content.getByte(content.readerIndex()) == 0x0;
}
代码示例来源:origin: traccar/traccar
for (int i = 0; i < buf.readableBytes(); i++) {
int b = buf.getByte(i);
if (b != 0x0b) {
buf.setByte(i, b - 0x20);
代码示例来源:origin: redisson/redisson
@Override
protected void decodeLast(ChannelHandlerContext ctx, ByteBuf buffer, List<Object> out) throws Exception {
switch (buffer.readableBytes()) {
case 0:
return;
case 1:
// Ignore the last TC_RESET
if (buffer.getByte(buffer.readerIndex()) == ObjectStreamConstants.TC_RESET) {
buffer.skipBytes(1);
return;
}
}
decode(ctx, buffer, out);
}
代码示例来源:origin: traccar/traccar
private static byte checksum(ByteBuf buf, int end) {
byte result = 0;
for (int i = 0; i < end; i++) {
result += buf.getByte(buf.readerIndex() + i);
}
return result;
}
代码示例来源:origin: redisson/redisson
/**
* Returns the index in the buffer of the end of line found.
* Returns -1 if no end of line was found in the buffer.
*/
private int findEndOfLine(final ByteBuf buffer) {
int totalLength = buffer.readableBytes();
int i = buffer.forEachByte(buffer.readerIndex() + offset, totalLength - offset, ByteProcessor.FIND_LF);
if (i >= 0) {
offset = 0;
if (i > 0 && buffer.getByte(i - 1) == '\r') {
i--;
}
} else {
offset = totalLength;
}
return i;
}
}
代码示例来源:origin: line/armeria
private boolean match(byte[] prefix, ByteBuf buffer) {
final int idx = buffer.readerIndex();
for (int i = 0; i < prefix.length; i++) {
final byte b = buffer.getByte(idx + i);
if (b != prefix[i]) {
return false;
}
}
return true;
}
}
代码示例来源:origin: wildfly/wildfly
/**
* Returns the proxy protocol specification version in the buffer if the version is found.
* Returns -1 if no version was found in the buffer.
*/
private static int findVersion(final ByteBuf buffer) {
final int n = buffer.readableBytes();
// per spec, the version number is found in the 13th byte
if (n < 13) {
return -1;
}
int idx = buffer.readerIndex();
return match(BINARY_PREFIX, buffer, idx) ? buffer.getByte(idx + BINARY_PREFIX_LENGTH) : 1;
}
代码示例来源:origin: wildfly/wildfly
/**
* Returns the index in the buffer of the end of line found.
* Returns -1 if no end of line was found in the buffer.
*/
private static int findEndOfLine(final ByteBuf buffer) {
final int n = buffer.writerIndex();
for (int i = buffer.readerIndex(); i < n; i++) {
final byte b = buffer.getByte(i);
if (b == '\r' && i < n - 1 && buffer.getByte(i + 1) == '\n') {
return i; // \r\n
}
}
return -1; // Not found.
}
代码示例来源:origin: Graylog2/graylog2-server
/**
* Returns the index in the buffer of the end of line found.
* Returns -1 if no end of line was found in the buffer.
*/
private int findEndOfLine(final ByteBuf buffer) {
int totalLength = buffer.readableBytes();
int i = buffer.forEachByte(buffer.readerIndex() + offset, totalLength - offset, ByteProcessor.FIND_LF);
if (i >= 0) {
offset = 0;
if (i > 0 && buffer.getByte(i - 1) == '\r') {
i--;
}
} else {
offset = totalLength;
}
return i;
}
}
代码示例来源:origin: mrniko/netty-socketio
private long readLong(ByteBuf chars, int length) {
long result = 0;
for (int i = chars.readerIndex(); i < chars.readerIndex() + length; i++) {
int digit = ((int)chars.getByte(i) & 0xF);
for (int j = 0; j < chars.readerIndex() + length-1-i; j++) {
digit *= 10;
}
result += digit;
}
chars.readerIndex(chars.readerIndex() + length);
return result;
}
代码示例来源:origin: wildfly/wildfly
@Override
protected void decodeLast(ChannelHandlerContext ctx, ByteBuf buffer, List<Object> out) throws Exception {
switch (buffer.readableBytes()) {
case 0:
return;
case 1:
// Ignore the last TC_RESET
if (buffer.getByte(buffer.readerIndex()) == ObjectStreamConstants.TC_RESET) {
buffer.skipBytes(1);
return;
}
}
decode(ctx, buffer, out);
}
代码示例来源:origin: runelite/runelite
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> list) throws Exception
{
if (in.getByte(in.readerIndex()) != UpdateOpcodes.CLIENT_LOGGED_IN)
{
ctx.fireChannelRead(in.retain());
return;
}
in.skipBytes(4);
}
内容来源于网络,如有侵权,请联系作者删除!