本文整理汇总了Java中com.google.protobuf.ExtensionRegistryLite类的典型用法代码示例。如果您正苦于以下问题:Java ExtensionRegistryLite类的具体用法?Java ExtensionRegistryLite怎么用?Java ExtensionRegistryLite使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ExtensionRegistryLite类属于com.google.protobuf包,在下文中一共展示了ExtensionRegistryLite类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mergeFrom
import com.google.protobuf.ExtensionRegistryLite; //导入依赖的package包/类
public PushSMPMessageProtos.PushSMPMessageContent.Builder mergeFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry) throws IOException {
PushSMPMessageProtos.PushSMPMessageContent parsedMessage = null;
try {
parsedMessage = (PushSMPMessageProtos.PushSMPMessageContent)PushSMPMessageProtos.PushSMPMessageContent.PARSER.parsePartialFrom(input, extensionRegistry);
} catch (InvalidProtocolBufferException var8) {
parsedMessage = (PushSMPMessageProtos.PushSMPMessageContent)var8.getUnfinishedMessage();
throw var8;
} finally {
if(parsedMessage != null) {
this.mergeFrom(parsedMessage);
}
}
return this;
}
示例2: parseField
import com.google.protobuf.ExtensionRegistryLite; //导入依赖的package包/类
/**
* Parses the field.
*
* @param <T> the generic type
* @param input the input
* @param extensionRegistry the extension registry
* @param type the type
* @param value the value
* @return the t
* @throws IOException Signals that an I/O exception has occurred.
*/
@SuppressWarnings("unchecked")
static <T> T parseField(CodedInputStream input, ExtensionRegistryLite extensionRegistry, WireFormat.FieldType type,
T value) throws IOException {
switch (type) {
case MESSAGE:
int length = input.readRawVarint32();
final int oldLimit = input.pushLimit(length);
Codec<? extends Object> codec = ProtobufProxy.create(value.getClass());
T ret = (T) codec.decode(input.readRawBytes(length));
input.popLimit(oldLimit);
return ret;
case ENUM:
return (T) (java.lang.Integer) input.readEnum();
case GROUP:
throw new RuntimeException("Groups are not allowed in maps.");
default:
return (T) CodedConstant.readPrimitiveField(input, type, true);
}
}
示例3: mergeFrom
import com.google.protobuf.ExtensionRegistryLite; //导入依赖的package包/类
public Builder mergeFrom(
CodedInputStream input,
ExtensionRegistryLite extensionRegistry)
throws IOException {
MumbleProto.Mumble.Version parsedMessage = null;
try {
parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
} catch (InvalidProtocolBufferException e) {
parsedMessage = (MumbleProto.Mumble.Version) e.getUnfinishedMessage();
throw e;
} finally {
if (parsedMessage != null) {
mergeFrom(parsedMessage);
}
}
return this;
}
示例4: ProtobufDecoder
import com.google.protobuf.ExtensionRegistryLite; //导入依赖的package包/类
public ProtobufDecoder(MessageLite prototype, ExtensionRegistryLite extensionRegistry) {
if (prototype == null) {
throw new NullPointerException("prototype");
}
this.prototype = prototype.getDefaultInstanceForType();
this.extensionRegistry = extensionRegistry;
}
示例5: parse
import com.google.protobuf.ExtensionRegistryLite; //导入依赖的package包/类
@Override
public DynamicMessage parse(InputStream inputStream) {
try {
return DynamicMessage.newBuilder(messageDescriptor)
.mergeFrom(inputStream, ExtensionRegistryLite.getEmptyRegistry())
.build();
} catch (IOException e) {
throw new RuntimeException("Unable to merge from the supplied input stream", e);
}
}
示例6: readMessage
import com.google.protobuf.ExtensionRegistryLite; //导入依赖的package包/类
/** Read an embedded message field value from the stream. */
public void readMessage(final ByteBufMessageBuilder builder, final ExtensionRegistryLite extensionRegistry)
throws IOException {
final int length = readRawVarint32();
int writerIdx = buf.writerIndex();
buf.writerIndex(buf.readerIndex() + length);
builder.mergeFrom(this, extensionRegistry);
checkLastTagWas(0);
buf.writerIndex(writerIdx);
}
示例7: ProtobufLiteDecoder
import com.google.protobuf.ExtensionRegistryLite; //导入依赖的package包/类
public ProtobufLiteDecoder(MessageLite prototype, ExtensionRegistryLite extensionRegistry)
{
if (prototype == null)
{
throw new NullPointerException("prototype");
}
this.prototype = prototype.getDefaultInstanceForType();
this.extensionRegistry = extensionRegistry;
}
示例8: SyncMessageContext
import com.google.protobuf.ExtensionRegistryLite; //导入依赖的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();
}
}
示例9: protoDeserialize
import com.google.protobuf.ExtensionRegistryLite; //导入依赖的package包/类
/**
* @param bytes 字节数据
* @param messageLite 序列化对应的类型
* @return
* @throws JRedisCacheException
*/
public static MessageLite protoDeserialize(byte[] bytes, MessageLite messageLite) throws JRedisCacheException {
assert (bytes != null && messageLite != null);
try {
return messageLite.getParserForType().parsePartialFrom(CodedInputStream.newInstance(bytes), ExtensionRegistryLite.getEmptyRegistry());
} catch (InvalidProtocolBufferException e) {
e.printStackTrace();
return null;
}
}
示例10: parseInto
import com.google.protobuf.ExtensionRegistryLite; //导入依赖的package包/类
/**
* Parses an entry off of the input into the map. This helper avoids allocaton of a {@link MapEntryLite} by parsing
* directly into the provided {@link MapFieldLite}.
*
* @param map the map
* @param input the input
* @param extensionRegistry the extension registry
* @throws IOException Signals that an I/O exception has occurred.
*/
public void parseInto(MapFieldLite<K, V> map, CodedInputStream input, ExtensionRegistryLite extensionRegistry)
throws IOException {
int length = input.readRawVarint32();
final int oldLimit = input.pushLimit(length);
K key = metadata.defaultKey;
V value = metadata.defaultValue;
while (true) {
int tag = input.readTag();
if (tag == 0) {
break;
}
if (tag == CodedConstant.makeTag(KEY_FIELD_NUMBER, metadata.keyType.getWireType())) {
key = parseField(input, extensionRegistry, metadata.keyType, key);
} else if (tag == CodedConstant.makeTag(VALUE_FIELD_NUMBER, metadata.valueType.getWireType())) {
value = parseField(input, extensionRegistry, metadata.valueType, value);
} else {
if (!input.skipField(tag)) {
break;
}
}
}
input.checkLastTagWas(0);
input.popLimit(oldLimit);
map.put(key, value);
}
示例11: Metadata
import com.google.protobuf.ExtensionRegistryLite; //导入依赖的package包/类
/**
* Instantiates a new metadata.
*
* @param descriptor the descriptor
* @param defaultInstance the default instance
* @param keyType the key type
* @param valueType the value type
*/
public Metadata(Descriptor descriptor, MapEntry<K, V> defaultInstance, WireFormat.FieldType keyType,
WireFormat.FieldType valueType) {
super(keyType, defaultInstance.key, valueType, defaultInstance.value);
this.descriptor = descriptor;
this.parser = new AbstractParser<MapEntry<K, V>>() {
@Override
public MapEntry<K, V> parsePartialFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)
throws InvalidProtocolBufferException {
return new MapEntry<K, V>(Metadata.this, input, extensionRegistry);
}
};
}
示例12: addDeserializationCode
import com.google.protobuf.ExtensionRegistryLite; //导入依赖的package包/类
@Override
public void addDeserializationCode(Context context) {
String builderName = context.makeName("builder");
context.builder.addStatement(
"$T.Builder $L = $T.newBuilder()",
context.getTypeName(),
builderName,
context.getTypeName());
context.builder.addStatement(
"codedIn.readMessage($L, $T.getEmptyRegistry())",
builderName,
ExtensionRegistryLite.class);
context.builder.addStatement("$L = $L.build()", context.name, builderName);
}
示例13: ProtoResponseBodyConverter
import com.google.protobuf.ExtensionRegistryLite; //导入依赖的package包/类
ProtoResponseBodyConverter(Parser<T> parser, ExtensionRegistryLite registry) {
this.parser = parser;
this.registry = registry;
}
示例14: createWithRegistry
import com.google.protobuf.ExtensionRegistryLite; //导入依赖的package包/类
/** Create an instance which uses {@code registry} when deserializing. */
public static ProtoConverterFactory createWithRegistry(ExtensionRegistryLite registry) {
return new ProtoConverterFactory(registry);
}
示例15: ProtoConverterFactory
import com.google.protobuf.ExtensionRegistryLite; //导入依赖的package包/类
private ProtoConverterFactory(ExtensionRegistryLite registry) {
this.registry = registry;
}