webkit  2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
Classes | Public Member Functions | Static Public Member Functions | List of all members
com.google.protobuf.ExtensionRegistry Class Reference
Inheritance diagram for com.google.protobuf.ExtensionRegistry:
com.google.protobuf.ExtensionRegistryLite

Classes

class  ExtensionInfo
 

Public Member Functions

ExtensionRegistry getUnmodifiable ()
 
ExtensionInfo findExtensionByName (final String fullName)
 
ExtensionInfo findImmutableExtensionByName (final String fullName)
 
ExtensionInfo findMutableExtensionByName (final String fullName)
 
ExtensionInfo findExtensionByNumber (final Descriptor containingType, final int fieldNumber)
 
ExtensionInfo findImmutableExtensionByNumber (final Descriptor containingType, final int fieldNumber)
 
ExtensionInfo findMutableExtensionByNumber (final Descriptor containingType, final int fieldNumber)
 
Set< ExtensionInfo > getAllMutableExtensionsByExtendedType (final String fullName)
 
Set< ExtensionInfo > getAllImmutableExtensionsByExtendedType (final String fullName)
 
void add (final Extension<?, ?> extension)
 
void add (final FieldDescriptor type)
 
void add (final FieldDescriptor type, final Message defaultInstance)
 
- Public Member Functions inherited from com.google.protobuf.ExtensionRegistryLite
ExtensionRegistryLite getUnmodifiable ()
 
final void add (final GeneratedMessageLite.GeneratedExtension<?, ?> extension)
 

Static Public Member Functions

static ExtensionRegistry newInstance ()
 
static ExtensionRegistry getEmptyRegistry ()
 
- Static Public Member Functions inherited from com.google.protobuf.ExtensionRegistryLite
static boolean isEagerlyParseMessageSets ()
 
static void setEagerlyParseMessageSets (boolean isEagerlyParse)
 
static ExtensionRegistryLite newInstance ()
 
static ExtensionRegistryLite getEmptyRegistry ()
 

Detailed Description

A table of known extensions, searchable by name or field number. When parsing a protocol message that might have extensions, you must provide an

ExtensionRegistry

in which you have registered any extensions that you want to be able to parse. Otherwise, those extensions will just be treated like unknown fields.

For example, if you had the

.proto

file:

option java_class = "MyProto";
message Foo {
  extensions 1000 to max;
}
extend Foo {
  optional int32 bar;
}

Then you might write code like:

ExtensionRegistry registry = ExtensionRegistry.newInstance();
registry.add(MyProto.bar);
MyProto.Foo message = MyProto.Foo.parseFrom(input, registry);

Background:

You might wonder why this is necessary. Two alternatives might come to mind. First, you might imagine a system where generated extensions are automatically registered when their containing classes are loaded. This is a popular technique, but is bad design; among other things, it creates a situation where behavior can change depending on what classes happen to be loaded. It also introduces a security vulnerability, because an unprivileged class could cause its code to be called unexpectedly from a privileged class by registering itself as an extension of the right type.

Another option you might consider is lazy parsing: do not parse an extension until it is first requested, at which point the caller must provide a type to use. This introduces a different set of problems. First, it would require a mutex lock any time an extension was accessed, which would be slow. Second, corrupt data would not be detected until first access, at which point it would be much harder to deal with it. Third, it could violate the expectation that message objects are immutable, since the type provided could be any arbitrary message class. An unprivileged user could take advantage of this to inject a mutable object into a message belonging to privileged code and create mischief.

Author
kento.nosp@m.n@go.nosp@m.ogle..nosp@m.com Kenton Varda

Member Function Documentation

◆ add() [1/3]

void com.google.protobuf.ExtensionRegistry.add ( final Extension<?, ?>  extension)
inline

Add an extension from a generated file to the registry.

◆ add() [2/3]

void com.google.protobuf.ExtensionRegistry.add ( final FieldDescriptor  type)
inline

Add a non-message-type extension to the registry by descriptor.

◆ add() [3/3]

void com.google.protobuf.ExtensionRegistry.add ( final FieldDescriptor  type,
final Message  defaultInstance 
)
inline

Add a message-type extension to the registry by descriptor.

◆ findExtensionByName()

ExtensionInfo com.google.protobuf.ExtensionRegistry.findExtensionByName ( final String  fullName)
inline

◆ findExtensionByNumber()

ExtensionInfo com.google.protobuf.ExtensionRegistry.findExtensionByNumber ( final Descriptor  containingType,
final int  fieldNumber 
)
inline

◆ findImmutableExtensionByName()

ExtensionInfo com.google.protobuf.ExtensionRegistry.findImmutableExtensionByName ( final String  fullName)
inline

Find an extension for immutable APIs by fully-qualified field name, in the proto namespace. i.e.

result.descriptor.fullName()

will match

fullName

if a match is found.

Returns
Information about the extension if found, or
null
otherwise.

◆ findImmutableExtensionByNumber()

ExtensionInfo com.google.protobuf.ExtensionRegistry.findImmutableExtensionByNumber ( final Descriptor  containingType,
final int  fieldNumber 
)
inline

Find an extension by containing type and field number for immutable APIs.

Returns
Information about the extension if found, or
null
otherwise.

◆ findMutableExtensionByName()

ExtensionInfo com.google.protobuf.ExtensionRegistry.findMutableExtensionByName ( final String  fullName)
inline

Find an extension for mutable APIs by fully-qualified field name, in the proto namespace. i.e.

result.descriptor.fullName()

will match

fullName

if a match is found.

Returns
Information about the extension if found, or
null
otherwise.

◆ findMutableExtensionByNumber()

ExtensionInfo com.google.protobuf.ExtensionRegistry.findMutableExtensionByNumber ( final Descriptor  containingType,
final int  fieldNumber 
)
inline

Find an extension by containing type and field number for mutable APIs.

Returns
Information about the extension if found, or
null
otherwise.

◆ getAllImmutableExtensionsByExtendedType()

Set<ExtensionInfo> com.google.protobuf.ExtensionRegistry.getAllImmutableExtensionsByExtendedType ( final String  fullName)
inline

Find all extensions for immutable APIs by fully-qualified name of extended class. Note that this method is more computationally expensive than getting a single extension by name or number.

Returns
Information about the extensions found, or
null
if there are none.

◆ getAllMutableExtensionsByExtendedType()

Set<ExtensionInfo> com.google.protobuf.ExtensionRegistry.getAllMutableExtensionsByExtendedType ( final String  fullName)
inline

Find all extensions for mutable APIs by fully-qualified name of extended class. Note that this method is more computationally expensive than getting a single extension by name or number.

Returns
Information about the extensions found, or
null
if there are none.

◆ getEmptyRegistry()

static ExtensionRegistry com.google.protobuf.ExtensionRegistry.getEmptyRegistry ( )
inlinestatic

Get the unmodifiable singleton empty instance.

◆ getUnmodifiable()

ExtensionRegistry com.google.protobuf.ExtensionRegistry.getUnmodifiable ( )
inline

Returns an unmodifiable view of the registry.

◆ newInstance()

static ExtensionRegistry com.google.protobuf.ExtensionRegistry.newInstance ( )
inlinestatic

Construct a new, empty instance.


The documentation for this class was generated from the following file: