本文整理了Java中io.netty.buffer.ByteBuf.getUnsignedByte()
方法的一些代码示例,展示了ByteBuf.getUnsignedByte()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteBuf.getUnsignedByte()
方法的具体详情如下:
包路径:io.netty.buffer.ByteBuf
类名称:ByteBuf
方法名:getUnsignedByte
[英]Gets an unsigned byte at the specified absolute index in this buffer. This method does not modify readerIndex or writerIndex of this buffer.
[中]获取此缓冲区中指定绝对索引处的无符号字节。此方法不修改此缓冲区的readerIndex或writerIndex。
代码示例来源:origin: netty/netty
@Override
public short getUnsignedByte(int index) {
return buf.getUnsignedByte(index);
}
代码示例来源:origin: netty/netty
@Override
public short getUnsignedByte(int index) {
return buf.getUnsignedByte(index);
}
代码示例来源:origin: redisson/redisson
@Override
public short getUnsignedByte(int index) {
return buf.getUnsignedByte(index);
}
代码示例来源:origin: redisson/redisson
@Override
public short getUnsignedByte(int index) {
return buf.getUnsignedByte(index);
}
代码示例来源:origin: eclipse-vertx/vert.x
public short getUnsignedByte(int pos) {
return buffer.getUnsignedByte(pos);
}
代码示例来源:origin: Graylog2/graylog2-server
private void extractSequenceNumber() {
if (this.sequenceNumber == -1) {
final int seqNum = payload.getUnsignedByte(HEADER_PART_SEQNUM_START);
if (seqNum >= 0) {
this.sequenceNumber = seqNum;
} else {
throw new IllegalStateException("Could not extract sequence number");
}
}
}
代码示例来源:origin: Graylog2/graylog2-server
private void extractSequenceCount() {
if (this.sequenceCount == -1) {
final int seqCnt = payload.getUnsignedByte(HEADER_PART_SEQCNT_START);
if (seqCnt >= 0) {
this.sequenceCount = seqCnt;
} else {
throw new IllegalStateException("Could not extract sequence count");
}
}
}
代码示例来源:origin: netty/netty
@Override
public short getUnsignedByte(int index) {
checkIndex(index, 1);
return buffer.getUnsignedByte(index);
}
代码示例来源:origin: neo4j/neo4j
private boolean isHttp( ByteBuf buf )
{
for ( int i = 0; i < WEBSOCKET_MAGIC.length(); ++i )
{
if ( buf.getUnsignedByte( buf.readerIndex() + i ) != WEBSOCKET_MAGIC.charAt( i ) )
{
return false;
}
}
return true;
}
代码示例来源:origin: traccar/traccar
private static short checksum(ByteBuf buf) {
short sum = 0;
for (int i = 0; i < buf.readableBytes(); i++) {
sum ^= buf.getUnsignedByte(i);
}
return sum;
}
代码示例来源:origin: redisson/redisson
private static String hexDump(ByteBuf buffer, int fromIndex, int length) {
if (length < 0) {
throw new IllegalArgumentException("length: " + length);
}
if (length == 0) {
return "";
}
int endIndex = fromIndex + length;
char[] buf = new char[length << 1];
int srcIdx = fromIndex;
int dstIdx = 0;
for (; srcIdx < endIndex; srcIdx ++, dstIdx += 2) {
System.arraycopy(
HEXDUMP_TABLE, buffer.getUnsignedByte(srcIdx) << 1,
buf, dstIdx, 2);
}
return new String(buf);
}
代码示例来源:origin: netty/netty
private static String hexDump(ByteBuf buffer, int fromIndex, int length) {
checkPositiveOrZero(length, "length");
if (length == 0) {
return "";
}
int endIndex = fromIndex + length;
char[] buf = new char[length << 1];
int srcIdx = fromIndex;
int dstIdx = 0;
for (; srcIdx < endIndex; srcIdx ++, dstIdx += 2) {
System.arraycopy(
HEXDUMP_TABLE, buffer.getUnsignedByte(srcIdx) << 1,
buf, dstIdx, 2);
}
return new String(buf);
}
代码示例来源:origin: redisson/redisson
@Override
public short getUnsignedByte(int index) {
checkIndex(index, 1);
return buffer.getUnsignedByte(index);
}
代码示例来源:origin: traccar/traccar
@Override
protected Object decode(
ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
if (buf.readableBytes() < 17) {
return null;
}
int length = 17 + buf.getUnsignedByte(16) + (BitUtil.from(buf.getUnsignedByte(15), 6) << 6);
if (buf.readableBytes() >= length) {
return buf.readBytes(length);
}
return null;
}
代码示例来源:origin: netty/netty
@Override
public String readLine() throws IOException {
if (!buffer.isReadable()) {
return null;
}
if (lineBuf != null) {
lineBuf.setLength(0);
}
loop: do {
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:
if (lineBuf == null) {
lineBuf = new StringBuilder();
}
lineBuf.append((char) c);
}
} while (buffer.isReadable());
return lineBuf != null && lineBuf.length() > 0 ? lineBuf.toString() : StringUtil.EMPTY_STRING;
}
代码示例来源:origin: wildfly/wildfly
@Override
public short getUnsignedByte(int index) {
checkIndex(index, 1);
return buffer.getUnsignedByte(index);
}
代码示例来源:origin: traccar/traccar
private static void sendResponse(Channel channel, ByteBuf buf) {
if (channel != null) {
ByteBuf response = Unpooled.buffer(4);
response.writeByte('*');
response.writeShort(buf.getUnsignedShort(buf.writerIndex() - 2));
response.writeByte(buf.getUnsignedByte(buf.writerIndex() - 3));
channel.writeAndFlush(new NetworkMessage(response, channel.remoteAddress()));
}
}
代码示例来源:origin: netty/netty
int comp = bufferA.getUnsignedByte(aIndex) - bufferB.getUnsignedByte(bIndex);
if (comp != 0) {
return comp;
代码示例来源:origin: Graylog2/graylog2-server
public static long getUnsignedInteger(final ByteBuf buf, final int offset, final int length) {
switch (length) {
case 1:
return buf.getUnsignedByte(offset);
case 2:
return buf.getUnsignedShort(offset);
case 3:
return buf.getUnsignedMedium(offset);
case 4:
return buf.getUnsignedInt(offset);
case 8:
return buf.getLong(offset) & 0x00000000ffffffffL;
default:
return 0L;
}
}
代码示例来源:origin: netty/netty
switch (length) {
case 1:
frameLength = buf.getUnsignedByte(offset);
break;
case 2:
内容来源于网络,如有侵权,请联系作者删除!