當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。