Top Description Inners Fields Constructors Methods
com.google.protobuf.nano

public Class Extension<M extends com.google.protobuf.nano.ExtendableMessageNano<M>, T>

extends Object
Class Inheritance
Known Direct Subclasses
com.google.protobuf.nano.Extension.PrimitiveExtension
Type Parameters
<M>
the type of the extendable message this extension is for.
<T>
the Java type of the extension; see clazz.
Imports
java.io.IOException, java.lang.reflect.Array, java.util.ArrayList, .List

Represents an extension.
Authors
[email protected] (Brian Duff), [email protected] (Max Cai)

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
Extension.PrimitiveExtension<M extends ExtendableMessageNano<M>, T>

Represents an extension of a primitive (including enum) type.

Field Summary

Modifier and TypeField and Description
protected final Class<T>
clazz

Java type of this extension.

protected final boolean
repeated

Whether this extension is repeated.

public final int
tag

Tag number of this extension.

protected final int
type

Protocol Buffer type of this extension; one of the TYPE_ constants.

public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int

Constructor Summary

AccessConstructor and Description
private
Extension(int type, Class<T> clazz, int tag, boolean repeated)

Method Summary

Modifier and TypeMethod and Description
protected int
pack-priv int
protected int
public static <M extends ExtendableMessageNano<M>, T extends MessageNano> Extension<M, T>
createMessageTyped(int type, Class<T> clazz, int tag)

Deprecated use createMessageTyped(int, Class, long) instead.
Creates an Extension of the given message type and tag number.
public static <M extends ExtendableMessageNano<M>, T extends MessageNano> Extension<M, T>
createMessageTyped(int type, Class<T> clazz, long tag)

Creates an Extension of the given message type and tag number.

public static <M extends ExtendableMessageNano<M>, T> Extension<M, T>
createPrimitiveTyped(int
one of TYPE_*, except TYPE_MESSAGE and TYPE_GROUP
type
,
Class<T>
the boxed Java type of this extension
clazz
,
long tag)

Creates an Extension of the given primitive type and tag number.

public static <M extends ExtendableMessageNano<M>, T extends MessageNano> Extension<M, T[]>
createRepeatedMessageTyped(int type, Class<T[]> clazz, long tag)

Creates a repeated Extension of the given message type and tag number.

public static <M extends ExtendableMessageNano<M>, T> Extension<M, T>
createRepeatedPrimitiveTyped(int
one of TYPE_*, except TYPE_MESSAGE and TYPE_GROUP
type
,
Class<T>
the Java array type of this extension, with an unboxed component type
clazz
,
long tag, long nonPackedTag, long packedTag)

Creates a repeated Extension of the given primitive type and tag number.

private T
private T
pack-priv final T
getValueFrom(List<UnknownFieldData>
a list of UnknownFieldData. All of the elements must have a tag that matches this Extension's tag.
unknownFields
)

Returns the value of this extension stored in the given list of unknown fields, or null if no unknown fields matches this extension.

protected Object
protected void
protected void
protected void
pack-priv void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

clazzback to summary
protected final Class<T> clazz

Java type of this extension. For a singular extension, this is the boxed Java type for the Protocol Buffer type; for a repeated extension, this is an array type whose component type is the unboxed Java type for type. For example, for a singular int32/TYPE_INT32 extension, this equals Integer.class; for a repeated int32 extension, this equals int[].class.

repeatedback to summary
protected final boolean repeated

Whether this extension is repeated.

tagback to summary
public final int tag

Tag number of this extension. The data should be viewed as an unsigned 32-bit value.

typeback to summary
protected final int type

Protocol Buffer type of this extension; one of the TYPE_ constants.

TYPE_BOOLback to summary
public static final int TYPE_BOOL
TYPE_BYTESback to summary
public static final int TYPE_BYTES
TYPE_DOUBLEback to summary
public static final int TYPE_DOUBLE
TYPE_ENUMback to summary
public static final int TYPE_ENUM
TYPE_FIXED32back to summary
public static final int TYPE_FIXED32
TYPE_FIXED64back to summary
public static final int TYPE_FIXED64
TYPE_FLOATback to summary
public static final int TYPE_FLOAT
TYPE_GROUPback to summary
public static final int TYPE_GROUP
TYPE_INT32back to summary
public static final int TYPE_INT32
TYPE_INT64back to summary
public static final int TYPE_INT64
TYPE_MESSAGEback to summary
public static final int TYPE_MESSAGE
TYPE_SFIXED32back to summary
public static final int TYPE_SFIXED32
TYPE_SFIXED64back to summary
public static final int TYPE_SFIXED64
TYPE_SINT32back to summary
public static final int TYPE_SINT32
TYPE_SINT64back to summary
public static final int TYPE_SINT64
TYPE_STRINGback to summary
public static final int TYPE_STRING
TYPE_UINT32back to summary
public static final int TYPE_UINT32
TYPE_UINT64back to summary
public static final int TYPE_UINT64

Constructor Detail

Extensionback to summary
private Extension(int type, Class<T> clazz, int tag, boolean repeated)

Method Detail

computeRepeatedSerializedSizeback to summary
protected int computeRepeatedSerializedSize(Object array)
computeSerializedSizeback to summary
pack-priv int computeSerializedSize(Object value)
computeSingularSerializedSizeback to summary
protected int computeSingularSerializedSize(Object value)
createMessageTypedback to summary
public static <M extends ExtendableMessageNano<M>, T extends MessageNano> Extension<M, T> createMessageTyped(int type, Class<T> clazz, int tag)

Deprecated

use createMessageTyped(int, Class, long) instead.

Creates an Extension of the given message type and tag number. Should be used by the generated code only.

Parameters
type:int

TYPE_MESSAGE or TYPE_GROUP

Annotations
@Deprecated
createMessageTypedback to summary
public static <M extends ExtendableMessageNano<M>, T extends MessageNano> Extension<M, T> createMessageTyped(int type, Class<T> clazz, long tag)

Creates an Extension of the given message type and tag number. Should be used by the generated code only.

Parameters
type:int

TYPE_MESSAGE or TYPE_GROUP

createPrimitiveTypedback to summary
public static <M extends ExtendableMessageNano<M>, T> Extension<M, T> createPrimitiveTyped(int type, Class<T> clazz, long tag)

Creates an Extension of the given primitive type and tag number. Should be used by the generated code only.

Parameters
type:int

one of TYPE_*, except TYPE_MESSAGE and TYPE_GROUP

clazz:Class<T>

the boxed Java type of this extension

createRepeatedMessageTypedback to summary
public static <M extends ExtendableMessageNano<M>, T extends MessageNano> Extension<M, T[]> createRepeatedMessageTyped(int type, Class<T[]> clazz, long tag)

Creates a repeated Extension of the given message type and tag number. Should be used by the generated code only.

Parameters
type:int

TYPE_MESSAGE or TYPE_GROUP

createRepeatedPrimitiveTypedback to summary
public static <M extends ExtendableMessageNano<M>, T> Extension<M, T> createRepeatedPrimitiveTyped(int type, Class<T> clazz, long tag, long nonPackedTag, long packedTag)

Creates a repeated Extension of the given primitive type and tag number. Should be used by the generated code only.

Parameters
type:int

one of TYPE_*, except TYPE_MESSAGE and TYPE_GROUP

clazz:Class<T>

the Java array type of this extension, with an unboxed component type

getRepeatedValueFromback to summary
private T getRepeatedValueFrom(List<UnknownFieldData> unknownFields)
getSingularValueFromback to summary
private T getSingularValueFrom(List<UnknownFieldData> unknownFields)
getValueFromback to summary
pack-priv final T getValueFrom(List<UnknownFieldData> unknownFields)

Returns the value of this extension stored in the given list of unknown fields, or null if no unknown fields matches this extension.

Parameters
unknownFields:List<UnknownFieldData>

a list of UnknownFieldData. All of the elements must have a tag that matches this Extension's tag.

readDataback to summary
protected Object readData(CodedInputByteBufferNano input)
readDataIntoback to summary
protected void readDataInto(UnknownFieldData data, List<Object> resultList)
writeRepeatedDataback to summary
protected void writeRepeatedData(Object array, CodedOutputByteBufferNano output)
writeSingularDataback to summary
protected void writeSingularData(Object value, CodedOutputByteBufferNano out)
writeToback to summary
pack-priv void writeTo(Object value, CodedOutputByteBufferNano output) throws IOException
com.google.protobuf.nano back to summary

private Class Extension.PrimitiveExtension<M extends com.google.protobuf.nano.ExtendableMessageNano<M>, T>

extends Extension<M extends ExtendableMessageNano<M>, T>
Class Inheritance

Represents an extension of a primitive (including enum) type. If there is no primitive extensions, this subclass will be removable by ProGuard.

Field Summary

Modifier and TypeField and Description
private final int
nonPackedTag

Tag of a piece of non-packed data from the wire compatible with this extension.

private final int
packedTag

Tag of a piece of packed data from the wire compatible with this extension.

Inherited from com.google.protobuf.nano.Extension:
clazzrepeatedtagtypeTYPE_BOOLTYPE_BYTESTYPE_DOUBLETYPE_ENUMTYPE_FIXED32TYPE_FIXED64TYPE_FLOATTYPE_GROUPTYPE_INT32TYPE_INT64TYPE_MESSAGETYPE_SFIXED32TYPE_SFIXED64TYPE_SINT32TYPE_SINT64TYPE_STRINGTYPE_UINT32TYPE_UINT64

Constructor Summary

AccessConstructor and Description
public
PrimitiveExtension(int type, Class<T> clazz, int tag, boolean repeated, int nonPackedTag, int packedTag)

Method Summary

Modifier and TypeMethod and Description
private int
protected int
protected final int
protected Object
protected void
protected void
protected final void
Inherited from com.google.protobuf.nano.Extension:
computeSerializedSizecreateMessageTypedcreateMessageTypedcreatePrimitiveTypedcreateRepeatedMessageTypedcreateRepeatedPrimitiveTypedgetValueFromwriteTo

Field Detail

nonPackedTagback to summary
private final int nonPackedTag

Tag of a piece of non-packed data from the wire compatible with this extension.

packedTagback to summary
private final int packedTag

Tag of a piece of packed data from the wire compatible with this extension. 0 if the type of this extension is not packable.

Constructor Detail

PrimitiveExtensionback to summary
public PrimitiveExtension(int type, Class<T> clazz, int tag, boolean repeated, int nonPackedTag, int packedTag)

Method Detail

computePackedDataSizeback to summary
private int computePackedDataSize(Object array)
computeRepeatedSerializedSizeback to summary
protected int computeRepeatedSerializedSize(Object array)

Overrides com.google.protobuf.nano.Extension.computeRepeatedSerializedSize.

Annotations
@Override
computeSingularSerializedSizeback to summary
protected final int computeSingularSerializedSize(Object value)

Overrides com.google.protobuf.nano.Extension.computeSingularSerializedSize.

Annotations
@Override
readDataback to summary
protected Object readData(CodedInputByteBufferNano input)

Overrides com.google.protobuf.nano.Extension.readData.

Annotations
@Override
readDataIntoback to summary
protected void readDataInto(UnknownFieldData data, List<Object> resultList)

Overrides com.google.protobuf.nano.Extension.readDataInto.

Annotations
@Override
writeRepeatedDataback to summary
protected void writeRepeatedData(Object array, CodedOutputByteBufferNano output)

Overrides com.google.protobuf.nano.Extension.writeRepeatedData.

Annotations
@Override
writeSingularDataback to summary
protected final void writeSingularData(Object value, CodedOutputByteBufferNano output)

Overrides com.google.protobuf.nano.Extension.writeSingularData.

Annotations
@Override