# Class Descriptors.FileDescriptor (3.19.4)

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

## Inheritance

[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> [Descriptors.GenericDescriptor](https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Descriptors.GenericDescriptor) \> Descriptors.FileDescriptor

## Inherited Members

[Descriptors.GenericDescriptor.getFile()](https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Descriptors.GenericDescriptor#com_google_protobuf_Descriptors_GenericDescriptor_getFile__) [Descriptors.GenericDescriptor.getFullName()](https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Descriptors.GenericDescriptor#com_google_protobuf_Descriptors_GenericDescriptor_getFullName__) [Descriptors.GenericDescriptor.getName()](https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Descriptors.GenericDescriptor#com_google_protobuf_Descriptors_GenericDescriptor_getName__) [Descriptors.GenericDescriptor.toProto()](https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Descriptors.GenericDescriptor#com_google_protobuf_Descriptors_GenericDescriptor_toProto__) [Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) [Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) [Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) [Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) [Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) [Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) [Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) [Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) [Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) [Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) [Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)

## 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` | `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.DescriptorProtos.FileDescriptorProto` The protocol message form of the FileDescriptor. |
| `dependencies` | `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Descriptors.FileDescriptor[]` `FileDescriptor`s corresponding to all of the file's dependencies. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Descriptors.FileDescriptor` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Descriptors.DescriptorValidationException` | `proto` is 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. |

### 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` | `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.DescriptorProtos.FileDescriptorProto` The protocol message form of the FileDescriptor. |
| `dependencies` | `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Descriptors.FileDescriptor[]` `FileDescriptor`s corresponding to all of the file's dependencies. |
| `allowUnknownDependencies` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` If true, non-exist dependenncies will be ignored and undefined message types will be replaced with a placeholder type. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Descriptors.FileDescriptor` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Descriptors.DescriptorValidationException` | `proto` is 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(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` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html[]` |
| `dependencies` | `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Descriptors.FileDescriptor[]` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.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` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html[]` |
| `dependencies` | `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Descriptors.FileDescriptor[]` |
| `descriptorAssigner` | `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.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` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html[]` |
| `descriptorOuterClass` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html<?>` |
| `dependencyClassNames` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html[]` |
| `dependencyFileNames` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html[]` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.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` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html[]` |
| `descriptorOuterClass` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html<?>` |
| `dependencyClassNames` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html[]` |
| `dependencyFileNames` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html[]` |
| `descriptorAssigner` | `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.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` | `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Descriptors.FileDescriptor` |
| `registry` | `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.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` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` The unqualified type name to look for. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Descriptors.EnumDescriptor` | The enum type's descriptor, or `null` if not found. |

### 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` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` The unqualified extension name to look for. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Descriptors.FieldDescriptor` | The extension's descriptor, or `null` if not found. |

### 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` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` The unqualified type name to look for. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Descriptors.Descriptor` | The message type's descriptor, or `null` if not found. |

### findServiceByName(String name)

    public Descriptors.ServiceDescriptor findServiceByName(String name)

Find a service type in the file by name.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` The unqualified type name to look for. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Descriptors.ServiceDescriptor` | The service type's descriptor, or `null` if not found. |

### getDependencies()

    public List<Descriptors.FileDescriptor> getDependencies()

Get a list of this file's dependencies (imports).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/util/List.html<https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Descriptors.FileDescriptor>` |   |

### getEnumTypes()

    public List<Descriptors.EnumDescriptor> getEnumTypes()

Get a list of top-level enum types declared in this file.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/util/List.html<https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Descriptors.EnumDescriptor>` |   |

### getExtensions()

    public List<Descriptors.FieldDescriptor> getExtensions()

Get a list of top-level extensions declared in this file.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/util/List.html<https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Descriptors.FieldDescriptor>` |   |

### getFile()

    public Descriptors.FileDescriptor getFile()

Returns this object.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Descriptors.FileDescriptor` |   |

**Overrides** [Descriptors.GenericDescriptor.getFile()](https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Descriptors.GenericDescriptor#com_google_protobuf_Descriptors_GenericDescriptor_getFile__)

### getFullName()

    public String getFullName()

Returns the same as getName().

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

**Overrides** [Descriptors.GenericDescriptor.getFullName()](https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Descriptors.GenericDescriptor#com_google_protobuf_Descriptors_GenericDescriptor_getFullName__)

### getMessageTypes()

    public List<Descriptors.Descriptor> getMessageTypes()

Get a list of top-level message types declared in this file.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/util/List.html<https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Descriptors.Descriptor>` |   |

### getName()

    public String getName()

Get the file name.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

**Overrides** [Descriptors.GenericDescriptor.getName()](https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Descriptors.GenericDescriptor#com_google_protobuf_Descriptors_GenericDescriptor_getName__)

### getOptions()

    public DescriptorProtos.FileOptions getOptions()

Get the `FileOptions`, defined in `descriptor.proto`.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.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** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### getPublicDependencies()

    public List<Descriptors.FileDescriptor> getPublicDependencies()

Get a list of this file's public dependencies (public imports).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/util/List.html<https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Descriptors.FileDescriptor>` |   |

### getServices()

    public List<Descriptors.ServiceDescriptor> getServices()

Get a list of top-level services declared in this file.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/util/List.html<https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Descriptors.ServiceDescriptor>` |   |

### getSyntax()

    public Descriptors.FileDescriptor.Syntax getSyntax()

Get the syntax of the .proto file.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Descriptors.FileDescriptor.Syntax` |   |

### toProto()

    public DescriptorProtos.FileDescriptorProto toProto()

Convert the descriptor to its protocol message representation.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.DescriptorProtos.FileDescriptorProto` |   |

**Overrides** [Descriptors.GenericDescriptor.toProto()](https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Descriptors.GenericDescriptor#com_google_protobuf_Descriptors_GenericDescriptor_toProto__)