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


Java FileDescriptor.getMessageTypes方法代码示例

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


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

示例1: registerGpbMsgDesc

import com.google.protobuf.Descriptors.FileDescriptor; //导入方法依赖的package包/类
public void registerGpbMsgDesc(FileDescriptor fileDescriptor) {
    if (fileDescriptor == null) return;
    //  service
    for (ServiceDescriptor service : fileDescriptor.getServices()) {
        for (MethodDescriptor method : service.getMethods()) {
            if (gpbMsgDescMap.containsKey(method.getName())) {
                LOG.error("[Gpb] the method [" + method.getName() + "] already registered.");
            }
            registerGpbMessage(method.getInputType());
            methodInputTypeMap.put(method.getName(), method.getInputType().getName());
        }
    }
    //  message
    for (Descriptor descriptor : fileDescriptor.getMessageTypes()) {
        registerGpbMessage(descriptor);
    }
}
 
开发者ID:ogcs,项目名称:Okra-Ax,代码行数:18,代码来源:GpbMessageContext.java

示例2: forGroup

import com.google.protobuf.Descriptors.FileDescriptor; //导入方法依赖的package包/类
public static ProtobufRowDataConverter forGroup(Group group, 
                                                FileDescriptor fileDescriptor) {
    // Find the group message.
    Descriptor groupMessage = null;
    List<Descriptor> messages = fileDescriptor.getMessageTypes();
    for (int i = messages.size() - 1; i >= 0; i--) {
        Descriptor message = messages.get(i);
        if (message.getOptions().getExtension(TableOptions.fdbsql).getIsGroup()) {
            groupMessage = message;
            break;
        }
    }
    if (groupMessage != null) {
        return new GroupConverter(group, groupMessage);
    }
    else {
        assert (messages.size() == 1 && group.getRoot().getChildJoins().isEmpty());
        return new TableConverter(group.getRoot(), messages.get(0));
    }
}
 
开发者ID:jaytaylor,项目名称:sql-layer,代码行数:21,代码来源:ProtobufRowDataConverter.java

示例3: forGroup

import com.google.protobuf.Descriptors.FileDescriptor; //导入方法依赖的package包/类
public static ProtobufRowConverter forGroup(Group group, 
                                            FileDescriptor fileDescriptor) {
    // Find the group message.
    Descriptor groupMessage = null;
    List<Descriptor> messages = fileDescriptor.getMessageTypes();
    for (int i = messages.size() - 1; i >= 0; i--) {
        Descriptor message = messages.get(i);
        if (message.getOptions().getExtension(TableOptions.fdbsql).getIsGroup()) {
            groupMessage = message;
            break;
        }
    }
    if (groupMessage != null) {
        return new GroupConverter(group, groupMessage);
    }
    else {
        assert (messages.size() == 1 && group.getRoot().getChildJoins().isEmpty());
        return new TableConverter(group.getRoot(), messages.get(0));
    }
}
 
开发者ID:jaytaylor,项目名称:sql-layer,代码行数:21,代码来源:ProtobufRowConverter.java

示例4: addFile

import com.google.protobuf.Descriptors.FileDescriptor; //导入方法依赖的package包/类
private void addFile(FileDescriptor file) {
  // Skip the file if it's already added.
  if (!files.add(file.getFullName())) {
    return;
  }
  for (FileDescriptor dependency : file.getDependencies()) {
    addFile(dependency);
  }
  for (Descriptor message : file.getMessageTypes()) {
    addMessage(message);
  }
}
 
开发者ID:SeldonIO,项目名称:seldon-core,代码行数:13,代码来源:JsonFormat.java

示例5: DynamicSchema

import com.google.protobuf.Descriptors.FileDescriptor; //导入方法依赖的package包/类
private DynamicSchema(FileDescriptorSet fileDescSet) throws DescriptorValidationException {
	mFileDescSet = fileDescSet;
	Map<String,FileDescriptor> fileDescMap = init(fileDescSet);
	
	Set<String> msgDupes = new HashSet<String>();
	Set<String> enumDupes = new HashSet<String>();
	for (FileDescriptor fileDesc : fileDescMap.values()) {
		for (Descriptor msgType : fileDesc.getMessageTypes()) addMessageType(msgType, null, msgDupes, enumDupes);			
		for (EnumDescriptor enumType : fileDesc.getEnumTypes()) addEnumType(enumType, null, enumDupes);						
	}
	
	for (String msgName : msgDupes) mMsgDescriptorMapShort.remove(msgName);
	for (String enumName : enumDupes) mEnumDescriptorMapShort.remove(enumName);
}
 
开发者ID:os72,项目名称:protobuf-dynamic,代码行数:15,代码来源:DynamicSchema.java

示例6: addToRegistry

import com.google.protobuf.Descriptors.FileDescriptor; //导入方法依赖的package包/类
/**
 * Adds all extensions, without dependencies, for the given FileDescriptor to the registry.
 */
public static ExtensionRegistry addToRegistry(final FileDescriptor file,
    final ExtensionRegistry registry) {
  for (final FieldDescriptor extension : file.getExtensions()) {
    addToRegistry(extension, registry);
  }

  for (final Descriptor descriptor : file.getMessageTypes()) {
    addToRegistry(descriptor, registry);
  }

  return registry;
}
 
开发者ID:protobufel,项目名称:protobuf-el,代码行数:16,代码来源:ExtensionRegistries.java

示例7: updateDecsriptorCache

import com.google.protobuf.Descriptors.FileDescriptor; //导入方法依赖的package包/类
private void updateDecsriptorCache() {
  for (FileDescriptor file : fileCache.values()) {
    for (Descriptor descriptor : file.getMessageTypes()) {
      updateDecsriptorCache(descriptor);
    }
  }
}
 
开发者ID:protobufel,项目名称:protobuf-el,代码行数:8,代码来源:DescriptorFactory.java

示例8: processFileDescriptor

import com.google.protobuf.Descriptors.FileDescriptor; //导入方法依赖的package包/类
private void processFileDescriptor(FileDescriptor fd) {
  String fdName = fd.getName();
  checkState(!fileDescriptorsByName.containsKey(fdName), "File name already used: %s", fdName);
  fileDescriptorsByName.put(fdName, fd);
  for (ServiceDescriptor service : fd.getServices()) {
    processService(service, fd);
  }
  for (Descriptor type : fd.getMessageTypes()) {
    processType(type, fd);
  }
  for (FieldDescriptor extension : fd.getExtensions()) {
    processExtension(extension, fd);
  }
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:15,代码来源:ProtoReflectionService.java

示例9: testDescriptorComplexCrosslink

import com.google.protobuf.Descriptors.FileDescriptor; //导入方法依赖的package包/类
/**
 * Tests the translate/crosslink for an example where a message field's name
 * and type name are the same.
 */
public void testDescriptorComplexCrosslink() throws Exception {
  FileDescriptorProto fileDescriptorProto = FileDescriptorProto.newBuilder()
    .setName("foo.proto")
    .addMessageType(DescriptorProto.newBuilder()
      .setName("Foo")
      .addField(FieldDescriptorProto.newBuilder()
        .setLabel(FieldDescriptorProto.Label.LABEL_OPTIONAL)
        .setType(FieldDescriptorProto.Type.TYPE_INT32)
        .setName("foo")
        .setNumber(1)
        .build())
      .build())
    .addMessageType(DescriptorProto.newBuilder()
      .setName("Bar")
      .addField(FieldDescriptorProto.newBuilder()
        .setLabel(FieldDescriptorProto.Label.LABEL_OPTIONAL)
        .setTypeName("Foo")
        .setName("Foo")
        .setNumber(1)
        .build())
      .build())
    .build();
  // translate and crosslink
  FileDescriptor file =
    Descriptors.FileDescriptor.buildFrom(fileDescriptorProto, 
        new FileDescriptor[0]);
  // verify resulting descriptors
  assertNotNull(file);
  List<Descriptor> msglist = file.getMessageTypes();
  assertNotNull(msglist);
  assertTrue(msglist.size() == 2);
  boolean barFound = false;
  for (Descriptor desc : msglist) {
    if (desc.getName().equals("Bar")) {
      barFound = true;
      assertNotNull(desc.getFields());
      List<FieldDescriptor> fieldlist = desc.getFields();
      assertNotNull(fieldlist);
      assertTrue(fieldlist.size() == 1);
      assertTrue(fieldlist.get(0).getType() == FieldDescriptor.Type.MESSAGE);
      assertTrue(fieldlist.get(0).getMessageType().getName().equals("Foo"));
    }
  }
  assertTrue(barFound);
}
 
开发者ID:Microsoft,项目名称:vsminecraft,代码行数:50,代码来源:DescriptorsTest.java

示例10: testComplexNamespacePublicDependency

import com.google.protobuf.Descriptors.FileDescriptor; //导入方法依赖的package包/类
/**
 * Tests the translate/crosslink for an example with a more complex namespace
 * referencing.
 */
public void testComplexNamespacePublicDependency() throws Exception {
  FileDescriptorProto fooProto = FileDescriptorProto.newBuilder()
      .setName("bar.proto")
      .setPackage("a.b.c.d.bar.shared")
      .addEnumType(EnumDescriptorProto.newBuilder()
          .setName("MyEnum")
          .addValue(EnumValueDescriptorProto.newBuilder()
              .setName("BLAH")
              .setNumber(1)))
      .build();
  FileDescriptorProto barProto = FileDescriptorProto.newBuilder()
      .setName("foo.proto")
      .addDependency("bar.proto")
      .setPackage("a.b.c.d.foo.shared")
      .addMessageType(DescriptorProto.newBuilder()
          .setName("MyMessage")
          .addField(FieldDescriptorProto.newBuilder()
              .setLabel(FieldDescriptorProto.Label.LABEL_REPEATED)
              .setTypeName("bar.shared.MyEnum")
              .setName("MyField")
              .setNumber(1)))
      .build();
  // translate and crosslink
  FileDescriptor fooFile = Descriptors.FileDescriptor.buildFrom(
      fooProto, new FileDescriptor[0]);
  FileDescriptor barFile = Descriptors.FileDescriptor.buildFrom(
      barProto, new FileDescriptor[]{fooFile});
  // verify resulting descriptors
  assertNotNull(barFile);
  List<Descriptor> msglist = barFile.getMessageTypes();
  assertNotNull(msglist);
  assertTrue(msglist.size() == 1);
  Descriptor desc = msglist.get(0);
  if (desc.getName().equals("MyMessage")) {
    assertNotNull(desc.getFields());
    List<FieldDescriptor> fieldlist = desc.getFields();
    assertNotNull(fieldlist);
    assertTrue(fieldlist.size() == 1);
    FieldDescriptor field = fieldlist.get(0);
    assertTrue(field.getType() == FieldDescriptor.Type.ENUM);
    assertTrue(field.getEnumType().getName().equals("MyEnum"));
    assertTrue(field.getEnumType().getFile().getName().equals("bar.proto"));
    assertTrue(field.getEnumType().getFile().getPackage().equals(
        "a.b.c.d.bar.shared"));
  }   
}
 
开发者ID:Microsoft,项目名称:vsminecraft,代码行数:51,代码来源:DescriptorsTest.java

示例11: getAllDefaultFields

import com.google.protobuf.Descriptors.FileDescriptor; //导入方法依赖的package包/类
private List<FieldDescriptor> getAllDefaultFields(final FileDescriptor file) {
  // return file.getMessageTypes().get(TestExtremeDefaultValuesIndex).getFields();
  final List<Descriptor> messageTypes = file.getMessageTypes();
  final Descriptor descriptor = messageTypes.get(TestExtremeDefaultValuesIndex);
  return descriptor.getFields();
}
 
开发者ID:protobufel,项目名称:protobuf-el,代码行数:7,代码来源:DefaultValuesTest.java

示例12: testDescriptorComplexCrosslink

import com.google.protobuf.Descriptors.FileDescriptor; //导入方法依赖的package包/类
/**
 * Tests the translate/crosslink for an example where a message field's name
 * and type name are the same.
 */
public void testDescriptorComplexCrosslink() throws Exception {
  FileDescriptorProto fileDescriptorProto = FileDescriptorProto.newBuilder()
    .setName("foo.proto")
    .addMessageType(DescriptorProto.newBuilder()
      .setName("Foo")
      .addField(FieldDescriptorProto.newBuilder()
        .setLabel(FieldDescriptorProto.Label.LABEL_OPTIONAL)
        .setType(FieldDescriptorProto.Type.TYPE_INT32)
        .setName("foo")
        .setNumber(1)
        .build())
      .build())
    .addMessageType(DescriptorProto.newBuilder()
      .setName("Bar")
      .addField(FieldDescriptorProto.newBuilder()
        .setLabel(FieldDescriptorProto.Label.LABEL_OPTIONAL)
        .setTypeName("Foo")
        .setName("Foo")
        .setNumber(1)
        .build())
      .build())
    .build();
  // translate and crosslink
  FileDescriptor file =
    Descriptors.FileDescriptor.buildFrom(fileDescriptorProto,
        new FileDescriptor[0]);
  // verify resulting descriptors
  assertNotNull(file);
  List<Descriptor> msglist = file.getMessageTypes();
  assertNotNull(msglist);
  assertTrue(msglist.size() == 2);
  boolean barFound = false;
  for (Descriptor desc : msglist) {
    if (desc.getName().equals("Bar")) {
      barFound = true;
      assertNotNull(desc.getFields());
      List<FieldDescriptor> fieldlist = desc.getFields();
      assertNotNull(fieldlist);
      assertTrue(fieldlist.size() == 1);
      assertTrue(fieldlist.get(0).getType() == FieldDescriptor.Type.MESSAGE);
      assertTrue(fieldlist.get(0).getMessageType().getName().equals("Foo"));
    }
  }
  assertTrue(barFound);
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:50,代码来源:DescriptorsTest.java

示例13: testComplexNamespacePublicDependency

import com.google.protobuf.Descriptors.FileDescriptor; //导入方法依赖的package包/类
/**
 * Tests the translate/crosslink for an example with a more complex namespace
 * referencing.
 */
public void testComplexNamespacePublicDependency() throws Exception {
  FileDescriptorProto fooProto = FileDescriptorProto.newBuilder()
      .setName("bar.proto")
      .setPackage("a.b.c.d.bar.shared")
      .addEnumType(EnumDescriptorProto.newBuilder()
          .setName("MyEnum")
          .addValue(EnumValueDescriptorProto.newBuilder()
              .setName("BLAH")
              .setNumber(1)))
      .build();
  FileDescriptorProto barProto = FileDescriptorProto.newBuilder()
      .setName("foo.proto")
      .addDependency("bar.proto")
      .setPackage("a.b.c.d.foo.shared")
      .addMessageType(DescriptorProto.newBuilder()
          .setName("MyMessage")
          .addField(FieldDescriptorProto.newBuilder()
              .setLabel(FieldDescriptorProto.Label.LABEL_REPEATED)
              .setTypeName("bar.shared.MyEnum")
              .setName("MyField")
              .setNumber(1)))
      .build();
  // translate and crosslink
  FileDescriptor fooFile = Descriptors.FileDescriptor.buildFrom(
      fooProto, new FileDescriptor[0]);
  FileDescriptor barFile = Descriptors.FileDescriptor.buildFrom(
      barProto, new FileDescriptor[]{fooFile});
  // verify resulting descriptors
  assertNotNull(barFile);
  List<Descriptor> msglist = barFile.getMessageTypes();
  assertNotNull(msglist);
  assertTrue(msglist.size() == 1);
  Descriptor desc = msglist.get(0);
  if (desc.getName().equals("MyMessage")) {
    assertNotNull(desc.getFields());
    List<FieldDescriptor> fieldlist = desc.getFields();
    assertNotNull(fieldlist);
    assertTrue(fieldlist.size() == 1);
    FieldDescriptor field = fieldlist.get(0);
    assertTrue(field.getType() == FieldDescriptor.Type.ENUM);
    assertTrue(field.getEnumType().getName().equals("MyEnum"));
    assertTrue(field.getEnumType().getFile().getName().equals("bar.proto"));
    assertTrue(field.getEnumType().getFile().getPackage().equals(
        "a.b.c.d.bar.shared"));
  }
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:51,代码来源:DescriptorsTest.java


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