Class Descriptors.Descriptor
java.lang.Object
com.google.protobuf.Descriptors.GenericDescriptor
com.google.protobuf.Descriptors.Descriptor
- Enclosing class:
Descriptors
Describes a message type.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Descriptors.EnumDescriptor[]private final int[]private final int[]private final Descriptors.FieldDescriptor[]private final Descriptors.FieldDescriptor[]private final Descriptors.FieldDescriptor[]private final Stringprivate final intprivate final Descriptors.Descriptor[]private final Descriptors.OneofDescriptor[]private DescriptorProtos.MessageOptionsprivate final Descriptors.GenericDescriptorprivate final booleanprivate DescriptorProtos.DescriptorProtoprivate final intFields inherited from class Descriptors.GenericDescriptor
features -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateDescriptor(DescriptorProtos.DescriptorProto proto, Descriptors.FileDescriptor file, Descriptors.Descriptor parent, int index) (package private)Descriptor(String fullname) -
Method Summary
Modifier and TypeMethodDescriptionprivate voidLook up and cross-link all field types, etc.findEnumTypeByName(String name) Finds a nested enum type by name.findFieldByName(String name) Finds a field by name.findFieldByNumber(int number) Finds a field by field number.findNestedTypeByName(String name) Finds a nested message type by name.If this is a nested type, get the outer descriptor, otherwise null.getEnumType(int index) Get the message type's nested enum type at the specified index.intGet a count of enum types nested within this one.Get a list of enum types nested within this one.getExtension(int index) Get the extension defined nested within this message type's scope at the specified index.intGet a count of the extensions defined nested within this message type's scope.Get a list of the extensions defined nested within this message type's scope.getField(int index) Get the message type's field at the specified index.intGet a count of this message type's fields.Get a list of this message type's fields.getFile()Get theDescriptors.FileDescriptorcontaining this descriptor.Get the type's fully-qualified name, within the proto language's namespace.intgetIndex()Get the index of this descriptor within its parent.getName()Get the type's unqualified name.getNestedType(int index) Get the message type's nested message type at the specified index.intGet a count of message types nested within this one.Get a list of message types nested within this one.getOneof(int index) Get the message type's oneof at the specified index.intGet a count of this message type's oneofs.Get a list of this message type's oneofs.Get theMessageOptions, defined indescriptor.proto.(package private) Descriptors.GenericDescriptorgetRealOneof(int index) Get the message type's real oneof at the specified index.intGet a count of this message type's real oneofs.Get a list of this message type's real oneofs.booleanIndicates whether the message can be extended.booleanisExtensionNumber(int number) Determines if the given field number is an extension.booleanbooleanisReservedName(String name) Determines if the given field name is reserved.booleanisReservedNumber(int number) Determines if the given field number is reserved.private voidSee.invalid reference
FileDescriptor#resolveAllFeaturesprivate voidtoProto()Convert the descriptor to its protocol message representation.private voidMethods inherited from class Descriptors.GenericDescriptor
getFeatures, inferLegacyProtoFeatures, resolveFeatures, validateFeatures
-
Field Details
-
index
private final int index -
proto
-
options
-
fullName
-
parent
-
nestedTypes
-
enumTypes
-
fields
-
fieldsSortedByNumber
-
extensions
-
oneofs
-
realOneofCount
private final int realOneofCount -
extensionRangeLowerBounds
private final int[] extensionRangeLowerBounds -
extensionRangeUpperBounds
private final int[] extensionRangeUpperBounds -
placeholder
private final boolean placeholder
-
-
Constructor Details
-
Descriptor
Descriptor(String fullname) throws Descriptors.DescriptorValidationException -
Descriptor
private Descriptor(DescriptorProtos.DescriptorProto proto, Descriptors.FileDescriptor file, Descriptors.Descriptor parent, int index) throws Descriptors.DescriptorValidationException
-
-
Method Details
-
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
Convert the descriptor to its protocol message representation.- Specified by:
toProtoin classDescriptors.GenericDescriptor
-
getName
Get the type's unqualified name.- Specified by:
getNamein classDescriptors.GenericDescriptor
-
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
Get theDescriptors.FileDescriptorcontaining this descriptor.- Specified by:
getFilein classDescriptors.GenericDescriptor
-
getParent
Descriptors.GenericDescriptor getParent()- Specified by:
getParentin classDescriptors.GenericDescriptor
-
isPlaceholder
public boolean isPlaceholder() -
getContainingType
If this is a nested type, get the outer descriptor, otherwise null. -
getOptions
Get theMessageOptions, defined indescriptor.proto. -
getFields
Get a list of this message type's fields. -
getFieldCount
public int getFieldCount()Get a count of this message type's fields. -
getField
Get the message type's field at the specified index. -
getOneofs
Get a list of this message type's oneofs. -
getOneofCount
public int getOneofCount()Get a count of this message type's oneofs. -
getOneof
Get the message type's oneof at the specified index. -
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
Get the message type's real oneof at the specified index. -
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
Get the extension defined nested within this message type's scope at the specified index. -
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
Get the message type's nested message type at the specified index. -
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
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
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
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
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
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
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
See.invalid reference
FileDescriptor#resolveAllFeatures -
crossLink
Look up and cross-link all field types, etc. -
validateNoDuplicateFieldNumbers
-
setProto
private void setProto(DescriptorProtos.DescriptorProto proto) throws Descriptors.DescriptorValidationException
-