本文整理汇总了Java中com.google.protobuf.DescriptorProtos.DescriptorProto.getField方法的典型用法代码示例。如果您正苦于以下问题:Java DescriptorProto.getField方法的具体用法?Java DescriptorProto.getField怎么用?Java DescriptorProto.getField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.protobuf.DescriptorProtos.DescriptorProto
的用法示例。
在下文中一共展示了DescriptorProto.getField方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: appendToFullName
import com.google.protobuf.DescriptorProtos.DescriptorProto; //导入方法依赖的package包/类
private static Optional<String> appendToFullName(
DescriptorProto messageDescriptor, List<Integer> path, String fullNameSoFar) {
switch (path.get(0)) {
case DescriptorProto.NESTED_TYPE_FIELD_NUMBER:
DescriptorProto nestedMessage = messageDescriptor.getNestedType(path.get(1));
return appendMessageToFullName(nestedMessage, path, fullNameSoFar);
case DescriptorProto.ENUM_TYPE_FIELD_NUMBER:
EnumDescriptorProto enumDescriptor = messageDescriptor.getEnumType(path.get(1));
return Optional.of(appendEnumToFullName(enumDescriptor, path, fullNameSoFar));
case DescriptorProto.FIELD_FIELD_NUMBER:
FieldDescriptorProto fieldDescriptor = messageDescriptor.getField(path.get(1));
return Optional.of(appendFieldComponent(fullNameSoFar, fieldDescriptor.getName()));
default:
return Optional.empty();
}
}
示例2: Descriptor
import com.google.protobuf.DescriptorProtos.DescriptorProto; //导入方法依赖的package包/类
private Descriptor(final DescriptorProto proto,
final FileDescriptor file,
final Descriptor parent,
final int index)
throws DescriptorValidationException {
this.index = index;
this.proto = proto;
fullName = computeFullName(file, parent, proto.getName());
this.file = file;
containingType = parent;
oneofs = new OneofDescriptor[proto.getOneofDeclCount()];
for (int i = 0; i < proto.getOneofDeclCount(); i++) {
oneofs[i] = new OneofDescriptor(
proto.getOneofDecl(i), file, this, i);
}
nestedTypes = new Descriptor[proto.getNestedTypeCount()];
for (int i = 0; i < proto.getNestedTypeCount(); i++) {
nestedTypes[i] = new Descriptor(
proto.getNestedType(i), file, this, i);
}
enumTypes = new EnumDescriptor[proto.getEnumTypeCount()];
for (int i = 0; i < proto.getEnumTypeCount(); i++) {
enumTypes[i] = new EnumDescriptor(
proto.getEnumType(i), file, this, i);
}
fields = new FieldDescriptor[proto.getFieldCount()];
for (int i = 0; i < proto.getFieldCount(); i++) {
fields[i] = new FieldDescriptor(
proto.getField(i), file, this, i, false);
}
extensions = new FieldDescriptor[proto.getExtensionCount()];
for (int i = 0; i < proto.getExtensionCount(); i++) {
extensions[i] = new FieldDescriptor(
proto.getExtension(i), file, this, i, true);
}
for (int i = 0; i < proto.getOneofDeclCount(); i++) {
oneofs[i].fields = new FieldDescriptor[oneofs[i].getFieldCount()];
oneofs[i].fieldCount = 0;
}
for (int i = 0; i < proto.getFieldCount(); i++) {
OneofDescriptor oneofDescriptor = fields[i].getContainingOneof();
if (oneofDescriptor != null) {
oneofDescriptor.fields[oneofDescriptor.fieldCount++] = fields[i];
}
}
file.pool.addSymbol(this);
}
示例3: Descriptor
import com.google.protobuf.DescriptorProtos.DescriptorProto; //导入方法依赖的package包/类
private Descriptor (final DescriptorProto proto,
final FileDescriptor file,
final Descriptor parent,
final int index)
throws DescriptorValidationException {
this.index = index;
this.proto = proto;
fullName = computeFullName (file, parent, proto.getName ());
this.file = file;
containingType = parent;
oneofs = new OneofDescriptor[proto.getOneofDeclCount ()];
for (int i = 0; i < proto.getOneofDeclCount (); i++) {
oneofs[i] = new OneofDescriptor (
proto.getOneofDecl (i), file, this, i);
}
nestedTypes = new Descriptor[proto.getNestedTypeCount ()];
for (int i = 0; i < proto.getNestedTypeCount (); i++) {
nestedTypes[i] = new Descriptor (
proto.getNestedType (i), file, this, i);
}
enumTypes = new EnumDescriptor[proto.getEnumTypeCount ()];
for (int i = 0; i < proto.getEnumTypeCount (); i++) {
enumTypes[i] = new EnumDescriptor (
proto.getEnumType (i), file, this, i);
}
fields = new FieldDescriptor[proto.getFieldCount ()];
for (int i = 0; i < proto.getFieldCount (); i++) {
fields[i] = new FieldDescriptor (
proto.getField (i), file, this, i, false);
}
extensions = new FieldDescriptor[proto.getExtensionCount ()];
for (int i = 0; i < proto.getExtensionCount (); i++) {
extensions[i] = new FieldDescriptor (
proto.getExtension (i), file, this, i, true);
}
for (int i = 0; i < proto.getOneofDeclCount (); i++) {
oneofs[i].fields = new FieldDescriptor[oneofs[i].getFieldCount ()];
oneofs[i].fieldCount = 0;
}
for (int i = 0; i < proto.getFieldCount (); i++) {
OneofDescriptor oneofDescriptor = fields[i].getContainingOneof ();
if (oneofDescriptor != null) {
oneofDescriptor.fields[oneofDescriptor.fieldCount++] = fields[i];
}
}
file.pool.addSymbol (this);
}