Package com.google.protobuf
Class Descriptors.FileDescriptor
java.lang.Object
com.google.protobuf.Descriptors.GenericDescriptor
com.google.protobuf.Descriptors.FileDescriptor
- Enclosing class:
- Descriptors
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).-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceThis class should be used by generated code only. -
Method Summary
Modifier and TypeMethodDescriptionstatic Descriptors.FileDescriptorbuildFrom(DescriptorProtos.FileDescriptorProto proto, Descriptors.FileDescriptor[] dependencies) Construct aFileDescriptor.findEnumTypeByName(String name) Find an enum type in the file by name.findExtensionByName(String name) Find an extension in the file by name.findMessageTypeByName(String name) Find a message type in the file by name.findServiceByName(String name) Find a service type in the file by name.Get a list of this file's dependencies (imports).Get a list of top-level enum types declared in this file.Get a list of top-level extensions declared in this file.getFile()Returns this object.Returns the same as getName().Get a list of top-level message types declared in this file.getName()Get the file name.Get theFileOptions, defined indescriptor.proto.Get the proto package name.Get a list of this file's public dependencies (public imports).Get a list of top-level services declared in this file.static voidinternalBuildGeneratedFileFrom(String[] descriptorDataParts, Descriptors.FileDescriptor[] dependencies, Descriptors.FileDescriptor.InternalDescriptorAssigner descriptorAssigner) This method is to be called by generated code only.static voidinternalBuildGeneratedFileFrom(String[] descriptorDataParts, Class<?> descriptorOuterClass, String[] dependencies, String[] dependencyFileNames, Descriptors.FileDescriptor.InternalDescriptorAssigner descriptorAssigner) This method is to be called by generated code only.static voidinternalUpdateFileDescriptor(Descriptors.FileDescriptor descriptor, ExtensionRegistry registry) This method is to be called by generated code only.toProto()Convert the descriptor to its protocol message representation.
-
Method Details
-
toProto
Convert the descriptor to its protocol message representation.- Specified by:
toProtoin classDescriptors.GenericDescriptor
-
getName
Get the file name.- Specified by:
getNamein classDescriptors.GenericDescriptor
-
getFile
Returns this object.- Specified by:
getFilein classDescriptors.GenericDescriptor
-
getFullName
Returns the same as getName().- Specified by:
getFullNamein classDescriptors.GenericDescriptor
-
getPackage
Get the proto package name. This is the package name given by thepackagestatement in the.protofile, which differs from the Java package. -
getOptions
Get theFileOptions, defined indescriptor.proto. -
getMessageTypes
Get a list of top-level message types declared in this file. -
getEnumTypes
Get a list of top-level enum types declared in this file. -
getServices
Get a list of top-level services declared in this file. -
getExtensions
Get a list of top-level extensions declared in this file. -
getDependencies
Get a list of this file's dependencies (imports). -
getPublicDependencies
Get a list of this file's public dependencies (public imports). -
findMessageTypeByName
Find a message type in the file by name. Does not find nested types.- Parameters:
name- The unqualified type name to look for.- Returns:
- The message type's descriptor, or
nullif not found.
-
findEnumTypeByName
Find an enum type in the file by name. Does not find nested types.- Parameters:
name- The unqualified type name to look for.- Returns:
- The enum type's descriptor, or
nullif not found.
-
findServiceByName
Find a service type in the file by name.- Parameters:
name- The unqualified type name to look for.- Returns:
- The service type's descriptor, or
nullif not found.
-
findExtensionByName
Find an extension in the file by name. Does not find extensions nested inside message types.- Parameters:
name- The unqualified extension name to look for.- Returns:
- The extension's descriptor, or
nullif not found.
-
buildFrom
public static Descriptors.FileDescriptor buildFrom(DescriptorProtos.FileDescriptorProto proto, Descriptors.FileDescriptor[] dependencies) throws Descriptors.DescriptorValidationException Construct aFileDescriptor.- Parameters:
proto- The protocol message form of the FileDescriptor.dependencies-FileDescriptors corresponding to all of the file's dependencies.- Throws:
Descriptors.DescriptorValidationException-protois not a valid descriptor. This can occur for a number of reasons, e.g. because a field has an undefined type or because two messages were defined with the same name.
-
internalBuildGeneratedFileFrom
public static void internalBuildGeneratedFileFrom(String[] descriptorDataParts, Descriptors.FileDescriptor[] dependencies, Descriptors.FileDescriptor.InternalDescriptorAssigner descriptorAssigner) This method is to be called by generated code only. It is equivalent tobuildFromexcept that theFileDescriptorProtois encoded in protocol buffer wire format. -
internalBuildGeneratedFileFrom
public static void internalBuildGeneratedFileFrom(String[] descriptorDataParts, Class<?> descriptorOuterClass, String[] dependencies, String[] dependencyFileNames, Descriptors.FileDescriptor.InternalDescriptorAssigner descriptorAssigner) This method is to be called by generated code only. It uses Java reflection to load the dependencies' descriptors. -
internalUpdateFileDescriptor
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.
-