本文整理匯總了Java中com.google.protobuf.CodedOutputStream.computeBoolSize方法的典型用法代碼示例。如果您正苦於以下問題:Java CodedOutputStream.computeBoolSize方法的具體用法?Java CodedOutputStream.computeBoolSize怎麽用?Java CodedOutputStream.computeBoolSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.protobuf.CodedOutputStream
的用法示例。
在下文中一共展示了CodedOutputStream.computeBoolSize方法的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
.computeUInt32Size(1, session_);
}
if (((bitField0_ & 0x00000002) == 0x00000002)) {
size += CodedOutputStream
.computeUInt32Size(2, actor_);
}
if (((bitField0_ & 0x00000004) == 0x00000004)) {
size += CodedOutputStream
.computeBytesSize(3, getReasonBytes());
}
if (((bitField0_ & 0x00000008) == 0x00000008)) {
size += CodedOutputStream
.computeBoolSize(4, ban_);
}
size += getUnknownFields().getSerializedSize();
memoizedSerializedSize = size;
return size;
}
示例2: getSerializedPointSize
import com.google.protobuf.CodedOutputStream; //導入方法依賴的package包/類
public int getSerializedPointSize(Track.TrackPoint point) {
int size = 0;
size += CodedOutputStream.computeInt32Size(FIELD_POINT_LATITUDE, point.latitudeE6);
size += CodedOutputStream.computeInt32Size(FIELD_POINT_LONGITUDE, point.longitudeE6);
size += CodedOutputStream.computeFloatSize(FIELD_POINT_ALTITUDE, point.elevation);
size += CodedOutputStream.computeFloatSize(FIELD_POINT_SPEED, point.speed);
size += CodedOutputStream.computeFloatSize(FIELD_POINT_BEARING, point.bearing);
size += CodedOutputStream.computeFloatSize(FIELD_POINT_ACCURACY, point.accuracy);
size += CodedOutputStream.computeUInt64Size(FIELD_POINT_TIMESTAMP, point.time);
if (!point.continuous) {
//noinspection ConstantConditions
size += CodedOutputStream.computeBoolSize(FIELD_POINT_CONTINUOUS, point.continuous);
}
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;
}