本文整理汇总了Java中com.google.protobuf.CodedInputStream.isAtEnd方法的典型用法代码示例。如果您正苦于以下问题:Java CodedInputStream.isAtEnd方法的具体用法?Java CodedInputStream.isAtEnd怎么用?Java CodedInputStream.isAtEnd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.protobuf.CodedInputStream
的用法示例。
在下文中一共展示了CodedInputStream.isAtEnd方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readFrom
import com.google.protobuf.CodedInputStream; //导入方法依赖的package包/类
public static BlockListAsLongs readFrom(InputStream is) throws IOException {
CodedInputStream cis = CodedInputStream.newInstance(is);
int numBlocks = -1;
ByteString blocksBuf = null;
while (!cis.isAtEnd()) {
int tag = cis.readTag();
int field = WireFormat.getTagFieldNumber(tag);
switch(field) {
case 0:
break;
case 1:
numBlocks = (int)cis.readInt32();
break;
case 2:
blocksBuf = cis.readBytes();
break;
default:
cis.skipField(tag);
break;
}
}
if (numBlocks != -1 && blocksBuf != null) {
return decodeBuffer(numBlocks, blocksBuf);
}
return null;
}
示例2: readPreprocessedBlock
import com.google.protobuf.CodedInputStream; //导入方法依赖的package包/类
private Iterable<RtbImpression> readPreprocessedBlock(BlockContext context) throws IOException {
List<RtbImpression> impressions = new ArrayList<>();
try (InputStream is = context.createInputStream(PREPROCESS)) {
CodedInputStream cis = CodedInputStream.newInstance(is);
while (!cis.isAtEnd()) {
int len = cis.readRawVarint32();
int oldLimit = cis.pushLimit(len);
impressions.add(RtbImpression.parseFrom(cis));
cis.popLimit(oldLimit);
}
}
return impressions;
}
示例3: readLog
import com.google.protobuf.CodedInputStream; //导入方法依赖的package包/类
private OnlineSectioningLog.ExportedLog readLog(CodedInputStream cin) throws IOException {
if (cin.isAtEnd()) return null;
int size = cin.readInt32();
int limit = cin.pushLimit(size);
OnlineSectioningLog.ExportedLog ret = OnlineSectioningLog.ExportedLog.parseFrom(cin);
cin.popLimit(limit);
cin.resetSizeCounter();
return ret;
}
示例4: readTable
import com.google.protobuf.CodedInputStream; //导入方法依赖的package包/类
public static TableData.Table readTable(CodedInputStream cin) throws IOException {
if (cin.isAtEnd()) return null;
int size = cin.readInt32();
int limit = cin.pushLimit(size);
TableData.Table ret = TableData.Table.parseFrom(cin);
cin.popLimit(limit);
cin.resetSizeCounter();
return ret;
}
示例5: apply
import com.google.protobuf.CodedInputStream; //导入方法依赖的package包/类
List<T> apply(InputStream in) throws IOException {
List<T> list = new ArrayList<>();
CodedInputStream stream = CodedInputStream.newInstance(in);
int size;
while (!stream.isAtEnd() && (size = stream.readRawVarint32()) != 0) {
ByteArrayInputStream delimited = new ByteArrayInputStream(stream.readRawBytes(size));
list.add(parse.apply(delimited));
}
return list;
}
示例6: decode
import com.google.protobuf.CodedInputStream; //导入方法依赖的package包/类
/**
* Decode custom protobuf variable length array.
*
* @param <T> the item type
* @param data the raw input, not null
* @param parser the parser to decode each message, not null
* @return the decoded list of items, not null
* @throws IOException
* @throws NullPointerException if any arguments are null
*/
public static <T> List<T> decode(InputStream data, Parser<T> parser) throws IOException {
CodedInputStream stream = CodedInputStream.newInstance(data);
List<T> list = new ArrayList<>();
while (!stream.isAtEnd()) {
int size = stream.readRawVarint32();
byte[] element = stream.readRawBytes(size);
T decoded = parser.parseFrom(element);
list.add(decoded);
}
return list;
}