當前位置: 首頁>>代碼示例>>Java>>正文


Java CodedOutputStream.computeUInt32SizeNoTag方法代碼示例

本文整理匯總了Java中com.google.protobuf.CodedOutputStream.computeUInt32SizeNoTag方法的典型用法代碼示例。如果您正苦於以下問題:Java CodedOutputStream.computeUInt32SizeNoTag方法的具體用法?Java CodedOutputStream.computeUInt32SizeNoTag怎麽用?Java CodedOutputStream.computeUInt32SizeNoTag使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.protobuf.CodedOutputStream的用法示例。


在下文中一共展示了CodedOutputStream.computeUInt32SizeNoTag方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getSkippableIndexOverheadSize

import com.google.protobuf.CodedOutputStream; //導入方法依賴的package包/類
public static int getSkippableIndexOverheadSize(Type type, int recordSize) {
    switch (type) {
        case INT:
        case LONG:
        case DOUBLE:
        case FLOAT:
        case BYTES:
        case STRING:
        case BOOLEAN:
        case ENUM:
        case ANY:
            return 0;
        case RECORD:
        case MAP:
        case LIST:
            return CodedOutputStream.computeUInt32SizeNoTag(recordSize);
    }
    throw new IllegalArgumentException("?");
}
 
開發者ID:atlascon,項目名稱:travny,代碼行數:20,代碼來源:BinaryWriter.java

示例2: serializeTo

import com.google.protobuf.CodedOutputStream; //導入方法依賴的package包/類
@Override
public int serializeTo(int sourceId, Namespaces namespaces, OutputStream output)
    throws IOException {
  Builder xmlValue =
      SerializeFormat.DataValueXml.newBuilder()
          .setType(XmlType.ID)
          .putAllNamespace(namespaces.asMap());
  if (value != null) {
    xmlValue.setValue(value);
  }
  SerializeFormat.DataValue dataValue =
      XmlResourceValues.newSerializableDataValueBuilder(sourceId).setXmlValue(xmlValue).build();
  dataValue.writeDelimitedTo(output);
  return CodedOutputStream.computeUInt32SizeNoTag(dataValue.getSerializedSize())
      + dataValue.getSerializedSize();
}
 
開發者ID:bazelbuild,項目名稱:bazel,代碼行數:17,代碼來源:IdXmlResourceValue.java

示例3: serializeTo

import com.google.protobuf.CodedOutputStream; //導入方法依賴的package包/類
@Override
public int serializeTo(int sourceId, Namespaces namespaces, OutputStream output)
    throws IOException {
  SerializeFormat.DataValue.Builder builder =
      XmlResourceValues.newSerializableDataValueBuilder(sourceId);
  SerializeFormat.DataValue value =
      builder
          .setXmlValue(
              builder
                  .getXmlValueBuilder()
                  .setType(XmlType.PLURAL)
                  .putAllNamespace(namespaces.asMap())
                  .putAllAttribute(attributes)
                  .putAllMappedStringValue(values))
          .build();
  value.writeDelimitedTo(output);
  return CodedOutputStream.computeUInt32SizeNoTag(value.getSerializedSize())
      + value.getSerializedSize();
}
 
開發者ID:bazelbuild,項目名稱:bazel,代碼行數:20,代碼來源:PluralXmlResourceValue.java

示例4: sizeOf

import com.google.protobuf.CodedOutputStream; //導入方法依賴的package包/類
public static int sizeOf(Schema schema, Object value) {
    if (value == null) {
        return 0;
    }
    switch (schema.getType()) {
        // natively skippable types
        case INT:
            return CodedOutputStream.computeInt32SizeNoTag((Integer) value);
        case BOOLEAN:
            return 1;
        case LONG:
            return CodedOutputStream.computeInt64SizeNoTag((Long) value);
        case DOUBLE:
            return CodedOutputStream.computeDoubleSizeNoTag((Double) value);
        case FLOAT:
            return CodedOutputStream.computeFloatSizeNoTag((Float) value);
        case ENUM:
            return CodedOutputStream.computeUInt32SizeNoTag(((EnumConstant) value).getOrd());
        case ANY:
            return CodedOutputStream.computeUInt32SizeNoTag(((Any) value).getSchemaId()) +
                    CodedOutputStream.computeBoolSizeNoTag(((Any) value).isId()) +
                    CodedOutputStream.computeUInt32SizeNoTag(((Any) value).getData().length()) + ((Any) value).getData().length();
        // naturally length-delimited types
        case BYTES:
            return CodedOutputStream.computeUInt32SizeNoTag(((ByteArray) value).length()) + ((ByteArray) value).length();
        case STRING:
            return CodedOutputStream.computeStringSizeNoTag((String) value);
        // complex types
        case MAP:
            return sizeOfMap((MapSchema) schema, (Map) value);
        case LIST:
            return sizeOfList((ListSchema) schema, (List) value);
        case RECORD:
            return sizeOfRecord((Record) value);
        default:
            throw new IllegalArgumentException("Unknown type " + schema.getType());
    }
}
 
開發者ID:atlascon,項目名稱:travny,代碼行數:39,代碼來源:BinaryWriter.java

示例5: getSerializedSize

import com.google.protobuf.CodedOutputStream; //導入方法依賴的package包/類
public int getSerializedSize() {
	int size = memoizedSerializedSize;
	if (size != -1) return size;

	size = 0;
	{
		int dataSize = 0;
		for (int i = 0; i < session_.size(); i++) {
			dataSize += CodedOutputStream
					.computeUInt32SizeNoTag(session_.get(i));
		}
		size += dataSize;
		size += 1 * getSessionList().size();
	}
	if (((bitField0_ & 0x00000001) == 0x00000001)) {
		size += CodedOutputStream
				.computeUInt32Size(2, channelId_);
	}
	if (((bitField0_ & 0x00000002) == 0x00000002)) {
		size += CodedOutputStream
				.computeBytesSize(3, getGroupBytes());
	}
	if (((bitField0_ & 0x00000004) == 0x00000004)) {
		size += CodedOutputStream
				.computeBoolSize(4, links_);
	}
	if (((bitField0_ & 0x00000008) == 0x00000008)) {
		size += CodedOutputStream
				.computeBoolSize(5, children_);
	}
	size += getUnknownFields().getSerializedSize();
	memoizedSerializedSize = size;
	return size;
}
 
開發者ID:wjlafrance,項目名稱:grumble,代碼行數:35,代碼來源:Mumble.java

示例6: serializeProtoDataValue

import com.google.protobuf.CodedOutputStream; //導入方法依賴的package包/類
public static int serializeProtoDataValue(
    OutputStream output, SerializeFormat.DataValue.Builder builder) throws IOException {
  SerializeFormat.DataValue value = builder.build();
  value.writeDelimitedTo(output);
  return CodedOutputStream.computeUInt32SizeNoTag(value.getSerializedSize())
      + value.getSerializedSize();
}
 
開發者ID:bazelbuild,項目名稱:bazel,代碼行數:8,代碼來源:XmlResourceValues.java

示例7: serializeTo

import com.google.protobuf.CodedOutputStream; //導入方法依賴的package包/類
@Override
public int serializeTo(DataKey key, DataSourceTable sourceTable, OutputStream output)
    throws IOException {
  SerializeFormat.DataValue.Builder builder = SerializeFormat.DataValue.newBuilder();
  SerializeFormat.DataValue value = builder.setSourceId(sourceTable.getSourceId(source)).build();
  value.writeDelimitedTo(output);
  return CodedOutputStream.computeUInt32SizeNoTag(value.getSerializedSize())
      + value.getSerializedSize();
}
 
開發者ID:bazelbuild,項目名稱:bazel,代碼行數:10,代碼來源:DataValueFile.java

示例8: computeElementSizeNoTag

import com.google.protobuf.CodedOutputStream; //導入方法依賴的package包/類
/**
 * Compute the number of bytes that would be needed to encode a particular value of arbitrary type, excluding tag.
 *
 * @param type The field's type.
 * @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 computeElementSizeNoTag(final WireFormat.FieldType type, final Object value) {
    switch (type) {
        // Note: Minor violation of 80-char limit rule here because this would
        // actually be harder to read if we wrapped the lines.
        case DOUBLE:
            return CodedOutputStream.computeDoubleSizeNoTag((Double) value);
        case FLOAT:
            return CodedOutputStream.computeFloatSizeNoTag((Float) value);
        case INT64:
            return CodedOutputStream.computeInt64SizeNoTag((Long) value);
        case UINT64:
            return CodedOutputStream.computeUInt64SizeNoTag((Long) value);
        case INT32:
            return CodedOutputStream.computeInt32SizeNoTag((Integer) value);
        case FIXED64:
            return CodedOutputStream.computeFixed64SizeNoTag((Long) value);
        case FIXED32:
            return CodedOutputStream.computeFixed32SizeNoTag((Integer) value);
        case BOOL:
            return CodedOutputStream.computeBoolSizeNoTag((Boolean) value);
        case STRING:
            return CodedOutputStream.computeStringSizeNoTag((String) value);
        case GROUP:
            return CodedOutputStream.computeGroupSizeNoTag((MessageLite) value);
        case BYTES:
            if (value instanceof ByteString) {
                return CodedOutputStream.computeBytesSizeNoTag((ByteString) value);
            } else {
                return CodedOutputStream.computeByteArraySizeNoTag((byte[]) value);
            }
        case UINT32:
            return CodedOutputStream.computeUInt32SizeNoTag((Integer) value);
        case SFIXED32:
            return CodedOutputStream.computeSFixed32SizeNoTag((Integer) value);
        case SFIXED64:
            return CodedOutputStream.computeSFixed64SizeNoTag((Long) value);
        case SINT32:
            return CodedOutputStream.computeSInt32SizeNoTag((Integer) value);
        case SINT64:
            return CodedOutputStream.computeSInt64SizeNoTag((Long) value);

        case MESSAGE:
            if (value instanceof LazyField) {
                return CodedOutputStream.computeLazyFieldSizeNoTag((LazyField) value);
            } else {
                return computeObjectSizeNoTag(value);
            }

        case ENUM:
            if (value instanceof Internal.EnumLite) {
                return CodedOutputStream.computeEnumSizeNoTag(((Internal.EnumLite) value).getNumber());
            } else {
                if (value instanceof EnumReadable) {
                    return CodedOutputStream.computeEnumSizeNoTag(((EnumReadable) value).value());
                } else if (value instanceof Enum) {
                    return CodedOutputStream.computeEnumSizeNoTag(((Enum) value).ordinal());
                }

                return CodedOutputStream.computeEnumSizeNoTag((Integer) value);
            }
    }

    throw new RuntimeException("There is no way to get here, but the compiler thinks otherwise.");
}
 
開發者ID:jhunters,項目名稱:jprotobuf,代碼行數:73,代碼來源:CodedConstant.java

示例9: computeLengthDelimitedFieldSize

import com.google.protobuf.CodedOutputStream; //導入方法依賴的package包/類
/**
 * Compute length delimited field size.
 *
 * @param fieldLength the field length
 * @return the int
 */
public static int computeLengthDelimitedFieldSize(int fieldLength) {
    return CodedOutputStream.computeUInt32SizeNoTag(fieldLength) + fieldLength;
}
 
開發者ID:jhunters,項目名稱:jprotobuf,代碼行數:10,代碼來源:CodedConstant.java


注:本文中的com.google.protobuf.CodedOutputStream.computeUInt32SizeNoTag方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。