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


Java FileOptions类代码示例

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


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

示例1: packageClassName

import com.google.protobuf.DescriptorProtos.FileOptions; //导入依赖的package包/类
private Pair<String, String> packageClassName(FileOptions options) {
  String packageName = null;
  String className = null;
  for (Map.Entry<FieldDescriptor, Object> entry : options.getAllFields().entrySet()) {
    if (entry.getKey().getName().equals("java_package")) {
      packageName = entry.getValue().toString();
    }
    if (entry.getKey().getName().equals("java_outer_classname")) {
      className = entry.getValue().toString();
    }
  }
  if (packageName != null && className != null) {
    return new ImmutablePair<String, String>(packageName, className);
  }
  return null;
}
 
开发者ID:venus-boot,项目名称:saluki,代码行数:17,代码来源:CommonProto2Java.java

示例2: of

import com.google.protobuf.DescriptorProtos.FileOptions; //导入依赖的package包/类
public static TypeMap of(FileDescriptorProto protoFile) {
  ImmutableMap.Builder<String, JavaType> types = ImmutableMap.builder();
  FileOptions options = protoFile.getOptions();

  String protoPackage = "." + (protoFile.hasPackage() ?
      protoFile.getPackage() : "");
  String javaPackage = options.hasJavaPackage() ?
      options.getJavaPackage() : protoFile.hasPackage() ?
      protoFile.getPackage() : null;
  String enclosingClass = options.getJavaMultipleFiles() ?
      null : options.hasJavaOuterClassname() ?
      options.getJavaOuterClassname() : createOuterJavaClassname(protoFile.getName());

  for (DescriptorProto message : protoFile.getMessageTypeList()) {
    types.put(protoPackage + "." + message.getName(),
        new JavaType(javaPackage, enclosingClass, message.getName()));
  }

  return new TypeMap(types.build());
}
 
开发者ID:jsilland,项目名称:piezo,代码行数:21,代码来源:TypeMap.java

示例3: extractPackageName

import com.google.protobuf.DescriptorProtos.FileOptions; //导入依赖的package包/类
private String extractPackageName(FileDescriptorProto proto) {
    FileOptions options = proto.getOptions();
    if (options != null) {
        String javaPackage = options.getJavaPackage();
        if (!Strings.isNullOrEmpty(javaPackage)) {
            return javaPackage;
        }
    }

    return Strings.nullToEmpty(proto.getPackage());
}
 
开发者ID:salesforce,项目名称:reactive-grpc,代码行数:12,代码来源:ReactiveGrpcGenerator.java

示例4: getPackage

import com.google.protobuf.DescriptorProtos.FileOptions; //导入依赖的package包/类
static String getPackage(FileDescriptorProto file, ProtoFlavor flavor) {
  FileOptions fileOptions = file.getOptions();
  StringBuilder sb = new StringBuilder();
  if (fileOptions.hasJavaPackage()) {
    sb.append(fileOptions.getJavaPackage());
  } else {
    if (!file.getPackage().isEmpty()) {
      sb.append(file.getPackage());
    }
  }


  return sb.toString();
}
 
开发者ID:google,项目名称:closure-templates,代码行数:15,代码来源:JavaQualifiedNames.java

示例5: multipleJavaFiles

import com.google.protobuf.DescriptorProtos.FileOptions; //导入依赖的package包/类
private static boolean multipleJavaFiles(FileDescriptorProto fd, ProtoFlavor flavor) {
  FileOptions options = fd.getOptions();
  switch (flavor) {
    case PROTO2:
      return options.getJavaMultipleFiles();
    default:
      throw new AssertionError();
  }
}
 
开发者ID:google,项目名称:closure-templates,代码行数:10,代码来源:JavaQualifiedNames.java

示例6: generateProtoFromDescriptor

import com.google.protobuf.DescriptorProtos.FileOptions; //导入依赖的package包/类
public void generateProtoFromDescriptor(FileDescriptor descriptor,
                                        Appendable out, Descriptor wrapperMessage) throws IOException {
    String package1 = descriptor.getPackage();
    if (package1 != null) {
        out.append("package " + package1 + ";\n");
    }

    FileOptions options = descriptor.getOptions();
    String javaPackage = options.getJavaPackage();
    if (javaPackage != null) {
        out.append("option java_package = \"" + javaPackage + "\";\n");
    }

    String javaOuterClassname = options.getJavaOuterClassname();
    if (javaOuterClassname != null) {
        out.append("option java_outer_classname = \"" + javaOuterClassname
                + "\";\n");
    }

    for (ServiceDescriptor serviceDescriptor : descriptor.getServices()) {
        generateProtoFromDescriptor(serviceDescriptor, out);
    }

    for (Descriptor messageDescriptor : descriptor.getMessageTypes()) {
        if (wrapperMessage != null && messageDescriptor.equals(wrapperMessage)) {
            out.append("// This is the message you can send to this service (wrapper message):\n");
        }

        generateProtoFromDescriptor(messageDescriptor, out, "",
                new LinkedHashMap<Descriptor, Boolean>());
    }

    for (EnumDescriptor enumDescriptor : descriptor.getEnumTypes()) {
        generateProtoFromDescriptor(enumDescriptor, out, "");
    }
}
 
开发者ID:ow2-chameleon,项目名称:fuchsia,代码行数:37,代码来源:ProtoGenerator.java

示例7: getOptions

import com.google.protobuf.DescriptorProtos.FileOptions; //导入依赖的package包/类
/** Get the {@code FileOptions}, defined in {@code descriptor.proto}. */
public FileOptions getOptions() { return proto.getOptions(); }
 
开发者ID:yeriomin,项目名称:play-store-api,代码行数:3,代码来源:Descriptors.java

示例8: getOptions

import com.google.protobuf.DescriptorProtos.FileOptions; //导入依赖的package包/类
/**
 * Get the {@code FileOptions}, defined in {@code descriptor.proto}.
 */
public FileOptions getOptions () {
    return proto.getOptions ();
}
 
开发者ID:BFergerson,项目名称:Beam,代码行数:7,代码来源:Descriptors.java

示例9: exitFileOption

import com.google.protobuf.DescriptorProtos.FileOptions; //导入依赖的package包/类
@Override
public void exitFileOption(final FileOptionContext ctx) {
  super.exitFileOption(ctx);

  if (ctx.customFileOption() != null) {
    final CustomOptionContext customOptionCtx = ctx.customFileOption().customOption();

    locationBuilder.addLocation().setAllSpan(ctx)
        .addPath(FileDescriptorProto.OPTIONS_FIELD_NUMBER);

    final int optionIndex =
        (treatStandardOptionAsUninterpreted ? getTotalFieldCount(fileOptionsBuilder)
            : fileOptionsBuilder.getUninterpretedOptionCount()) - 1;

    locationBuilder.addLocationClone().addPath(FileOptions.UNINTERPRETED_OPTION_FIELD_NUMBER)
        .addPath(optionIndex);

    locationBuilder.addLocationClone().clearComments()
        .addPath(UninterpretedOption.NAME_FIELD_NUMBER)
        .setAllSpan(customOptionCtx.customOptionName());

    int i = -1;

    for (final CustomOptionNamePartContext namePart : customOptionCtx.customOptionName()
        .customOptionNamePart()) {
      locationBuilder.addLocation().addPath(FileDescriptorProto.OPTIONS_FIELD_NUMBER)
          .addPath(FileOptions.UNINTERPRETED_OPTION_FIELD_NUMBER).addPath(optionIndex)
          .addPath(UninterpretedOption.NAME_FIELD_NUMBER).addPath(++i).setAllSpan(namePart);

      locationBuilder
          .addLocationClone()
          .addPath(UninterpretedOption.NamePart.NAME_PART_FIELD_NUMBER)
          .setAllSpan(
              namePart.customOptionNamePartId() == null ? namePart.identifier() : namePart
                  .customOptionNamePartId());
    }

    // customOption value locations: can be scalar or aggregate!

    final CustomOptionValueContext customOptionValue = customOptionCtx.customOptionValue();
    int valuePath;

    if (customOptionValue.optionAggregateValue() != null) {
      valuePath = UninterpretedOption.AGGREGATE_VALUE_FIELD_NUMBER;
    } else {
      final OptionScalarValueContext optionScalarValue = customOptionValue.optionScalarValue();

      if (optionScalarValue.doubleValue() != null) {
        valuePath = UninterpretedOption.DOUBLE_VALUE_FIELD_NUMBER;
      } else if (optionScalarValue.identifier() != null) {
        valuePath = UninterpretedOption.IDENTIFIER_VALUE_FIELD_NUMBER;
      } else if (optionScalarValue.StringLiteral() != null
          || optionScalarValue.BooleanLiteral() != null) {
        valuePath = UninterpretedOption.STRING_VALUE_FIELD_NUMBER;
      } else if (optionScalarValue.NegativeIntegerLiteral() != null) {
        valuePath = UninterpretedOption.NEGATIVE_INT_VALUE_FIELD_NUMBER;
      } else if (optionScalarValue.IntegerLiteral() != null) {
        valuePath = UninterpretedOption.POSITIVE_INT_VALUE_FIELD_NUMBER;
      } else { // we shouldn't arrive here!
        throw new RuntimeException("custom option value has unidentified type!");
      }
    }

    locationBuilder.addLocation().addPath(FileDescriptorProto.OPTIONS_FIELD_NUMBER)
        .addPath(FileOptions.UNINTERPRETED_OPTION_FIELD_NUMBER).addPath(optionIndex)
        .addPath(valuePath).setAllSpan(customOptionValue);

    // should the aggregate locations be added here? BTW, protoc fails on aggregates!
  }
}
 
开发者ID:protobufel,项目名称:protobuf-el,代码行数:71,代码来源:SourceInfoProtoFileParser.java

示例10: doStandardOptionSource

import com.google.protobuf.DescriptorProtos.FileOptions; //导入依赖的package包/类
private void doStandardOptionSource(final StandardFileOptionContext ctx,
    final int customOptionValueType) {
  final FileOptionContext parentCtx = (FileOptionContext) ctx.getParent();

  locationBuilder.addLocation().setAllSpan(parentCtx)
      .addPath(FileDescriptorProto.OPTIONS_FIELD_NUMBER);

  if (treatStandardOptionAsUninterpreted) {
    final int optionIndex = getTotalFieldCount(fileOptionsBuilder) - 1;

    locationBuilder.addLocation().comments(parentCtx)
        .addPath(FileDescriptorProto.OPTIONS_FIELD_NUMBER)
        .addPath(FileOptions.UNINTERPRETED_OPTION_FIELD_NUMBER).addPath(optionIndex)
        .setAllSpan(parentCtx);

    locationBuilder.addLocation().addPath(FileDescriptorProto.OPTIONS_FIELD_NUMBER)
        .addPath(FileOptions.UNINTERPRETED_OPTION_FIELD_NUMBER).addPath(optionIndex)
        .addPath(UninterpretedOption.NAME_FIELD_NUMBER)
        .setAllSpan((TerminalNode) ctx.getChild(0));

    locationBuilder.addLocation().addPath(FileDescriptorProto.OPTIONS_FIELD_NUMBER)
        .addPath(FileOptions.UNINTERPRETED_OPTION_FIELD_NUMBER).addPath(optionIndex)
        .addPath(UninterpretedOption.NAME_FIELD_NUMBER).addPath(0)
        .setAllSpan((TerminalNode) ctx.getChild(0));

    locationBuilder.addLocation().addPath(FileDescriptorProto.OPTIONS_FIELD_NUMBER)
        .addPath(FileOptions.UNINTERPRETED_OPTION_FIELD_NUMBER).addPath(optionIndex)
        .addPath(UninterpretedOption.NAME_FIELD_NUMBER).addPath(0)
        .addPath(UninterpretedOption.NamePart.NAME_PART_FIELD_NUMBER)
        .setAllSpan((TerminalNode) ctx.getChild(0));

    locationBuilder.addLocation().addPath(FileDescriptorProto.OPTIONS_FIELD_NUMBER)
        .addPath(FileOptions.UNINTERPRETED_OPTION_FIELD_NUMBER).addPath(optionIndex)
        .addPath(customOptionValueType).setAllSpan(ctx.getChild(2));
  } else {
    locationBuilder
        .addLocation()
        .comments(parentCtx)
        .addPath(FileDescriptorProto.OPTIONS_FIELD_NUMBER)
        .addPath(
            FileOptions.getDescriptor().findFieldByName(ctx.getChild(0).getText()).getNumber())
        .setAllSpan(ctx.getChild(2));
  }
}
 
开发者ID:protobufel,项目名称:protobuf-el,代码行数:45,代码来源:SourceInfoProtoFileParser.java

示例11: getFileOptions

import com.google.protobuf.DescriptorProtos.FileOptions; //导入依赖的package包/类
public FileOptions.Builder getFileOptions() {
  return currentScope.getFileOptions();
}
 
开发者ID:protobufel,项目名称:protobuf-el,代码行数:4,代码来源:Scopes.java

示例12: getOptions

import com.google.protobuf.DescriptorProtos.FileOptions; //导入依赖的package包/类
public FileOptions getOptions() {
  return delegate.getOptions();
}
 
开发者ID:protobufel,项目名称:protobuf-el,代码行数:4,代码来源:FileDescriptorEx.java

示例13: inferJavaPackage

import com.google.protobuf.DescriptorProtos.FileOptions; //导入依赖的package包/类
@VisibleForTesting
static String inferJavaPackage(FileDescriptorProto file) {
  FileOptions options = file.getOptions();
  return options.hasJavaPackage() ?
      options.getJavaPackage() : file.hasPackage() ? file.getPackage() : null;
}
 
开发者ID:jsilland,项目名称:piezo,代码行数:7,代码来源:ProtoFileHandler.java


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