Package com.google.protobuf
Class Descriptors.DescriptorPool
- java.lang.Object
-
- com.google.protobuf.Descriptors.DescriptorPool
-
- Enclosing class:
- Descriptors
private static final class Descriptors.DescriptorPool extends java.lang.Object
A private helper class which contains lookup tables containing all the descriptors defined in a particular file.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
Descriptors.DescriptorPool.PackageDescriptor
Represents a package in the symbol table.(package private) static class
Descriptors.DescriptorPool.SearchFilter
Defines what subclass of descriptors to search in the descriptor pool.
-
Field Summary
Fields Modifier and Type Field Description private boolean
allowUnknownDependencies
private java.util.Set<Descriptors.FileDescriptor>
dependencies
private java.util.Map<java.lang.String,Descriptors.GenericDescriptor>
descriptorsByName
-
Constructor Summary
Constructors Constructor Description DescriptorPool(Descriptors.FileDescriptor[] dependencies, boolean allowUnknownDependencies)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
addPackage(java.lang.String fullName, Descriptors.FileDescriptor file)
Adds a package to the symbol tables.(package private) void
addSymbol(Descriptors.GenericDescriptor descriptor)
Adds a symbol to the symbol table.(package private) Descriptors.GenericDescriptor
findSymbol(java.lang.String fullName)
Find a generic descriptor by fully-qualified name.(package private) Descriptors.GenericDescriptor
findSymbol(java.lang.String fullName, Descriptors.DescriptorPool.SearchFilter filter)
Find a descriptor by fully-qualified name and given option to only search valid field type descriptors.private void
importPublicDependencies(Descriptors.FileDescriptor file)
Find and put public dependencies of the file into dependencies set.(package private) boolean
isAggregate(Descriptors.GenericDescriptor descriptor)
Checks if the descriptor is a valid namespace type.(package private) boolean
isType(Descriptors.GenericDescriptor descriptor)
Checks if the descriptor is a valid type for a message field.(package private) Descriptors.GenericDescriptor
lookupSymbol(java.lang.String name, Descriptors.GenericDescriptor relativeTo, Descriptors.DescriptorPool.SearchFilter filter)
Look up a type descriptor by name, relative to some other descriptor.(package private) static void
validateSymbolName(Descriptors.GenericDescriptor descriptor)
Verifies that the descriptor's name is valid (i.e.
-
-
-
Field Detail
-
dependencies
private final java.util.Set<Descriptors.FileDescriptor> dependencies
-
allowUnknownDependencies
private boolean allowUnknownDependencies
-
descriptorsByName
private final java.util.Map<java.lang.String,Descriptors.GenericDescriptor> descriptorsByName
-
-
Constructor Detail
-
DescriptorPool
DescriptorPool(Descriptors.FileDescriptor[] dependencies, boolean allowUnknownDependencies)
-
-
Method Detail
-
importPublicDependencies
private void importPublicDependencies(Descriptors.FileDescriptor file)
Find and put public dependencies of the file into dependencies set.
-
findSymbol
Descriptors.GenericDescriptor findSymbol(java.lang.String fullName)
Find a generic descriptor by fully-qualified name.
-
findSymbol
Descriptors.GenericDescriptor findSymbol(java.lang.String fullName, Descriptors.DescriptorPool.SearchFilter filter)
Find a descriptor by fully-qualified name and given option to only search valid field type descriptors.
-
isType
boolean isType(Descriptors.GenericDescriptor descriptor)
Checks if the descriptor is a valid type for a message field.
-
isAggregate
boolean isAggregate(Descriptors.GenericDescriptor descriptor)
Checks if the descriptor is a valid namespace type.
-
lookupSymbol
Descriptors.GenericDescriptor lookupSymbol(java.lang.String name, Descriptors.GenericDescriptor relativeTo, Descriptors.DescriptorPool.SearchFilter filter) throws Descriptors.DescriptorValidationException
Look up a type descriptor by name, relative to some other descriptor. The name may be fully-qualified (with a leading '.'), partially-qualified, or unqualified. C++-like name lookup semantics are used to search for the matching descriptor.
-
addSymbol
void addSymbol(Descriptors.GenericDescriptor descriptor) throws Descriptors.DescriptorValidationException
Adds a symbol to the symbol table. If a symbol with the same name already exists, throws an error.
-
addPackage
void addPackage(java.lang.String fullName, Descriptors.FileDescriptor file) throws Descriptors.DescriptorValidationException
Adds a package to the symbol tables. If a package by the same name already exists, that is fine, but if some other kind of symbol exists under the same name, an exception is thrown. If the package has multiple components, this also adds the parent package(s).
-
validateSymbolName
static void validateSymbolName(Descriptors.GenericDescriptor descriptor) throws Descriptors.DescriptorValidationException
Verifies that the descriptor's name is valid (i.e. it contains only letters, digits, and underscores, and does not start with a digit).
-
-