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


Java FileDescriptorSet.newBuilder方法代码示例

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


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

示例1: generate

import com.google.protobuf.DescriptorProtos.FileDescriptorSet; //导入方法依赖的package包/类
private FileDescriptorSet generate() {
  FileDescriptorSet.Builder setBuilder = FileDescriptorSet.newBuilder();
  for (Map.Entry<String, FileContents> entry : contentsByFile.entrySet()) {
    FileContents contents = entry.getValue();
    String fileName = entry.getKey();
    if (!contents.apis.isEmpty() || !contents.types.isEmpty() || !contents.enums.isEmpty()) {
      setBuilder.addFile(generateFile(fileName, contents));
    }
  }
  return setBuilder.build();
}
 
开发者ID:googleapis,项目名称:api-compiler,代码行数:12,代码来源:DescriptorGenerator.java

示例2: build

import com.google.protobuf.DescriptorProtos.FileDescriptorSet; //导入方法依赖的package包/类
/**
 * Builds a dynamic schema
 * 
 * @return the schema object
 * @throws DescriptorValidationException
 */
public DynamicSchema build() throws DescriptorValidationException {
	FileDescriptorSet.Builder fileDescSetBuilder = FileDescriptorSet.newBuilder();
	fileDescSetBuilder.addFile(mFileDescProtoBuilder.build());
	fileDescSetBuilder.mergeFrom(mFileDescSetBuilder.build());
	return new DynamicSchema(fileDescSetBuilder.build());
}
 
开发者ID:os72,项目名称:protobuf-dynamic,代码行数:13,代码来源:DynamicSchema.java

示例3: testFileSetSerialization

import com.google.protobuf.DescriptorProtos.FileDescriptorSet; //导入方法依赖的package包/类
@Test
public void testFileSetSerialization() throws Exception {
  final FileDescriptorSet fileDescriptorSet = FileDescriptorSetBuilder.newBuilder()
      .addDescriptor(TestAllTypes.getDescriptor()).build();
  String fileDescriptorSetText = TextFormat.printToString(fileDescriptorSet);
  
  FileDescriptorSet.Builder fileDescriptorSetBuilder = FileDescriptorSet.newBuilder();
  TextFormat.merge(fileDescriptorSetText, fileDescriptorSetBuilder);
  FileDescriptorSet actualFileSet = fileDescriptorSetBuilder.build();
  
  assertThat(actualFileSet, equalTo(fileDescriptorSet));
}
 
开发者ID:protobufel,项目名称:protobuf-el,代码行数:13,代码来源:DescriptorFactoryTest.java

示例4: AISToProtobuf

import com.google.protobuf.DescriptorProtos.FileDescriptorSet; //导入方法依赖的package包/类
public AISToProtobuf(ProtobufRowFormat.Type formatType, FileDescriptorSet priorSet) {
    this.formatType = formatType;
    this.priorSet = priorSet;
    setBuilder = FileDescriptorSet.newBuilder();
}
 
开发者ID:jaytaylor,项目名称:sql-layer,代码行数:6,代码来源:AISToProtobuf.java

示例5: validateAndGenerate

import com.google.protobuf.DescriptorProtos.FileDescriptorSet; //导入方法依赖的package包/类
static FileDescriptorProto validateAndGenerate(HasStorage object,
                                               ProtobufRowFormat.Type formatType,
                                               FileDescriptorProto fileProto,
                                               AISValidationOutput output) {
    if (!(object instanceof Group)) {
        output.reportFailure(new AISValidationFailure(new StorageDescriptionInvalidException(object, "is not a Group and cannot use Protocol Buffers")));
        return null;
    }
    Group group = (Group)object;
    if (formatType == ProtobufRowFormat.Type.SINGLE_TABLE) {
        if (!group.getRoot().getChildJoins().isEmpty()) {
            output.reportFailure(new AISValidationFailure(new StorageDescriptionInvalidException(object, "has more than one table")));
            return null;
        }
    }
    int currentVersion = sumTableVersions(group.getRoot());
    if (fileProto != null) {
        int storedVersion = fileProto.getOptions()
            .getExtension(CustomOptions.GroupOptions.fdbsql).getVersion();
        if (storedVersion == currentVersion) {
            return fileProto;
        }
    }
    FileDescriptorSet set = null;
    if (fileProto != null) {
        FileDescriptorSet.Builder builder = FileDescriptorSet.newBuilder();
        builder.addFile(fileProto);
        set = builder.build();
    }
    AISToProtobuf ais2p = new AISToProtobuf(formatType, set);
    ais2p.addGroup(group);
    set = ais2p.build();
    fileProto = set.getFile(0); // Only added one group.
    // Make sure it will build before committing to this format.
    try {
        FileDescriptor.buildFrom(fileProto, DEPENDENCIES);
    }
    catch (DescriptorValidationException ex) {
        output.reportFailure(new AISValidationFailure(new ProtobufBuildException(ex)));
    }
    return fileProto;
}
 
开发者ID:jaytaylor,项目名称:sql-layer,代码行数:43,代码来源:ProtobufStorageDescriptionHelper.java

示例6: Builder

import com.google.protobuf.DescriptorProtos.FileDescriptorSet; //导入方法依赖的package包/类
private Builder() {
	mFileDescProtoBuilder = FileDescriptorProto.newBuilder();
	mFileDescSetBuilder = FileDescriptorSet.newBuilder();
}
 
开发者ID:os72,项目名称:protobuf-dynamic,代码行数:5,代码来源:DynamicSchema.java


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