当前位置: 首页>>代码示例>>Java>>正文


Java CodedInputStream.readMessage方法代码示例

本文整理汇总了Java中com.google.protobuf.CodedInputStream.readMessage方法的典型用法代码示例。如果您正苦于以下问题:Java CodedInputStream.readMessage方法的具体用法?Java CodedInputStream.readMessage怎么用?Java CodedInputStream.readMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.protobuf.CodedInputStream的用法示例。


在下文中一共展示了CodedInputStream.readMessage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: PushSMPMessageContent

import com.google.protobuf.CodedInputStream; //导入方法依赖的package包/类
private PushSMPMessageContent(CodedInputStream input, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException {
	this.memoizedIsInitialized = -1;
	this.memoizedSerializedSize = -1;
	this.initFields();
	int mutable_bitField0_ = 0;
	com.google.protobuf.UnknownFieldSet.Builder unknownFields = UnknownFieldSet.newBuilder();

	try {
		boolean e = false;

		while(!e) {
			int tag = input.readTag();
			switch(tag) {
				case 0:
					e = true;
					break;
				case 10:
					this.bitField0_ |= 1;
					this.body_ = input.readBytes();
					break;
				case 18:
					if((mutable_bitField0_ & 2) != 2) {
						this.attachments_ = new ArrayList();
						mutable_bitField0_ |= 2;
					}

					this.attachments_.add(input.readMessage(PushSMPMessageProtos.PushSMPMessageContent.AttachmentPointer.PARSER, extensionRegistry));
					break;
				case 26:
					PushSMPMessageProtos.PushSMPMessageContent.GroupContext.Builder subBuilder1 = null;
					if((this.bitField0_ & 2) == 2) {
						subBuilder1 = this.group_.toBuilder();
					}

					this.group_ = (PushSMPMessageProtos.PushSMPMessageContent.GroupContext)input.readMessage(PushSMPMessageProtos.PushSMPMessageContent.GroupContext.PARSER, extensionRegistry);
					if(subBuilder1 != null) {
						subBuilder1.mergeFrom(this.group_);
						this.group_ = subBuilder1.buildPartial();
					}

					this.bitField0_ |= 2;
					break;
				case 32:
					this.bitField0_ |= 4;
					this.flags_ = input.readUInt32();
					break;
				case 42:
					PushSMPMessageProtos.PushSMPMessageContent.SyncMessageContext.Builder subBuilder = null;
					if((this.bitField0_ & 8) == 8) {
						subBuilder = this.sync_.toBuilder();
					}

					this.sync_ = (PushSMPMessageProtos.PushSMPMessageContent.SyncMessageContext)input.readMessage(PushSMPMessageProtos.PushSMPMessageContent.SyncMessageContext.PARSER, extensionRegistry);
					if(subBuilder != null) {
						subBuilder.mergeFrom(this.sync_);
						this.sync_ = subBuilder.buildPartial();
					}

					this.bitField0_ |= 8;
					break;
				default:
					if(!this.parseUnknownField(input, unknownFields, extensionRegistry, tag)) {
						e = true;
					}
			}
		}
	} catch (InvalidProtocolBufferException var12) {
		throw var12.setUnfinishedMessage(this);
	} catch (IOException var13) {
		throw (new InvalidProtocolBufferException(var13.getMessage())).setUnfinishedMessage(this);
	} finally {
		if((mutable_bitField0_ & 2) == 2) {
			this.attachments_ = Collections.unmodifiableList(this.attachments_);
		}

		this.unknownFields = unknownFields.build();
		this.makeExtensionsImmutable();
	}

}
 
开发者ID:Agilitum,项目名称:TextSecureSMP,代码行数:81,代码来源:PushSMPMessageProtos.java

示例2: GroupContext

import com.google.protobuf.CodedInputStream; //导入方法依赖的package包/类
private GroupContext(CodedInputStream input, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException {
	this.memoizedIsInitialized = -1;
	this.memoizedSerializedSize = -1;
	this.initFields();
	int mutable_bitField0_ = 0;
	com.google.protobuf.UnknownFieldSet.Builder unknownFields = UnknownFieldSet.newBuilder();

	try {
		boolean e = false;

		while(!e) {
			int tag = input.readTag();
			switch(tag) {
				case 0:
					e = true;
					break;
				case 10:
					this.bitField0_ |= 1;
					this.id_ = input.readBytes();
					break;
				case 16:
					int subBuilder1 = input.readEnum();
					PushSMPMessageProtos.PushSMPMessageContent.GroupContext.Type value = PushSMPMessageProtos.PushSMPMessageContent.GroupContext.Type.valueOf(subBuilder1);
					if(value == null) {
						unknownFields.mergeVarintField(2, subBuilder1);
					} else {
						this.bitField0_ |= 2;
						this.type_ = value;
					}
					break;
				case 26:
					this.bitField0_ |= 4;
					this.name_ = input.readBytes();
					break;
				case 34:
					if((mutable_bitField0_ & 8) != 8) {
						this.members_ = new LazyStringArrayList();
						mutable_bitField0_ |= 8;
					}

					this.members_.add(input.readBytes());
					break;
				case 42:
					PushSMPMessageProtos.PushSMPMessageContent.AttachmentPointer.Builder subBuilder = null;
					if((this.bitField0_ & 8) == 8) {
						subBuilder = this.avatar_.toBuilder();
					}

					this.avatar_ = (PushSMPMessageProtos.PushSMPMessageContent.AttachmentPointer)input.readMessage(PushSMPMessageProtos.PushSMPMessageContent.AttachmentPointer.PARSER, extensionRegistry);
					if(subBuilder != null) {
						subBuilder.mergeFrom(this.avatar_);
						this.avatar_ = subBuilder.buildPartial();
					}

					this.bitField0_ |= 8;
					break;
				default:
					if(!this.parseUnknownField(input, unknownFields, extensionRegistry, tag)) {
						e = true;
					}
			}
		}
	} catch (InvalidProtocolBufferException var13) {
		throw var13.setUnfinishedMessage(this);
	} catch (IOException var14) {
		throw (new InvalidProtocolBufferException(var14.getMessage())).setUnfinishedMessage(this);
	} finally {
		if((mutable_bitField0_ & 8) == 8) {
			this.members_ = new UnmodifiableLazyStringList(this.members_);
		}

		this.unknownFields = unknownFields.build();
		this.makeExtensionsImmutable();
	}

}
 
开发者ID:Agilitum,项目名称:TextSecureSMP,代码行数:77,代码来源:PushSMPMessageProtos.java

示例3: putMapValue

import com.google.protobuf.CodedInputStream; //导入方法依赖的package包/类
/**
 * Put map value.
 *
 * @param <K> the key type
 * @param <V> the value type
 * @param input the input
 * @param map the map
 * @param keyType the key type
 * @param defaultKey the default key
 * @param valueType the value type
 * @param defalutValue the defalut value
 * @throws IOException Signals that an I/O exception has occurred.
 */
public static <K, V> void putMapValue(CodedInputStream input, Map<K, V> map,
        com.google.protobuf.WireFormat.FieldType keyType, K defaultKey,
        com.google.protobuf.WireFormat.FieldType valueType, V defalutValue) throws IOException {
    com.baidu.bjf.remoting.protobuf.MapEntry<K, V> valuesDefaultEntry = com.baidu.bjf.remoting.protobuf.MapEntry
            .<K, V> newDefaultInstance(null, keyType, defaultKey, valueType, defalutValue);

    com.baidu.bjf.remoting.protobuf.MapEntry<K, V> values =
            input.readMessage(valuesDefaultEntry.getParserForType(), null);
    map.put(values.getKey(), values.getValue());

}
 
开发者ID:jhunters,项目名称:jprotobuf,代码行数:25,代码来源:CodedConstant.java


注:本文中的com.google.protobuf.CodedInputStream.readMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。