public static final class Descriptors.FileDescriptor extends Descriptors.GenericDescriptor
.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).Modifier and Type | Class and Description |
---|---|
static interface |
Descriptors.FileDescriptor.InternalDescriptorAssigner
This class should be used by generated code only.
|
static class |
Descriptors.FileDescriptor.Syntax
The syntax of the .proto file.
|
Modifier and Type | Field and Description |
---|---|
private Descriptors.FileDescriptor[] |
dependencies |
private Descriptors.EnumDescriptor[] |
enumTypes |
private Descriptors.FieldDescriptor[] |
extensions |
private Descriptors.Descriptor[] |
messageTypes |
private Descriptors.DescriptorPool |
pool |
private DescriptorProtos.FileDescriptorProto |
proto |
private Descriptors.FileDescriptor[] |
publicDependencies |
private Descriptors.ServiceDescriptor[] |
services |
Modifier | Constructor and Description |
---|---|
private |
FileDescriptor(DescriptorProtos.FileDescriptorProto proto,
Descriptors.FileDescriptor[] dependencies,
Descriptors.DescriptorPool pool,
boolean allowUnknownDependencies) |
(package private) |
FileDescriptor(java.lang.String packageName,
Descriptors.Descriptor message)
Create a placeholder FileDescriptor for a message Descriptor.
|
Modifier and Type | Method and 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 . |
private void |
crossLink()
Look up and cross-link all field types, etc.
|
Descriptors.EnumDescriptor |
findEnumTypeByName(java.lang.String name)
Find an enum type in the file by name.
|
Descriptors.FieldDescriptor |
findExtensionByName(java.lang.String name)
Find an extension in the file by name.
|
Descriptors.Descriptor |
findMessageTypeByName(java.lang.String name)
Find a message type in the file by name.
|
Descriptors.ServiceDescriptor |
findServiceByName(java.lang.String name)
Find a service type in the file by name.
|
java.util.List<Descriptors.FileDescriptor> |
getDependencies()
Get a list of this file's dependencies (imports).
|
java.util.List<Descriptors.EnumDescriptor> |
getEnumTypes()
Get a list of top-level enum types declared in this file.
|
java.util.List<Descriptors.FieldDescriptor> |
getExtensions()
Get a list of top-level extensions declared in this file.
|
Descriptors.FileDescriptor |
getFile()
Returns this object.
|
java.lang.String |
getFullName()
Returns the same as getName().
|
java.util.List<Descriptors.Descriptor> |
getMessageTypes()
Get a list of top-level message types declared in this file.
|
java.lang.String |
getName()
Get the file name.
|
DescriptorProtos.FileOptions |
getOptions()
Get the
FileOptions , defined in descriptor.proto . |
java.lang.String |
getPackage()
Get the proto package name.
|
java.util.List<Descriptors.FileDescriptor> |
getPublicDependencies()
Get a list of this file's public dependencies (public imports).
|
java.util.List<Descriptors.ServiceDescriptor> |
getServices()
Get a list of top-level services declared in this file.
|
Descriptors.FileDescriptor.Syntax |
getSyntax()
Get the syntax of the .proto file.
|
static void |
internalBuildGeneratedFileFrom(java.lang.String[] descriptorDataParts,
java.lang.Class<?> descriptorOuterClass,
java.lang.String[] dependencies,
java.lang.String[] dependencyFileNames,
Descriptors.FileDescriptor.InternalDescriptorAssigner descriptorAssigner)
This method is to be called by generated code only.
|
static void |
internalBuildGeneratedFileFrom(java.lang.String[] descriptorDataParts,
Descriptors.FileDescriptor[] dependencies,
Descriptors.FileDescriptor.InternalDescriptorAssigner descriptorAssigner)
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.
|
private void |
setProto(DescriptorProtos.FileDescriptorProto proto)
Replace our
DescriptorProtos.FileDescriptorProto with the given one, which is
identical except that it might contain extensions that weren't present
in the original. |
(package private) boolean |
supportsUnknownEnumValue() |
DescriptorProtos.FileDescriptorProto |
toProto()
Convert the descriptor to its protocol message representation.
|
private DescriptorProtos.FileDescriptorProto proto
private final Descriptors.Descriptor[] messageTypes
private final Descriptors.EnumDescriptor[] enumTypes
private final Descriptors.ServiceDescriptor[] services
private final Descriptors.FieldDescriptor[] extensions
private final Descriptors.FileDescriptor[] dependencies
private final Descriptors.FileDescriptor[] publicDependencies
private final Descriptors.DescriptorPool pool
private FileDescriptor(DescriptorProtos.FileDescriptorProto proto, Descriptors.FileDescriptor[] dependencies, Descriptors.DescriptorPool pool, boolean allowUnknownDependencies) throws Descriptors.DescriptorValidationException
FileDescriptor(java.lang.String packageName, Descriptors.Descriptor message) throws Descriptors.DescriptorValidationException
public DescriptorProtos.FileDescriptorProto toProto()
toProto
in class Descriptors.GenericDescriptor
public java.lang.String getName()
getName
in class Descriptors.GenericDescriptor
public Descriptors.FileDescriptor getFile()
getFile
in class Descriptors.GenericDescriptor
public java.lang.String getFullName()
getFullName
in class Descriptors.GenericDescriptor
public java.lang.String getPackage()
package
statement in the .proto
file, which differs
from the Java package.public DescriptorProtos.FileOptions getOptions()
FileOptions
, defined in descriptor.proto
.public java.util.List<Descriptors.Descriptor> getMessageTypes()
public java.util.List<Descriptors.EnumDescriptor> getEnumTypes()
public java.util.List<Descriptors.ServiceDescriptor> getServices()
public java.util.List<Descriptors.FieldDescriptor> getExtensions()
public java.util.List<Descriptors.FileDescriptor> getDependencies()
public java.util.List<Descriptors.FileDescriptor> getPublicDependencies()
public Descriptors.FileDescriptor.Syntax getSyntax()
public Descriptors.Descriptor findMessageTypeByName(java.lang.String name)
name
- The unqualified type name to look for.null
if not found.public Descriptors.EnumDescriptor findEnumTypeByName(java.lang.String name)
name
- The unqualified type name to look for.null
if not found.public Descriptors.ServiceDescriptor findServiceByName(java.lang.String name)
name
- The unqualified type name to look for.null
if not found.public Descriptors.FieldDescriptor findExtensionByName(java.lang.String name)
name
- The unqualified extension name to look for.null
if not found.public static Descriptors.FileDescriptor buildFrom(DescriptorProtos.FileDescriptorProto proto, Descriptors.FileDescriptor[] dependencies) throws Descriptors.DescriptorValidationException
FileDescriptor
.proto
- The protocol message form of the FileDescriptor.dependencies
- FileDescriptor
s corresponding to all of
the file's dependencies.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.public static Descriptors.FileDescriptor buildFrom(DescriptorProtos.FileDescriptorProto proto, Descriptors.FileDescriptor[] dependencies, boolean allowUnknownDependencies) throws Descriptors.DescriptorValidationException
FileDescriptor
.proto
- The protocol message form of the FileDescriptor.dependencies
- FileDescriptor
s corresponding to all of
the file's dependencies.allowUnknownDependencies
- If true, non-exist dependenncies will be
ignored and undefined message types will be replaced with a
placeholder type.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.public static void internalBuildGeneratedFileFrom(java.lang.String[] descriptorDataParts, Descriptors.FileDescriptor[] dependencies, Descriptors.FileDescriptor.InternalDescriptorAssigner descriptorAssigner)
buildFrom
except that the FileDescriptorProto
is
encoded in protocol buffer wire format.public static void internalBuildGeneratedFileFrom(java.lang.String[] descriptorDataParts, java.lang.Class<?> descriptorOuterClass, java.lang.String[] dependencies, java.lang.String[] dependencyFileNames, Descriptors.FileDescriptor.InternalDescriptorAssigner descriptorAssigner)
public static void internalUpdateFileDescriptor(Descriptors.FileDescriptor descriptor, ExtensionRegistry registry)
private void crossLink() throws Descriptors.DescriptorValidationException
private void setProto(DescriptorProtos.FileDescriptorProto proto)
DescriptorProtos.FileDescriptorProto
with the given one, which is
identical except that it might contain extensions that weren't present
in the original. This method is needed for bootstrapping when a file
defines custom options. The options may be defined in the file itself,
so we can't actually parse them until we've constructed the descriptors,
but to construct the descriptors we have to have parsed the descriptor
protos. So, we have to parse the descriptor protos a second time after
constructing the descriptors.boolean supportsUnknownEnumValue()