本文整理匯總了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;
}