public static final class Descriptors.Descriptor extends Descriptors.GenericDescriptorDescribes a message type.
Methods
findEnumTypeByName(String name)
public Descriptors.EnumDescriptor findEnumTypeByName(String name)Finds a nested enum type by name.
| Parameter | |
|---|---|
| Name | Description |
name |
StringThe unqualified name of the nested type (e.g. "Foo"). |
| Returns | |
|---|---|
| Type | Description |
Descriptors.EnumDescriptor |
The types's descriptor, or |
findFieldByName(String name)
public Descriptors.FieldDescriptor findFieldByName(String name)Finds a field by name.
| Parameter | |
|---|---|
| Name | Description |
name |
StringThe unqualified name of the field (e.g. "foo"). For protocol buffer messages that follow <a href=https://developers.google.com/protocol-buffers/docs/style#message_and_field_names>Google's guidance on naming this will be a snake case string, such as song_name . |
| Returns | |
|---|---|
| Type | Description |
Descriptors.FieldDescriptor |
The field's descriptor, or |
findFieldByNumber(int number)
public Descriptors.FieldDescriptor findFieldByNumber(int number)Finds a field by field number.
| Parameter | |
|---|---|
| Name | Description |
number |
intThe field number within this message type. |
| Returns | |
|---|---|
| Type | Description |
Descriptors.FieldDescriptor |
The field's descriptor, or |
findNestedTypeByName(String name)
public Descriptors.Descriptor findNestedTypeByName(String name)Finds a nested message type by name.
| Parameter | |
|---|---|
| Name | Description |
name |
StringThe unqualified name of the nested type (e.g. "Foo"). |
| Returns | |
|---|---|
| Type | Description |
Descriptors.Descriptor |
The types's descriptor, or |
getContainingType()
public Descriptors.Descriptor getContainingType()If this is a nested type, get the outer descriptor, otherwise null.
| Returns | |
|---|---|
| Type | Description |
Descriptors.Descriptor |
|
getEnumTypes()
public List<Descriptors.EnumDescriptor> getEnumTypes()Get a list of enum types nested within this one.
| Returns | |
|---|---|
| Type | Description |
List<EnumDescriptor> |
|
getExtensions()
public List<Descriptors.FieldDescriptor> getExtensions()Get a list of this message type's extensions.
| Returns | |
|---|---|
| Type | Description |
List<FieldDescriptor> |
|
getFields()
public List<Descriptors.FieldDescriptor> getFields()Get a list of this message type's fields.
| Returns | |
|---|---|
| Type | Description |
List<FieldDescriptor> |
|
getFile()
public Descriptors.FileDescriptor getFile()Get the FileDescriptor containing this descriptor.
| Returns | |
|---|---|
| Type | Description |
Descriptors.FileDescriptor |
|
getFullName()
public 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".
| Returns | |
|---|---|
| Type | Description |
String |
|
getIndex()
public int getIndex()Get the index of this descriptor within its parent. In other words, given a FileDescriptor file, the following is true:
for all i in [0, file.getMessageTypeCount()): file.getMessageType(i).getIndex() == i
Similarly, for a Descriptor messageType:
for all i in [0, messageType.getNestedTypeCount()): messageType.getNestedType(i).getIndex() == i
| Returns | |
|---|---|
| Type | Description |
int |
|
getName()
public String getName()Get the type's unqualified name.
| Returns | |
|---|---|
| Type | Description |
String |
|
getNestedTypes()
public List<Descriptors.Descriptor> getNestedTypes()Get a list of message types nested within this one.
| Returns | |
|---|---|
| Type | Description |
List<Descriptor> |
|
getOneofs()
public List<Descriptors.OneofDescriptor> getOneofs()Get a list of this message type's oneofs.
| Returns | |
|---|---|
| Type | Description |
List<OneofDescriptor> |
|
getOptions()
public DescriptorProtos.MessageOptions getOptions()Get the MessageOptions, defined in descriptor.proto.
| Returns | |
|---|---|
| Type | Description |
DescriptorProtos.MessageOptions |
|
getRealOneofs()
public List<Descriptors.OneofDescriptor> getRealOneofs()Get a list of this message type's real oneofs.
| Returns | |
|---|---|
| Type | Description |
List<OneofDescriptor> |
|
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.
| Returns | |
|---|---|
| Type | Description |
boolean |
|
isExtensionNumber(int number)
public boolean isExtensionNumber(int number)Determines if the given field number is an extension.
| Parameter | |
|---|---|
| Name | Description |
number |
int |
| Returns | |
|---|---|
| Type | Description |
boolean |
|
isReservedName(String name)
public boolean isReservedName(String name)Determines if the given field name is reserved.
| Parameter | |
|---|---|
| Name | Description |
name |
String |
| Returns | |
|---|---|
| Type | Description |
boolean |
|
isReservedNumber(int number)
public boolean isReservedNumber(int number)Determines if the given field number is reserved.
| Parameter | |
|---|---|
| Name | Description |
number |
int |
| Returns | |
|---|---|
| Type | Description |
boolean |
|
toProto()
public DescriptorProtos.DescriptorProto toProto()Convert the descriptor to its protocol message representation.
| Returns | |
|---|---|
| Type | Description |
DescriptorProtos.DescriptorProto |
|