本文整理汇总了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);
}
}
示例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));
}
}
示例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));
}
}
示例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);
}
}
示例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);
}
示例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;
}
示例7: updateDecsriptorCache
import com.google.protobuf.Descriptors.FileDescriptor; //导入方法依赖的package包/类
private void updateDecsriptorCache() {
for (FileDescriptor file : fileCache.values()) {
for (Descriptor descriptor : file.getMessageTypes()) {
updateDecsriptorCache(descriptor);
}
}
}
示例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);
}
}
示例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);
}
示例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"));
}
}
示例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();
}
示例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);
}
示例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"));
}
}