本文整理汇总了Java中io.netty.buffer.ByteBuf.readUnsignedIntLE方法的典型用法代码示例。如果您正苦于以下问题:Java ByteBuf.readUnsignedIntLE方法的具体用法?Java ByteBuf.readUnsignedIntLE怎么用?Java ByteBuf.readUnsignedIntLE使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.netty.buffer.ByteBuf
的用法示例。
在下文中一共展示了ByteBuf.readUnsignedIntLE方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: extractOffsets
import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
private int[] extractOffsets(ByteBuf msg) {
int numOffsets = numTags - 1;
int endOfPayload = msg.readableBytes() - (4 * numOffsets);
// Offset for every tag, including the value of tag 0 which starts immediately after header.
int[] offsets = new int[numTags];
offsets[0] = 0;
for (int i = 0; i < numOffsets; i++) {
long offset = msg.readUnsignedIntLE();
if ((offset % 4) != 0) {
throw new TagOffsetUnalignedException("offset " + i + " not multiple of 4: " + offset);
}
if (offset > endOfPayload) {
throw new TagOffsetOverflowException("offset " + i + " overflow: " + offset);
}
checkState((int) offset >= 0, "impossible, negative offset");
offsets[i + 1] = (int) offset;
}
return offsets;
}
示例2: extractNumTags
import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
private int extractNumTags(ByteBuf msg) {
long readNumTags = msg.readUnsignedIntLE();
// Spec says max # tags can be 2^32-1, but capping at 64k tags in this implementation
if (readNumTags > 0xffff) {
throw new InvalidNumTagsException("invalid num_tags value " + readNumTags);
}
return (int) readNumTags;
}