本文整理汇总了Java中com.google.protobuf.CodedInputStream.readBytes方法的典型用法代码示例。如果您正苦于以下问题:Java CodedInputStream.readBytes方法的具体用法?Java CodedInputStream.readBytes怎么用?Java CodedInputStream.readBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.protobuf.CodedInputStream
的用法示例。
在下文中一共展示了CodedInputStream.readBytes方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readFrom
import com.google.protobuf.CodedInputStream; //导入方法依赖的package包/类
public static BlockListAsLongs readFrom(InputStream is) throws IOException {
CodedInputStream cis = CodedInputStream.newInstance(is);
int numBlocks = -1;
ByteString blocksBuf = null;
while (!cis.isAtEnd()) {
int tag = cis.readTag();
int field = WireFormat.getTagFieldNumber(tag);
switch(field) {
case 0:
break;
case 1:
numBlocks = (int)cis.readInt32();
break;
case 2:
blocksBuf = cis.readBytes();
break;
default:
cis.skipField(tag);
break;
}
}
if (numBlocks != -1 && blocksBuf != null) {
return decodeBuffer(numBlocks, blocksBuf);
}
return null;
}
示例2: deserializeOneNestedSet
import com.google.protobuf.CodedInputStream; //导入方法依赖的package包/类
private Object deserializeOneNestedSet(
CodedInputStream codedIn, Map<ByteString, Object> digestToChild)
throws SerializationException, IOException {
ByteString digest = codedIn.readBytes();
CodedInputStream childCodedIn = codedIn.readBytes().newCodedInput();
childCodedIn.enableAliasing(true); // Allow efficient views of byte slices when reading digests
int childCount = childCodedIn.readInt32();
final Object result;
if (childCount > 1) {
result = deserializeMultipleItemChildArray(digestToChild, childCodedIn, childCount);
} else if (childCount == 1) {
result = objectCodec.deserialize(childCodedIn);
} else {
result = NestedSet.EMPTY_CHILDREN;
}
digestToChild.put(digest, result);
return result;
}
示例3: deserializeMultipleItemChildArray
import com.google.protobuf.CodedInputStream; //导入方法依赖的package包/类
private Object deserializeMultipleItemChildArray(
Map<ByteString, Object> digestToChild, CodedInputStream childCodedIn, int childCount)
throws IOException, SerializationException {
Object[] children = new Object[childCount];
for (int i = 0; i < childCount; ++i) {
boolean isTransitiveEntry = childCodedIn.readBool();
if (isTransitiveEntry) {
ByteString digest = childCodedIn.readBytes();
children[i] =
Preconditions.checkNotNull(digestToChild.get(digest), "Transitive nested set missing");
} else {
children[i] = objectCodec.deserialize(childCodedIn);
}
}
return children;
}
示例4: SyncMessageContext
import com.google.protobuf.CodedInputStream; //导入方法依赖的package包/类
private SyncMessageContext(CodedInputStream input, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException {
this.memoizedIsInitialized = -1;
this.memoizedSerializedSize = -1;
this.initFields();
boolean mutable_bitField0_ = false;
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.destination_ = input.readBytes();
break;
case 16:
this.bitField0_ |= 2;
this.timestamp_ = input.readUInt64();
break;
default:
if(!this.parseUnknownField(input, unknownFields, extensionRegistry, tag)) {
e = true;
}
}
}
} catch (InvalidProtocolBufferException var11) {
throw var11.setUnfinishedMessage(this);
} catch (IOException var12) {
throw (new InvalidProtocolBufferException(var12.getMessage())).setUnfinishedMessage(this);
} finally {
this.unknownFields = unknownFields.build();
this.makeExtensionsImmutable();
}
}
示例5: 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();
}
}
示例6: 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();
}
}
示例7: AttachmentPointer
import com.google.protobuf.CodedInputStream; //导入方法依赖的package包/类
private AttachmentPointer(CodedInputStream input, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException {
this.memoizedIsInitialized = -1;
this.memoizedSerializedSize = -1;
this.initFields();
boolean mutable_bitField0_ = false;
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 9:
this.bitField0_ |= 1;
this.id_ = input.readFixed64();
break;
case 18:
this.bitField0_ |= 2;
this.contentType_ = input.readBytes();
break;
case 26:
this.bitField0_ |= 4;
this.key_ = input.readBytes();
break;
default:
if(!this.parseUnknownField(input, unknownFields, extensionRegistry, tag)) {
e = true;
}
}
}
} catch (InvalidProtocolBufferException var11) {
throw var11.setUnfinishedMessage(this);
} catch (IOException var12) {
throw (new InvalidProtocolBufferException(var12.getMessage())).setUnfinishedMessage(this);
} finally {
this.unknownFields = unknownFields.build();
this.makeExtensionsImmutable();
}
}
示例8: IncomingPushMessageSignal
import com.google.protobuf.CodedInputStream; //导入方法依赖的package包/类
private IncomingPushMessageSignal(CodedInputStream input, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException {
this.memoizedIsInitialized = -1;
this.memoizedSerializedSize = -1;
this.initFields();
boolean mutable_bitField0_ = false;
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 8:
int rawValue = input.readEnum();
PushSMPMessageProtos.IncomingPushMessageSignal.Type value = PushSMPMessageProtos.IncomingPushMessageSignal.Type.valueOf(rawValue);
if(value == null) {
unknownFields.mergeVarintField(1, rawValue);
} else {
this.bitField0_ |= 1;
this.type_ = value;
}
break;
case 18:
this.bitField0_ |= 2;
this.source_ = input.readBytes();
break;
case 26:
this.bitField0_ |= 8;
this.relay_ = input.readBytes();
break;
case 40:
this.bitField0_ |= 16;
this.timestamp_ = input.readUInt64();
break;
case 50:
this.bitField0_ |= 32;
this.message_ = input.readBytes();
break;
case 56:
this.bitField0_ |= 4;
this.sourceDevice_ = input.readUInt32();
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 {
this.unknownFields = unknownFields.build();
this.makeExtensionsImmutable();
}
}
示例9: readPrimitiveField
import com.google.protobuf.CodedInputStream; //导入方法依赖的package包/类
/**
* Read a field of any primitive type for immutable messages from a CodedInputStream. Enums, groups, and embedded
* messages are not handled by this method.
*
* @param input The stream from which to read.
* @param type Declared type of the field.
* @param checkUtf8 When true, check that the input is valid utf8.
* @return An object representing the field's value, of the exact type which would be returned by
* {@link Message#getField(Descriptors.FieldDescriptor)} for this field.
* @throws IOException Signals that an I/O exception has occurred.
*/
public static Object readPrimitiveField(CodedInputStream input, final WireFormat.FieldType type, boolean checkUtf8)
throws IOException {
switch (type) {
case DOUBLE:
return input.readDouble();
case FLOAT:
return input.readFloat();
case INT64:
return input.readInt64();
case UINT64:
return input.readUInt64();
case INT32:
return input.readInt32();
case FIXED64:
return input.readFixed64();
case FIXED32:
return input.readFixed32();
case BOOL:
return input.readBool();
case STRING:
if (checkUtf8) {
return input.readStringRequireUtf8();
} else {
return input.readString();
}
case BYTES:
return input.readBytes();
case UINT32:
return input.readUInt32();
case SFIXED32:
return input.readSFixed32();
case SFIXED64:
return input.readSFixed64();
case SINT32:
return input.readSInt32();
case SINT64:
return input.readSInt64();
case GROUP:
throw new IllegalArgumentException("readPrimitiveField() cannot handle nested groups.");
case MESSAGE:
throw new IllegalArgumentException("readPrimitiveField() cannot handle embedded messages.");
case ENUM:
// We don't handle enums because we don't know what to do if the
// value is not recognized.
throw new IllegalArgumentException("readPrimitiveField() cannot handle enums.");
}
throw new RuntimeException("There is no way to get here, but the compiler thinks otherwise.");
}