Class Descriptors.FileDescriptor

  • Enclosing class:
    Descriptors


    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).
    • Method Detail

      • getName

        public String getName()
        Get the file name.
      • getFullName

        public String getFullName()
        Returns the same as getName().
      • 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.
      • getMessageTypes

        public List<Descriptors.Descriptor> getMessageTypes()
        Get a list of top-level message types declared in this file.
      • getPublicDependencies

        public List<Descriptors.FileDescriptor> getPublicDependencies()
        Get a list of this file's public dependencies (public imports).
      • findMessageTypeByName

        public Descriptors.Descriptor findMessageTypeByName(String name)
        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 null if not found.
      • findEnumTypeByName

        public Descriptors.EnumDescriptor findEnumTypeByName(String name)
        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 null if not found.
      • findServiceByName

        public Descriptors.ServiceDescriptor findServiceByName(String name)
        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 null if not found.
      • findExtensionByName

        public Descriptors.FieldDescriptor findExtensionByName(String name)
        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 null if not found.
      • 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.