Package com.google.protobuf

# Class Descriptors.FileDescriptor

java.lang.Object
com.google.protobuf.Descriptors.GenericDescriptor
com.google.protobuf.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).

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static interface`
`Descriptors.FileDescriptor.InternalDescriptorAssigner`
Deprecated.

## Method Summary

Modifier and Type
Method
Description
`static Descriptors.FileDescriptor`
`buildFrom(DescriptorProtos.FileDescriptorProto proto, Descriptors.FileDescriptor[] dependencies)`
Construct a `FileDescriptor`.
`static Descriptors.FileDescriptor`
`buildFrom(DescriptorProtos.FileDescriptorProto proto, Descriptors.FileDescriptor[] dependencies, boolean allowUnknownDependencies)`
Construct a `FileDescriptor`.
`void`
`copyHeadingTo(DescriptorProtos.FileDescriptorProto.Builder protoBuilder)`
`Descriptors.EnumDescriptor`
`findEnumTypeByName(String name)`
Find an enum type in the file by name.
`Descriptors.FieldDescriptor`
`findExtensionByName(String name)`
Find an extension in the file by name.
`Descriptors.Descriptor`
`findMessageTypeByName(String name)`
Find a message type in the file by name.
`Descriptors.ServiceDescriptor`
`findServiceByName(String name)`
Find a service type in the file by name.
`List<Descriptors.FileDescriptor>`
`getDependencies()`
Get a list of this file's dependencies (imports).
`List<Descriptors.EnumDescriptor>`
`getEnumTypes()`
Get a list of top-level enum types declared in this file.
`List<Descriptors.FieldDescriptor>`
`getExtensions()`
Get a list of top-level extensions declared in this file.
`Descriptors.FileDescriptor`
`getFile()`
Returns this object.
`String`
`getFullName()`
Returns the same as getName().
`List<Descriptors.Descriptor>`
`getMessageTypes()`
Get a list of top-level message types declared in this file.
`String`
`getName()`
Get the file name.
`DescriptorProtos.FileOptions`
`getOptions()`
Get the `FileOptions`, defined in `descriptor.proto`.
`String`
`getPackage()`
Get the proto package name.
`List<Descriptors.FileDescriptor>`
`getPublicDependencies()`
Get a list of this file's public dependencies (public imports).
`List<Descriptors.ServiceDescriptor>`
`getServices()`
Get a list of top-level services declared in this file.
`static Descriptors.FileDescriptor`
`internalBuildGeneratedFileFrom(String[] descriptorDataParts, Descriptors.FileDescriptor[] dependencies)`
This method is to be called by generated code only.
`static Descriptors.FileDescriptor`
`internalBuildGeneratedFileFrom(String[] descriptorDataParts, Class<?> descriptorOuterClass, String[] dependencyClassNames, String[] dependencyFileNames)`
This method is to be called by generated code only.
`static void`
`internalUpdateFileDescriptor(Descriptors.FileDescriptor descriptor, ExtensionRegistry registry)`
This method is to be called by generated code only.
`void`
`resolveAllFeaturesImmutable()`
`DescriptorProtos.FileDescriptorProto`
`toProto()`
Convert the descriptor to its protocol message representation.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Method Details

### toProto

public DescriptorProtos.FileDescriptorProto toProto()
Convert the descriptor to its protocol message representation.

Specified by:
  `toProto` in class `Descriptors.GenericDescriptor`

### getName

public String getName()
Get the file name.

Specified by:
  `getName` in class `Descriptors.GenericDescriptor`

### getFile

public Descriptors.FileDescriptor getFile()
Returns this object.

Specified by:
  `getFile` in class `Descriptors.GenericDescriptor`

### getFullName

public String getFullName()
Returns the same as getName().

Specified by:
  `getFullName` in class `Descriptors.GenericDescriptor`

### 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.

### getOptions

public DescriptorProtos.FileOptions getOptions()
Get the `FileOptions`, defined in `descriptor.proto`.

### getMessageTypes

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

### getEnumTypes

public List<Descriptors.EnumDescriptor> getEnumTypes()
Get a list of top-level enum types declared in this file.

### getServices

public List<Descriptors.ServiceDescriptor> getServices()
Get a list of top-level services declared in this file.

### getExtensions

public List<Descriptors.FieldDescriptor> getExtensions()
Get a list of top-level extensions declared in this file.

### getDependencies

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

### getPublicDependencies

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

### copyHeadingTo

public void copyHeadingTo(DescriptorProtos.FileDescriptorProto.Builder protoBuilder)

### 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.

### buildFrom

public static Descriptors.FileDescriptor buildFrom(DescriptorProtos.FileDescriptorProto proto, Descriptors.FileDescriptor[] dependencies) throws Descriptors.DescriptorValidationException
Construct a `FileDescriptor`.

Parameters:
  `proto` - the protocol message form of the FileDescriptort
  `dependencies` - `FileDescriptor`s corresponding to all of the file's dependencies.
Throws:
  `Descriptors.DescriptorValidationException` - `proto` is not a valid descriptor. This can occur for a number of reasons; for instance, because a field has an undefined type or because two messages were defined with the same name.

### buildFrom

public static Descriptors.FileDescriptor buildFrom(DescriptorProtos.FileDescriptorProto proto, Descriptors.FileDescriptor[] dependencies, boolean allowUnknownDependencies) throws Descriptors.DescriptorValidationException
Construct a `FileDescriptor`.

Parameters:
  `proto` - the protocol message form of the FileDescriptor
  `dependencies` - `FileDescriptor`s corresponding to all of the file's dependencies
  `allowUnknownDependencies` - if true, non-existing dependencies will be ignored and undefined message types will be replaced with a placeholder type. Undefined enum types still cause a DescriptorValidationException.
Throws:
  `Descriptors.DescriptorValidationException` - `proto` is not a valid descriptor. This can occur for a number of reasons; for instance, because a field has an undefined type or because two messages were defined with the same name.

### internalBuildGeneratedFileFrom

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.

### internalBuildGeneratedFileFrom

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.

### internalUpdateFileDescriptor

public static void internalUpdateFileDescriptor(Descriptors.FileDescriptor descriptor, ExtensionRegistry registry)
This method is to be called by generated code only. It updates the FileDescriptorProto associated with the descriptor by parsing it again with the given ExtensionRegistry. This is needed to recognize custom options.

### resolveAllFeaturesImmutable

public void resolveAllFeaturesImmutable()