/**
* Compute the number of bytes that would be needed to encode a single tag/value pair of arbitrary type.
*
* @param type The field's type.
* @param number The field's number.
* @param value Object representing the field's value. Must be of the exact type which would be returned by
* {@link Message#getField(Descriptors.FieldDescriptor)} for this field.
* @return the int
*/
public static int computeElementSize(final WireFormat.FieldType type, final int number, final Object value) {
int tagSize = CodedOutputStream.computeTagSize(number);
if (type == WireFormat.FieldType.GROUP) {
// Only count the end group tag for proto2 messages as for proto1 the end
// group tag will be counted as a part of getSerializedSize().
tagSize *= 2;
}
return tagSize + computeElementSizeNoTag(type, value);
}
CodedConstant.java 文件源码
java
阅读 29
收藏 0
点赞 0
评论 0
项目:jprotobuf
作者:
评论列表
文章目录