本文整理匯總了Java中com.google.protobuf.CodedOutputStream.computeEnumSize方法的典型用法代碼示例。如果您正苦於以下問題:Java CodedOutputStream.computeEnumSize方法的具體用法?Java CodedOutputStream.computeEnumSize怎麽用?Java CodedOutputStream.computeEnumSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.protobuf.CodedOutputStream
的用法示例。
在下文中一共展示了CodedOutputStream.computeEnumSize方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getSerializedSize
import com.google.protobuf.CodedOutputStream; //導入方法依賴的package包/類
public int getSerializedSize() {
int size = memoizedSerializedSize;
if (size != -1) return size;
size = 0;
if (((bitField0_ & 0x00000001) == 0x00000001)) {
size += CodedOutputStream
.computeEnumSize(1, type_.getNumber());
}
if (((bitField0_ & 0x00000002) == 0x00000002)) {
size += CodedOutputStream
.computeBytesSize(2, getReasonBytes());
}
size += getUnknownFields().getSerializedSize();
memoizedSerializedSize = size;
return size;
}
示例2: getSerializedSize
import com.google.protobuf.CodedOutputStream; //導入方法依賴的package包/類
public int getSerializedSize() {
int size = this.memoizedSerializedSize;
if(size != -1) {
return size;
} else {
size = 0;
if((this.bitField0_ & 1) == 1) {
size += CodedOutputStream.computeBytesSize(1, this.id_);
}
if((this.bitField0_ & 2) == 2) {
size += CodedOutputStream.computeEnumSize(2, this.type_.getNumber());
}
if((this.bitField0_ & 4) == 4) {
size += CodedOutputStream.computeBytesSize(3, this.getNameBytes());
}
int dataSize = 0;
for(int i = 0; i < this.members_.size(); ++i) {
dataSize += CodedOutputStream.computeBytesSizeNoTag(this.members_.getByteString(i));
}
size += dataSize;
size += 1 * this.getMembersList().size();
if((this.bitField0_ & 8) == 8) {
size += CodedOutputStream.computeMessageSize(5, this.avatar_);
}
size += this.getUnknownFields().getSerializedSize();
this.memoizedSerializedSize = size;
return size;
}
}
示例3: computeSize
import com.google.protobuf.CodedOutputStream; //導入方法依賴的package包/類
private int computeSize(FieldInfo fieldInfo, Object value) throws IOException {
FieldType fieldType = fieldInfo.getFieldType();
int size = 0;
if (value instanceof List) {
// if list
size = CodedConstant.computeListSize(fieldInfo.getOrder(), (List) value, fieldInfo.getFieldType(), true, null);
return size;
}
int order = fieldInfo.getOrder();
switch (fieldType) {
case DOUBLE:
size = CodedOutputStream.computeDoubleSize(order, (Double) value);
break;
case BYTES:
ByteString bytes = ByteString.copyFrom((byte[]) value);
size = CodedOutputStream.computeBytesSize(order, bytes);
break;
case STRING:
ByteString string = ByteString.copyFromUtf8(value.toString());
size = CodedOutputStream.computeBytesSize(order, string);
break;
case BOOL:
size = CodedOutputStream.computeBoolSize(order, (Boolean) value);
break;
case FIXED32:
size = CodedOutputStream.computeFixed32Size(order, (Integer) value);
break;
case SFIXED32:
size = CodedOutputStream.computeSFixed32Size(order, (Integer) value);
break;
case SINT32:
size = CodedOutputStream.computeSInt32Size(order, (Integer) value);
break;
case INT32:
size = CodedOutputStream.computeInt32Size(order, (Integer) value);
break;
case UINT32:
size = CodedOutputStream.computeUInt32Size(order, (Integer) value);
break;
case FIXED64:
size = CodedOutputStream.computeFixed64Size(order, (Long) value);
break;
case SFIXED64:
size = CodedOutputStream.computeSFixed64Size(order, (Long) value);
break;
case SINT64:
size = CodedOutputStream.computeSInt64Size(order, (Long) value);
break;
case INT64:
size = CodedOutputStream.computeInt64Size(order, (Long) value);
break;
case UINT64:
size = CodedOutputStream.computeUInt64Size(order, (Long) value);
break;
case ENUM:
int i;
i = getEnumValue(value);
size = CodedOutputStream.computeEnumSize(order, i);
break;
case FLOAT:
size = CodedOutputStream.computeFloatSize(order, (Float) value);
break;
case OBJECT:
Class c = value.getClass();
ReflectiveCodec codec = new ReflectiveCodec(c);
int objectSize = codec.size(value);
size = size + CodedOutputStream.computeRawVarint32Size(objectSize);
size = size + CodedOutputStream.computeTagSize(order);
size += objectSize;
break;
default:
throw new IOException("Unknown field type on field '" + fieldInfo.getField().getName() + "'");
}
return size;
}