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


Java FieldDescriptorProto.getOneofIndex方法代码示例

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


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

示例1: FieldDescriptor

import com.google.protobuf.DescriptorProtos.FieldDescriptorProto; //导入方法依赖的package包/类
private FieldDescriptor(final FieldDescriptorProto proto,
                        final FileDescriptor file,
                        final Descriptor parent,
                        final int index,
                        final boolean isExtension)
                 throws DescriptorValidationException {
  this.index = index;
  this.proto = proto;
  fullName = computeFullName(file, parent, proto.getName());
  this.file = file;
  if (proto.hasJsonName()) {
    jsonName = proto.getJsonName();
  } else {
    jsonName = fieldNameToLowerCamelCase(proto.getName());
  }

  if (proto.hasType()) {
    type = Type.valueOf(proto.getType());
  }

  if (getNumber() <= 0) {
    throw new DescriptorValidationException(this,
      "Field numbers must be positive integers.");
  }

  if (isExtension) {
    if (!proto.hasExtendee()) {
      throw new DescriptorValidationException(this,
        "FieldDescriptorProto.extendee not set for extension field.");
    }
    containingType = null;  // Will be filled in when cross-linking
    if (parent != null) {
      extensionScope = parent;
    } else {
      extensionScope = null;
    }

    if (proto.hasOneofIndex()) {
      throw new DescriptorValidationException(this,
        "FieldDescriptorProto.oneof_index set for extension field.");
    }
    containingOneof = null;
  } else {
    if (proto.hasExtendee()) {
      throw new DescriptorValidationException(this,
        "FieldDescriptorProto.extendee set for non-extension field.");
    }
    containingType = parent;

    if (proto.hasOneofIndex()) {
      if (proto.getOneofIndex() < 0 ||
          proto.getOneofIndex() >= parent.toProto().getOneofDeclCount()) {
        throw new DescriptorValidationException(this,
          "FieldDescriptorProto.oneof_index is out of range for type "
          + parent.getName());
      }
      containingOneof = parent.getOneofs().get(proto.getOneofIndex());
      containingOneof.fieldCount++;
    } else {
      containingOneof = null;
    }
    extensionScope = null;
  }

  file.pool.addSymbol(this);
}
 
开发者ID:yeriomin,项目名称:play-store-api,代码行数:67,代码来源:Descriptors.java

示例2: FieldDescriptor

import com.google.protobuf.DescriptorProtos.FieldDescriptorProto; //导入方法依赖的package包/类
private FieldDescriptor (final FieldDescriptorProto proto,
        final FileDescriptor file,
        final Descriptor parent,
        final int index,
        final boolean isExtension)
        throws DescriptorValidationException {
    this.index = index;
    this.proto = proto;
    fullName = computeFullName (file, parent, proto.getName ());
    this.file = file;

    if (proto.hasType ()) {
        type = Type.valueOf (proto.getType ());
    }

    if (getNumber () <= 0) {
        throw new DescriptorValidationException (this,
                "Field numbers must be positive integers.");
    }

    // Only repeated primitive fields may be packed.
    if (proto.getOptions ().getPacked () && !isPackable ()) {
        throw new DescriptorValidationException (this,
                "[packed = true] can only be specified for repeated primitive "
                + "fields.");
    }

    if (isExtension) {
        if (!proto.hasExtendee ()) {
            throw new DescriptorValidationException (this,
                    "FieldDescriptorProto.extendee not set for extension field.");
        }
        containingType = null;  // Will be filled in when cross-linking
        if (parent != null) {
            extensionScope = parent;
        } else {
            extensionScope = null;
        }

        if (proto.hasOneofIndex ()) {
            throw new DescriptorValidationException (this,
                    "FieldDescriptorProto.oneof_index set for extension field.");
        }
        containingOneof = null;
    } else {
        if (proto.hasExtendee ()) {
            throw new DescriptorValidationException (this,
                    "FieldDescriptorProto.extendee set for non-extension field.");
        }
        containingType = parent;

        if (proto.hasOneofIndex ()) {
            if (proto.getOneofIndex () < 0
                    || proto.getOneofIndex () >= parent.toProto ().getOneofDeclCount ()) {
                throw new DescriptorValidationException (this,
                        "FieldDescriptorProto.oneof_index is out of range for type "
                        + parent.getName ());
            }
            containingOneof = parent.getOneofs ().get (proto.getOneofIndex ());
            containingOneof.fieldCount++;
        } else {
            containingOneof = null;
        }
        extensionScope = null;
    }

    file.pool.addSymbol (this);
}
 
开发者ID:BFergerson,项目名称:Beam,代码行数:69,代码来源:Descriptors.java


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