com.google.protobuf
Class Descriptors.FileDescriptor

java.lang.Object
  extended by com.google.protobuf.Descriptors.FileDescriptor
Enclosing class:
Descriptors

public static final class Descriptors.FileDescriptor
extends java.lang.Object

Describes a .proto file, including everything defined within.


Nested Class Summary
static interface Descriptors.FileDescriptor.InternalDescriptorAssigner
          This class should be used by generated code only.
 
Method Summary
static Descriptors.FileDescriptor buildFrom(DescriptorProtos.FileDescriptorProto proto, Descriptors.FileDescriptor[] dependencies)
          Construct a FileDescriptor.
 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.
 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.ServiceDescriptor> getServices()
          Get a list of top-level services declared in this file.
static void internalBuildGeneratedFileFrom(java.lang.String[] descriptorDataParts, Descriptors.FileDescriptor[] dependencies, Descriptors.FileDescriptor.InternalDescriptorAssigner descriptorAssigner)
          This method is to be called by generated code only.
 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 Detail

toProto

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


getName

public java.lang.String getName()
Get the file name.


getPackage

public java.lang.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 java.util.List<Descriptors.Descriptor> getMessageTypes()
Get a list of top-level message types declared in this file.


getEnumTypes

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


getServices

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


getExtensions

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


getDependencies

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


findMessageTypeByName

public Descriptors.Descriptor findMessageTypeByName(java.lang.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(java.lang.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(java.lang.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(java.lang.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 FileDescriptor.
dependencies - FileDescriptors corresponding to all of the file's dependencies, in the exact order listed in proto.
Throws:
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

public static void internalBuildGeneratedFileFrom(java.lang.String[] descriptorDataParts,
                                                  Descriptors.FileDescriptor[] dependencies,
                                                  Descriptors.FileDescriptor.InternalDescriptorAssigner descriptorAssigner)
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.



Copyright © 2008-2009 Google. All Rights Reserved.