Package com.google.protobuf
Class Descriptors.Descriptor
- java.lang.Object
-
- com.google.protobuf.Descriptors.GenericDescriptor
-
- com.google.protobuf.Descriptors.Descriptor
-
- Enclosing class:
- Descriptors
public static final class Descriptors.Descriptor extends Descriptors.GenericDescriptor
Describes a message type.
-
-
Field Summary
Fields Modifier and Type Field Description private Descriptors.EnumDescriptor[]enumTypesprivate int[]extensionRangeLowerBoundsprivate int[]extensionRangeUpperBoundsprivate Descriptors.FieldDescriptor[]extensionsprivate Descriptors.FieldDescriptor[]fieldsprivate Descriptors.FieldDescriptor[]fieldsSortedByNumberprivate java.lang.StringfullNameprivate intindexprivate Descriptors.Descriptor[]nestedTypesprivate Descriptors.OneofDescriptor[]oneofsprivate DescriptorProtos.MessageOptionsoptionsprivate Descriptors.GenericDescriptorparentprivate booleanplaceholderprivate DescriptorProtos.DescriptorProtoprotoprivate intrealOneofCount-
Fields inherited from class com.google.protobuf.Descriptors.GenericDescriptor
features
-
-
Constructor Summary
Constructors Modifier Constructor Description privateDescriptor(DescriptorProtos.DescriptorProto proto, Descriptors.FileDescriptor file, Descriptors.Descriptor parent, int index)(package private)Descriptor(java.lang.String fullname)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcrossLink()Look up and cross-link all field types, etc.Descriptors.EnumDescriptorfindEnumTypeByName(java.lang.String name)Finds a nested enum type by name.Descriptors.FieldDescriptorfindFieldByName(java.lang.String name)Finds a field by name.Descriptors.FieldDescriptorfindFieldByNumber(int number)Finds a field by field number.Descriptors.DescriptorfindNestedTypeByName(java.lang.String name)Finds a nested message type by name.Descriptors.DescriptorgetContainingType()If this is a nested type, get the outer descriptor, otherwise null.Descriptors.EnumDescriptorgetEnumType(int index)Get the message type's nested enum type at the specified index.intgetEnumTypeCount()Get a count of enum types nested within this one.java.util.List<Descriptors.EnumDescriptor>getEnumTypes()Get a list of enum types nested within this one.Descriptors.FieldDescriptorgetExtension(int index)Get the extension defined nested within this message type's scope at the specified index.intgetExtensionCount()Get a count of the extensions defined nested within this message type's scope.java.util.List<Descriptors.FieldDescriptor>getExtensions()Get a list of the extensions defined nested within this message type's scope.Descriptors.FieldDescriptorgetField(int index)Get the message type's field at the specified index.intgetFieldCount()Get a count of this message type's fields.java.util.List<Descriptors.FieldDescriptor>getFields()Get a list of this message type's fields.Descriptors.FileDescriptorgetFile()Get theDescriptors.FileDescriptorcontaining this descriptor.java.lang.StringgetFullName()Get the type's fully-qualified name, within the proto language's namespace.intgetIndex()Get the index of this descriptor within its parent.java.lang.StringgetName()Get the type's unqualified name.Descriptors.DescriptorgetNestedType(int index)Get the message type's nested message type at the specified index.intgetNestedTypeCount()Get a count of message types nested within this one.java.util.List<Descriptors.Descriptor>getNestedTypes()Get a list of message types nested within this one.Descriptors.OneofDescriptorgetOneof(int index)Get the message type's oneof at the specified index.intgetOneofCount()Get a count of this message type's oneofs.java.util.List<Descriptors.OneofDescriptor>getOneofs()Get a list of this message type's oneofs.DescriptorProtos.MessageOptionsgetOptions()Get theMessageOptions, defined indescriptor.proto.(package private) Descriptors.GenericDescriptorgetParent()Descriptors.OneofDescriptorgetRealOneof(int index)Get the message type's real oneof at the specified index.intgetRealOneofCount()Get a count of this message type's real oneofs.java.util.List<Descriptors.OneofDescriptor>getRealOneofs()Get a list of this message type's real oneofs.booleanisExtendable()Indicates whether the message can be extended.booleanisExtensionNumber(int number)Determines if the given field number is an extension.booleanisPlaceholder()booleanisReservedName(java.lang.String name)Determines if the given field name is reserved.booleanisReservedNumber(int number)Determines if the given field number is reserved.private voidresolveAllFeatures()SeeFileDescriptor#resolveAllFeatures.private voidsetProto(DescriptorProtos.DescriptorProto proto)DescriptorProtos.DescriptorPrototoProto()Convert the descriptor to its protocol message representation.private voidvalidateNoDuplicateFieldNumbers()-
Methods inherited from class com.google.protobuf.Descriptors.GenericDescriptor
getFeatures, inferLegacyProtoFeatures, resolveFeatures, validateFeatures
-
-
-
-
Field Detail
-
index
private final int index
-
proto
private DescriptorProtos.DescriptorProto proto
-
options
private volatile DescriptorProtos.MessageOptions options
-
fullName
private final java.lang.String fullName
-
parent
private final Descriptors.GenericDescriptor parent
-
nestedTypes
private final Descriptors.Descriptor[] nestedTypes
-
enumTypes
private final Descriptors.EnumDescriptor[] enumTypes
-
fields
private final Descriptors.FieldDescriptor[] fields
-
fieldsSortedByNumber
private final Descriptors.FieldDescriptor[] fieldsSortedByNumber
-
extensions
private final Descriptors.FieldDescriptor[] extensions
-
oneofs
private final Descriptors.OneofDescriptor[] oneofs
-
realOneofCount
private final int realOneofCount
-
extensionRangeLowerBounds
private final int[] extensionRangeLowerBounds
-
extensionRangeUpperBounds
private final int[] extensionRangeUpperBounds
-
placeholder
private final boolean placeholder
-
-
Constructor Detail
-
Descriptor
Descriptor(java.lang.String fullname) throws Descriptors.DescriptorValidationException
-
Descriptor
private Descriptor(DescriptorProtos.DescriptorProto proto, Descriptors.FileDescriptor file, Descriptors.Descriptor parent, int index) throws Descriptors.DescriptorValidationException
-
-
Method Detail
-
getIndex
public int getIndex()
Get the index of this descriptor within its parent. In other words, given aDescriptors.FileDescriptorfile, the following is true:for all i in [0, file.getMessageTypeCount()): file.getMessageType(i).getIndex() == iSimilarly, for aDescriptors.DescriptormessageType:for all i in [0, messageType.getNestedTypeCount()): messageType.getNestedType(i).getIndex() == i
-
toProto
public DescriptorProtos.DescriptorProto toProto()
Convert the descriptor to its protocol message representation.
-
getName
public java.lang.String getName()
Get the type's unqualified name.- Specified by:
getNamein classDescriptors.GenericDescriptor
-
getFullName
public java.lang.String getFullName()
Get the type's fully-qualified name, within the proto language's namespace. This differs from the Java name. For example, given this.proto:package foo.bar; option java_package = "com.example.protos" message Baz {}Baz's full name is "foo.bar.Baz".- Specified by:
getFullNamein classDescriptors.GenericDescriptor
-
getFile
public Descriptors.FileDescriptor getFile()
Get theDescriptors.FileDescriptorcontaining this descriptor.- Specified by:
getFilein classDescriptors.GenericDescriptor
-
getParent
Descriptors.GenericDescriptor getParent()
- Specified by:
getParentin classDescriptors.GenericDescriptor
-
isPlaceholder
public boolean isPlaceholder()
-
getContainingType
public Descriptors.Descriptor getContainingType()
If this is a nested type, get the outer descriptor, otherwise null.
-
getOptions
public DescriptorProtos.MessageOptions getOptions()
Get theMessageOptions, defined indescriptor.proto.
-
getFields
public java.util.List<Descriptors.FieldDescriptor> getFields()
Get a list of this message type's fields.
-
getFieldCount
public int getFieldCount()
Get a count of this message type's fields.
-
getField
public Descriptors.FieldDescriptor getField(int index)
Get the message type's field at the specified index.
-
getOneofs
public java.util.List<Descriptors.OneofDescriptor> getOneofs()
Get a list of this message type's oneofs.
-
getOneofCount
public int getOneofCount()
Get a count of this message type's oneofs.
-
getOneof
public Descriptors.OneofDescriptor getOneof(int index)
Get the message type's oneof at the specified index.
-
getRealOneofs
public java.util.List<Descriptors.OneofDescriptor> getRealOneofs()
Get a list of this message type's real oneofs.
-
getRealOneofCount
public int getRealOneofCount()
Get a count of this message type's real oneofs.
-
getRealOneof
public Descriptors.OneofDescriptor getRealOneof(int index)
Get the message type's real oneof at the specified index.
-
getExtensions
public java.util.List<Descriptors.FieldDescriptor> getExtensions()
Get a list of the extensions defined nested within this message type's scope.
-
getExtensionCount
public int getExtensionCount()
Get a count of the extensions defined nested within this message type's scope.
-
getExtension
public Descriptors.FieldDescriptor getExtension(int index)
Get the extension defined nested within this message type's scope at the specified index.
-
getNestedTypes
public java.util.List<Descriptors.Descriptor> getNestedTypes()
Get a list of message types nested within this one.
-
getNestedTypeCount
public int getNestedTypeCount()
Get a count of message types nested within this one.
-
getNestedType
public Descriptors.Descriptor getNestedType(int index)
Get the message type's nested message type at the specified index.
-
getEnumTypes
public java.util.List<Descriptors.EnumDescriptor> getEnumTypes()
Get a list of enum types nested within this one.
-
getEnumTypeCount
public int getEnumTypeCount()
Get a count of enum types nested within this one.
-
getEnumType
public Descriptors.EnumDescriptor getEnumType(int index)
Get the message type's nested enum type at the specified index.
-
isExtensionNumber
public boolean isExtensionNumber(int number)
Determines if the given field number is an extension.
-
isReservedNumber
public boolean isReservedNumber(int number)
Determines if the given field number is reserved.
-
isReservedName
public boolean isReservedName(java.lang.String name)
Determines if the given field name is reserved.
-
isExtendable
public boolean isExtendable()
Indicates whether the message can be extended. That is, whether it has any "extensions x to y" ranges declared on it.
-
findFieldByName
public Descriptors.FieldDescriptor findFieldByName(java.lang.String name)
Finds a field by name.- Parameters:
name- The unqualified name of the field (e.g. "foo"). For protocol buffer messages that follow Google's guidance on naming this will be a snake case string, such assong_name
.- Returns:
- The field's descriptor, or
nullif not found.
-
findFieldByNumber
public Descriptors.FieldDescriptor findFieldByNumber(int number)
Finds a field by field number.- Parameters:
number- The field number within this message type.- Returns:
- The field's descriptor, or
nullif not found.
-
findNestedTypeByName
public Descriptors.Descriptor findNestedTypeByName(java.lang.String name)
Finds a nested message type by name.- Parameters:
name- The unqualified name of the nested type such as "Foo"- Returns:
- The types's descriptor, or
nullif not found.
-
findEnumTypeByName
public Descriptors.EnumDescriptor findEnumTypeByName(java.lang.String name)
Finds a nested enum type by name.- Parameters:
name- The unqualified name of the nested type such as "Foo"- Returns:
- The types's descriptor, or
nullif not found.
-
resolveAllFeatures
private void resolveAllFeatures() throws Descriptors.DescriptorValidationExceptionSeeFileDescriptor#resolveAllFeatures.
-
crossLink
private void crossLink() throws Descriptors.DescriptorValidationExceptionLook up and cross-link all field types, etc.
-
validateNoDuplicateFieldNumbers
private void validateNoDuplicateFieldNumbers() throws Descriptors.DescriptorValidationException
-
setProto
private void setProto(DescriptorProtos.DescriptorProto proto) throws Descriptors.DescriptorValidationException
-
-