public static final class Descriptors.FileDescriptor extends Descriptors.GenericDescriptor
Describes a .proto
file, including everything defined within. That includes, in
particular, descriptors for all the messages and file descriptors for all other imported
.proto
files (dependencies).
Static Methods
buildFrom(DescriptorProtos.FileDescriptorProto proto, Descriptors.FileDescriptor[] dependencies)
public static Descriptors.FileDescriptor buildFrom(DescriptorProtos.FileDescriptorProto proto, Descriptors.FileDescriptor[] dependencies)
Construct a FileDescriptor
.
Parameters | |
---|---|
Name | Description |
proto |
DescriptorProtos.FileDescriptorProto The protocol message form of the FileDescriptor. |
dependencies |
FileDescriptor[]
|
Returns | |
---|---|
Type | Description |
Descriptors.FileDescriptor |
Exceptions | |
---|---|
Type | Description |
Descriptors.DescriptorValidationException |
|
buildFrom(DescriptorProtos.FileDescriptorProto proto, Descriptors.FileDescriptor[] dependencies, boolean allowUnknownDependencies)
public static Descriptors.FileDescriptor buildFrom(DescriptorProtos.FileDescriptorProto proto, Descriptors.FileDescriptor[] dependencies, boolean allowUnknownDependencies)
Construct a FileDescriptor
.
Parameters | |
---|---|
Name | Description |
proto |
DescriptorProtos.FileDescriptorProto The protocol message form of the FileDescriptor. |
dependencies |
FileDescriptor[]
|
allowUnknownDependencies |
boolean If true, non-exist dependenncies will be ignored and undefined message types will be replaced with a placeholder type. |
Returns | |
---|---|
Type | Description |
Descriptors.FileDescriptor |
Exceptions | |
---|---|
Type | Description |
Descriptors.DescriptorValidationException |
|
internalBuildGeneratedFileFrom(String[] descriptorDataParts, Descriptors.FileDescriptor[] dependencies)
public static Descriptors.FileDescriptor internalBuildGeneratedFileFrom(String[] descriptorDataParts, Descriptors.FileDescriptor[] dependencies)
This method is to be called by generated code only. It is equivalent to buildFrom
except that the FileDescriptorProto
is encoded in protocol buffer wire format.
Parameters | |
---|---|
Name | Description |
descriptorDataParts |
String[] |
dependencies |
FileDescriptor[] |
Returns | |
---|---|
Type | Description |
Descriptors.FileDescriptor |
internalBuildGeneratedFileFrom(String[] descriptorDataParts, Descriptors.FileDescriptor[] dependencies, Descriptors.FileDescriptor.InternalDescriptorAssigner descriptorAssigner)
public static void internalBuildGeneratedFileFrom(String[] descriptorDataParts, Descriptors.FileDescriptor[] dependencies, Descriptors.FileDescriptor.InternalDescriptorAssigner descriptorAssigner)
This method is for backward compatibility with generated code which passed an InternalDescriptorAssigner.
Parameters | |
---|---|
Name | Description |
descriptorDataParts |
String[] |
dependencies |
FileDescriptor[] |
descriptorAssigner |
Descriptors.FileDescriptor.InternalDescriptorAssigner |
internalBuildGeneratedFileFrom(String[] descriptorDataParts, Class<?> descriptorOuterClass, String[] dependencyClassNames, String[] dependencyFileNames)
public static Descriptors.FileDescriptor internalBuildGeneratedFileFrom(String[] descriptorDataParts, Class<?> descriptorOuterClass, String[] dependencyClassNames, String[] dependencyFileNames)
This method is to be called by generated code only. It uses Java reflection to load the dependencies' descriptors.
Parameters | |
---|---|
Name | Description |
descriptorDataParts |
String[] |
descriptorOuterClass |
Class<?> |
dependencyClassNames |
String[] |
dependencyFileNames |
String[] |
Returns | |
---|---|
Type | Description |
Descriptors.FileDescriptor |
internalBuildGeneratedFileFrom(String[] descriptorDataParts, Class<?> descriptorOuterClass, String[] dependencyClassNames, String[] dependencyFileNames, Descriptors.FileDescriptor.InternalDescriptorAssigner descriptorAssigner)
public static void internalBuildGeneratedFileFrom(String[] descriptorDataParts, Class<?> descriptorOuterClass, String[] dependencyClassNames, String[] dependencyFileNames, Descriptors.FileDescriptor.InternalDescriptorAssigner descriptorAssigner)
This method is for backward compatibility with generated code which passed an InternalDescriptorAssigner.
Parameters | |
---|---|
Name | Description |
descriptorDataParts |
String[] |
descriptorOuterClass |
Class<?> |
dependencyClassNames |
String[] |
dependencyFileNames |
String[] |
descriptorAssigner |
Descriptors.FileDescriptor.InternalDescriptorAssigner |
internalUpdateFileDescriptor(Descriptors.FileDescriptor descriptor, ExtensionRegistry registry)
public static void internalUpdateFileDescriptor(Descriptors.FileDescriptor descriptor, ExtensionRegistry registry)
This method is to be called by generated code only. It is used to update the FileDescriptorProto associated with the descriptor by parsing it again with the given ExtensionRegistry. This is needed to recognize custom options.
Parameters | |
---|---|
Name | Description |
descriptor |
Descriptors.FileDescriptor |
registry |
ExtensionRegistry |
Methods
findEnumTypeByName(String name)
public Descriptors.EnumDescriptor findEnumTypeByName(String name)
Find an enum type in the file by name. Does not find nested types.
Parameter | |
---|---|
Name | Description |
name |
String The unqualified type name to look for. |
Returns | |
---|---|
Type | Description |
Descriptors.EnumDescriptor |
The enum type's descriptor, or |
findExtensionByName(String name)
public Descriptors.FieldDescriptor findExtensionByName(String name)
Find an extension in the file by name. Does not find extensions nested inside message types.
Parameter | |
---|---|
Name | Description |
name |
String The unqualified extension name to look for. |
Returns | |
---|---|
Type | Description |
Descriptors.FieldDescriptor |
The extension's descriptor, or |
findMessageTypeByName(String name)
public Descriptors.Descriptor findMessageTypeByName(String name)
Find a message type in the file by name. Does not find nested types.
Parameter | |
---|---|
Name | Description |
name |
String The unqualified type name to look for. |
Returns | |
---|---|
Type | Description |
Descriptors.Descriptor |
The message type's descriptor, or |
findServiceByName(String name)
public Descriptors.ServiceDescriptor findServiceByName(String name)
Find a service type in the file by name.
Parameter | |
---|---|
Name | Description |
name |
String The unqualified type name to look for. |
Returns | |
---|---|
Type | Description |
Descriptors.ServiceDescriptor |
The service type's descriptor, or |
getDependencies()
public List<Descriptors.FileDescriptor> getDependencies()
Get a list of this file's dependencies (imports).
Returns | |
---|---|
Type | Description |
List<FileDescriptor> |
getEnumTypes()
public List<Descriptors.EnumDescriptor> getEnumTypes()
Get a list of top-level enum types declared in this file.
Returns | |
---|---|
Type | Description |
List<EnumDescriptor> |
getExtensions()
public List<Descriptors.FieldDescriptor> getExtensions()
Get a list of top-level extensions declared in this file.
Returns | |
---|---|
Type | Description |
List<FieldDescriptor> |
getFile()
public Descriptors.FileDescriptor getFile()
Returns this object.
Returns | |
---|---|
Type | Description |
Descriptors.FileDescriptor |
getFullName()
public String getFullName()
Returns the same as getName().
Returns | |
---|---|
Type | Description |
String |
getMessageTypes()
public List<Descriptors.Descriptor> getMessageTypes()
Get a list of top-level message types declared in this file.
Returns | |
---|---|
Type | Description |
List<Descriptor> |
getName()
public String getName()
Get the file name.
Returns | |
---|---|
Type | Description |
String |
getOptions()
public DescriptorProtos.FileOptions getOptions()
Get the FileOptions
, defined in descriptor.proto
.
Returns | |
---|---|
Type | Description |
DescriptorProtos.FileOptions |
getPackage()
public String getPackage()
Get the proto package name. This is the package name given by the package
statement
in the .proto
file, which differs from the Java package.
Returns | |
---|---|
Type | Description |
String |
getPublicDependencies()
public List<Descriptors.FileDescriptor> getPublicDependencies()
Get a list of this file's public dependencies (public imports).
Returns | |
---|---|
Type | Description |
List<FileDescriptor> |
getServices()
public List<Descriptors.ServiceDescriptor> getServices()
Get a list of top-level services declared in this file.
Returns | |
---|---|
Type | Description |
List<ServiceDescriptor> |
getSyntax()
public Descriptors.FileDescriptor.Syntax getSyntax()
Get the syntax of the .proto file.
Returns | |
---|---|
Type | Description |
Descriptors.FileDescriptor.Syntax |
toProto()
public DescriptorProtos.FileDescriptorProto toProto()
Convert the descriptor to its protocol message representation.
Returns | |
---|---|
Type | Description |
DescriptorProtos.FileDescriptorProto |