Classes | Static Public Member Functions | Static Public Attributes | Private Member Functions | Static Private Attributes | List of all members
com.google.protobuf.Internal Class Reference

Classes

interface  BooleanList
 
interface  DoubleList
 
interface  EnumLite
 
interface  EnumLiteMap
 
interface  EnumLiteMap
 
interface  EnumVerifier
 
interface  FloatList
 
interface  IntList
 
class  ListAdapter
 
class  ListAdapter
 
interface  LongList
 
class  MapAdapter
 
class  MapAdapter
 
interface  ProtobufList
 
interface  ProtobufList
 

Static Public Member Functions

static byte[] byteArrayDefaultValue (String bytes)
 
static byte[] byteArrayDefaultValue (String bytes)
 
static ByteBuffer byteBufferDefaultValue (String bytes)
 
static ByteBuffer byteBufferDefaultValue (String bytes)
 
static ByteString bytesDefaultValue (String bytes)
 
static ByteString bytesDefaultValue (String bytes)
 
static ByteBuffer copyByteBuffer (ByteBuffer source)
 
static ByteBuffer copyByteBuffer (ByteBuffer source)
 
static boolean equals (List< byte[]> a, List< byte[]> b)
 
static boolean equals (List< byte[]> a, List< byte[]> b)
 
static boolean equalsByteBuffer (ByteBuffer a, ByteBuffer b)
 
static boolean equalsByteBuffer (ByteBuffer a, ByteBuffer b)
 
static boolean equalsByteBuffer (List< ByteBuffer > a, List< ByteBuffer > b)
 
static boolean equalsByteBuffer (List< ByteBuffer > a, List< ByteBuffer > b)
 
static< T extends MessageLite > T getDefaultInstance (Class< T > clazz)
 
static< T extends MessageLite > T getDefaultInstance (Class< T > clazz)
 
static int hashBoolean (boolean b)
 
static int hashBoolean (boolean b)
 
static int hashCode (byte[] bytes)
 
static int hashCode (byte[] bytes)
 
static int hashCode (List< byte[]> list)
 
static int hashCode (List< byte[]> list)
 
static int hashCodeByteBuffer (ByteBuffer bytes)
 
static int hashCodeByteBuffer (ByteBuffer bytes)
 
static int hashCodeByteBuffer (List< ByteBuffer > list)
 
static int hashCodeByteBuffer (List< ByteBuffer > list)
 
static int hashEnum (EnumLite e)
 
static int hashEnum (EnumLite e)
 
static int hashEnumList (List<? extends EnumLite > list)
 
static int hashEnumList (List<? extends EnumLite > list)
 
static int hashLong (long n)
 
static int hashLong (long n)
 
static boolean isValidUtf8 (byte[] byteArray)
 
static boolean isValidUtf8 (byte[] byteArray)
 
static boolean isValidUtf8 (ByteString byteString)
 
static boolean isValidUtf8 (ByteString byteString)
 
static String stringDefaultValue (String bytes)
 
static String stringDefaultValue (String bytes)
 
static byte[] toByteArray (String value)
 
static byte[] toByteArray (String value)
 
static String toStringUtf8 (byte[] bytes)
 
static String toStringUtf8 (byte[] bytes)
 

Static Public Attributes

static final byte[] EMPTY_BYTE_ARRAY = new byte[0]
 
static final ByteBuffer EMPTY_BYTE_BUFFER = ByteBuffer.wrap(EMPTY_BYTE_ARRAY)
 
static final CodedInputStream EMPTY_CODED_INPUT_STREAM
 

Private Member Functions

 Internal ()
 
 Internal ()
 

Static Private Attributes

static final int DEFAULT_BUFFER_SIZE = 4096
 

Detailed Description

The classes contained within are used internally by the Protocol Buffer library and generated message implementations. They are public only because those generated messages do not reside in the

package. Others should not use this class directly.

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

Definition at line 54 of file bloaty/third_party/protobuf/java/core/src/main/java/com/google/protobuf/Internal.java.

Constructor & Destructor Documentation

◆ Internal() [1/2]

com.google.protobuf.Internal.Internal ( )
inlineprivate

◆ Internal() [2/2]

com.google.protobuf.Internal.Internal ( )
inlineprivate

Member Function Documentation

◆ byteArrayDefaultValue() [1/2]

static byte [] com.google.protobuf.Internal.byteArrayDefaultValue ( String  bytes)
inlinestatic

Helper called by generated code to construct default values for bytes fields.

This is like bytesDefaultValue, but returns a byte array.

Definition at line 118 of file bloaty/third_party/protobuf/java/core/src/main/java/com/google/protobuf/Internal.java.

◆ byteArrayDefaultValue() [2/2]

static byte [] com.google.protobuf.Internal.byteArrayDefaultValue ( String  bytes)
inlinestatic

Helper called by generated code to construct default values for bytes fields.

This is like bytesDefaultValue, but returns a byte array.

Definition at line 118 of file protobuf/java/core/src/main/java/com/google/protobuf/Internal.java.

◆ byteBufferDefaultValue() [1/2]

static ByteBuffer com.google.protobuf.Internal.byteBufferDefaultValue ( String  bytes)
inlinestatic

Helper called by generated code to construct default values for bytes fields.

This is like bytesDefaultValue, but returns a ByteBuffer.

Definition at line 127 of file bloaty/third_party/protobuf/java/core/src/main/java/com/google/protobuf/Internal.java.

◆ byteBufferDefaultValue() [2/2]

static ByteBuffer com.google.protobuf.Internal.byteBufferDefaultValue ( String  bytes)
inlinestatic

Helper called by generated code to construct default values for bytes fields.

This is like bytesDefaultValue, but returns a ByteBuffer.

Definition at line 127 of file protobuf/java/core/src/main/java/com/google/protobuf/Internal.java.

◆ bytesDefaultValue() [1/2]

static ByteString com.google.protobuf.Internal.bytesDefaultValue ( String  bytes)
inlinestatic

Helper called by generated code to construct default values for bytes fields.

This is a lot like stringDefaultValue, but for bytes fields. In this case we only need the second of the two hacks – allowing us to embed raw bytes as a string literal with ISO-8859-1 encoding.

Definition at line 110 of file protobuf/java/core/src/main/java/com/google/protobuf/Internal.java.

◆ bytesDefaultValue() [2/2]

static ByteString com.google.protobuf.Internal.bytesDefaultValue ( String  bytes)
inlinestatic

Helper called by generated code to construct default values for bytes fields.

This is a lot like stringDefaultValue, but for bytes fields. In this case we only need the second of the two hacks – allowing us to embed raw bytes as a string literal with ISO-8859-1 encoding.

Definition at line 110 of file bloaty/third_party/protobuf/java/core/src/main/java/com/google/protobuf/Internal.java.

◆ copyByteBuffer() [1/2]

static ByteBuffer com.google.protobuf.Internal.copyByteBuffer ( ByteBuffer  source)
inlinestatic

Create a new ByteBuffer and copy all the content of

source

ByteBuffer to the new ByteBuffer. The new ByteBuffer's limit and capacity will be source.capacity(), and its position will be 0. Note that the state of

source

ByteBuffer won't be changed.

Definition at line 136 of file bloaty/third_party/protobuf/java/core/src/main/java/com/google/protobuf/Internal.java.

◆ copyByteBuffer() [2/2]

static ByteBuffer com.google.protobuf.Internal.copyByteBuffer ( ByteBuffer  source)
inlinestatic

Create a new ByteBuffer and copy all the content of

source

ByteBuffer to the new ByteBuffer. The new ByteBuffer's limit and capacity will be source.capacity(), and its position will be 0. Note that the state of

source

ByteBuffer won't be changed.

Definition at line 136 of file protobuf/java/core/src/main/java/com/google/protobuf/Internal.java.

◆ equals() [1/2]

static boolean com.google.protobuf.Internal.equals ( List< byte[]>  a,
List< byte[]>  b 
)
inlinestatic

Helper method for implementing Message#equals(Object) for bytes field.

Definition at line 258 of file protobuf/java/core/src/main/java/com/google/protobuf/Internal.java.

◆ equals() [2/2]

static boolean com.google.protobuf.Internal.equals ( List< byte[]>  a,
List< byte[]>  b 
)
inlinestatic

Helper method for implementing Message#equals(Object) for bytes field.

Definition at line 258 of file bloaty/third_party/protobuf/java/core/src/main/java/com/google/protobuf/Internal.java.

◆ equalsByteBuffer() [1/4]

static boolean com.google.protobuf.Internal.equalsByteBuffer ( ByteBuffer  a,
ByteBuffer  b 
)
inlinestatic

Helper method for implementing Message#equals(Object) for bytes field.

Definition at line 305 of file bloaty/third_party/protobuf/java/core/src/main/java/com/google/protobuf/Internal.java.

◆ equalsByteBuffer() [2/4]

static boolean com.google.protobuf.Internal.equalsByteBuffer ( ByteBuffer  a,
ByteBuffer  b 
)
inlinestatic

Helper method for implementing Message#equals(Object) for bytes field.

Definition at line 305 of file protobuf/java/core/src/main/java/com/google/protobuf/Internal.java.

◆ equalsByteBuffer() [3/4]

static boolean com.google.protobuf.Internal.equalsByteBuffer ( List< ByteBuffer >  a,
List< ByteBuffer >  b 
)
inlinestatic

Helper method for implementing Message#equals(Object) for bytes field.

Definition at line 315 of file bloaty/third_party/protobuf/java/core/src/main/java/com/google/protobuf/Internal.java.

◆ equalsByteBuffer() [4/4]

static boolean com.google.protobuf.Internal.equalsByteBuffer ( List< ByteBuffer >  a,
List< ByteBuffer >  b 
)
inlinestatic

Helper method for implementing Message#equals(Object) for bytes field.

Definition at line 315 of file protobuf/java/core/src/main/java/com/google/protobuf/Internal.java.

◆ getDefaultInstance() [1/2]

static <T extends MessageLite> T com.google.protobuf.Internal.getDefaultInstance ( Class< T clazz)
inlinestatic

◆ getDefaultInstance() [2/2]

static <T extends MessageLite> T com.google.protobuf.Internal.getDefaultInstance ( Class< T clazz)
inlinestatic

◆ hashBoolean() [1/2]

static int com.google.protobuf.Internal.hashBoolean ( boolean  b)
inlinestatic

Helper method for implementing Message#hashCode() for booleans.

See also
Boolean::hashCode()

Definition at line 233 of file protobuf/java/core/src/main/java/com/google/protobuf/Internal.java.

◆ hashBoolean() [2/2]

static int com.google.protobuf.Internal.hashBoolean ( boolean  b)
inlinestatic

Helper method for implementing Message#hashCode() for booleans.

See also
Boolean::hashCode()

Definition at line 233 of file bloaty/third_party/protobuf/java/core/src/main/java/com/google/protobuf/Internal.java.

◆ hashCode() [1/4]

static int com.google.protobuf.Internal.hashCode ( byte[]  bytes)
inlinestatic

Helper method for implementing Message#hashCode() for bytes field.

Definition at line 278 of file bloaty/third_party/protobuf/java/core/src/main/java/com/google/protobuf/Internal.java.

◆ hashCode() [2/4]

static int com.google.protobuf.Internal.hashCode ( byte[]  bytes)
inlinestatic

Helper method for implementing Message#hashCode() for bytes field.

Definition at line 278 of file protobuf/java/core/src/main/java/com/google/protobuf/Internal.java.

◆ hashCode() [3/4]

static int com.google.protobuf.Internal.hashCode ( List< byte[]>  list)
inlinestatic

Helper method for implementing Message#hashCode() for bytes field.

Definition at line 269 of file protobuf/java/core/src/main/java/com/google/protobuf/Internal.java.

◆ hashCode() [4/4]

static int com.google.protobuf.Internal.hashCode ( List< byte[]>  list)
inlinestatic

Helper method for implementing Message#hashCode() for bytes field.

Definition at line 269 of file bloaty/third_party/protobuf/java/core/src/main/java/com/google/protobuf/Internal.java.

◆ hashCodeByteBuffer() [1/4]

static int com.google.protobuf.Internal.hashCodeByteBuffer ( ByteBuffer  bytes)
inlinestatic

Helper method for implementing Message#hashCode() for bytes field.

Definition at line 339 of file protobuf/java/core/src/main/java/com/google/protobuf/Internal.java.

◆ hashCodeByteBuffer() [2/4]

static int com.google.protobuf.Internal.hashCodeByteBuffer ( ByteBuffer  bytes)
inlinestatic

Helper method for implementing Message#hashCode() for bytes field.

Definition at line 339 of file bloaty/third_party/protobuf/java/core/src/main/java/com/google/protobuf/Internal.java.

◆ hashCodeByteBuffer() [3/4]

static int com.google.protobuf.Internal.hashCodeByteBuffer ( List< ByteBuffer >  list)
inlinestatic

Helper method for implementing Message#hashCode() for bytes field.

Definition at line 328 of file protobuf/java/core/src/main/java/com/google/protobuf/Internal.java.

◆ hashCodeByteBuffer() [4/4]

static int com.google.protobuf.Internal.hashCodeByteBuffer ( List< ByteBuffer >  list)
inlinestatic

Helper method for implementing Message#hashCode() for bytes field.

Definition at line 328 of file bloaty/third_party/protobuf/java/core/src/main/java/com/google/protobuf/Internal.java.

◆ hashEnum() [1/2]

static int com.google.protobuf.Internal.hashEnum ( EnumLite  e)
inlinestatic

Helper method for implementing Message#hashCode() for enums.

This is needed because java.lang.Enum#hashCode() is final, but we need to use the field number as the hash code to ensure compatibility between statically and dynamically generated enum objects.

Definition at line 244 of file bloaty/third_party/protobuf/java/core/src/main/java/com/google/protobuf/Internal.java.

◆ hashEnum() [2/2]

static int com.google.protobuf.Internal.hashEnum ( EnumLite  e)
inlinestatic

Helper method for implementing Message#hashCode() for enums.

This is needed because java.lang.Enum#hashCode() is final, but we need to use the field number as the hash code to ensure compatibility between statically and dynamically generated enum objects.

Definition at line 244 of file protobuf/java/core/src/main/java/com/google/protobuf/Internal.java.

◆ hashEnumList() [1/2]

static int com.google.protobuf.Internal.hashEnumList ( List<? extends EnumLite list)
inlinestatic

Helper method for implementing Message#hashCode() for enum lists.

Definition at line 249 of file protobuf/java/core/src/main/java/com/google/protobuf/Internal.java.

◆ hashEnumList() [2/2]

static int com.google.protobuf.Internal.hashEnumList ( List<? extends EnumLite list)
inlinestatic

Helper method for implementing Message#hashCode() for enum lists.

Definition at line 249 of file bloaty/third_party/protobuf/java/core/src/main/java/com/google/protobuf/Internal.java.

◆ hashLong() [1/2]

static int com.google.protobuf.Internal.hashLong ( long  n)
inlinestatic

Helper method for implementing Message#hashCode() for longs.

See also
Long::hashCode()

Definition at line 224 of file bloaty/third_party/protobuf/java/core/src/main/java/com/google/protobuf/Internal.java.

◆ hashLong() [2/2]

static int com.google.protobuf.Internal.hashLong ( long  n)
inlinestatic

Helper method for implementing Message#hashCode() for longs.

See also
Long::hashCode()

Definition at line 224 of file protobuf/java/core/src/main/java/com/google/protobuf/Internal.java.

◆ isValidUtf8() [1/4]

static boolean com.google.protobuf.Internal.isValidUtf8 ( byte[]  byteArray)
inlinestatic

◆ isValidUtf8() [2/4]

static boolean com.google.protobuf.Internal.isValidUtf8 ( byte[]  byteArray)
inlinestatic

◆ isValidUtf8() [3/4]

static boolean com.google.protobuf.Internal.isValidUtf8 ( ByteString  byteString)
inlinestatic

Helper called by generated code to determine if a byte array is a valid UTF-8 encoded string such that the original bytes can be converted to a String object and then back to a byte array round tripping the bytes without loss. More precisely, returns

true

whenever:

Arrays.equals(byteString.toByteArray(),
new String(byteString.toByteArray(), "UTF-8").getBytes("UTF-8"))

This method rejects "overlong" byte sequences, as well as 3-byte sequences that would map to a surrogate character, in accordance with the restricted definition of UTF-8 introduced in Unicode 3.1. Note that the UTF-8 decoder included in Oracle's JDK has been modified to also reject "overlong" byte sequences, but currently (2011) still accepts 3-byte surrogate character byte sequences.

See the Unicode Standard,
Table 3-6. UTF-8 Bit Distribution,
Table 3-7. Well Formed UTF-8 Byte Sequences.

As of 2011-02, this method simply returns the result of ByteString#isValidUtf8(). Calling that method directly is preferred.

Parameters
byteStringthe string to check
Returns
whether the byte array is round trippable

Definition at line 175 of file bloaty/third_party/protobuf/java/core/src/main/java/com/google/protobuf/Internal.java.

◆ isValidUtf8() [4/4]

static boolean com.google.protobuf.Internal.isValidUtf8 ( ByteString  byteString)
inlinestatic

Helper called by generated code to determine if a byte array is a valid UTF-8 encoded string such that the original bytes can be converted to a String object and then back to a byte array round tripping the bytes without loss. More precisely, returns

true

whenever:

Arrays.equals(byteString.toByteArray(),
new String(byteString.toByteArray(), "UTF-8").getBytes("UTF-8"))

This method rejects "overlong" byte sequences, as well as 3-byte sequences that would map to a surrogate character, in accordance with the restricted definition of UTF-8 introduced in Unicode 3.1. Note that the UTF-8 decoder included in Oracle's JDK has been modified to also reject "overlong" byte sequences, but currently (2011) still accepts 3-byte surrogate character byte sequences.

See the Unicode Standard,
Table 3-6. UTF-8 Bit Distribution,
Table 3-7. Well Formed UTF-8 Byte Sequences.

As of 2011-02, this method simply returns the result of ByteString#isValidUtf8(). Calling that method directly is preferred.

Parameters
byteStringthe string to check
Returns
whether the byte array is round trippable

Definition at line 175 of file protobuf/java/core/src/main/java/com/google/protobuf/Internal.java.

◆ stringDefaultValue() [1/2]

static String com.google.protobuf.Internal.stringDefaultValue ( String  bytes)
inlinestatic

Helper called by generated code to construct default values for string fields.

The protocol compiler does not actually contain a UTF-8 decoder – it just pushes UTF-8-encoded text around without touching it. The one place where this presents a problem is when generating Java string literals. Unicode characters in the string literal would normally need to be encoded using a Unicode escape sequence, which would require decoding them. To get around this, protoc instead embeds the UTF-8 bytes into the generated code and leaves it to the runtime library to decode them.

It gets worse, though. If protoc just generated a byte array, like: new byte[] {0x12, 0x34, 0x56, 0x78} Java actually generates code which allocates an array and then fills in each value. This is much less efficient than just embedding the bytes directly into the bytecode. To get around this, we need another work-around. String literals are embedded directly, so protoc actually generates a string literal corresponding to the bytes. The easiest way to do this is to use the ISO-8859-1 character set, which corresponds to the first 256 characters of the Unicode range. Protoc can then use good old CEscape to generate the string.

So we have a string literal which represents a set of bytes which represents another string. This function – stringDefaultValue – converts from the generated string to the string we actually want. The generated code calls this automatically.

Definition at line 99 of file protobuf/java/core/src/main/java/com/google/protobuf/Internal.java.

◆ stringDefaultValue() [2/2]

static String com.google.protobuf.Internal.stringDefaultValue ( String  bytes)
inlinestatic

Helper called by generated code to construct default values for string fields.

The protocol compiler does not actually contain a UTF-8 decoder – it just pushes UTF-8-encoded text around without touching it. The one place where this presents a problem is when generating Java string literals. Unicode characters in the string literal would normally need to be encoded using a Unicode escape sequence, which would require decoding them. To get around this, protoc instead embeds the UTF-8 bytes into the generated code and leaves it to the runtime library to decode them.

It gets worse, though. If protoc just generated a byte array, like: new byte[] {0x12, 0x34, 0x56, 0x78} Java actually generates code which allocates an array and then fills in each value. This is much less efficient than just embedding the bytes directly into the bytecode. To get around this, we need another work-around. String literals are embedded directly, so protoc actually generates a string literal corresponding to the bytes. The easiest way to do this is to use the ISO-8859-1 character set, which corresponds to the first 256 characters of the Unicode range. Protoc can then use good old CEscape to generate the string.

So we have a string literal which represents a set of bytes which represents another string. This function – stringDefaultValue – converts from the generated string to the string we actually want. The generated code calls this automatically.

Definition at line 99 of file bloaty/third_party/protobuf/java/core/src/main/java/com/google/protobuf/Internal.java.

◆ toByteArray() [1/2]

static byte [] com.google.protobuf.Internal.toByteArray ( String  value)
inlinestatic

Helper method to get the UTF-8 bytes of a string.

Definition at line 185 of file bloaty/third_party/protobuf/java/core/src/main/java/com/google/protobuf/Internal.java.

◆ toByteArray() [2/2]

static byte [] com.google.protobuf.Internal.toByteArray ( String  value)
inlinestatic

Helper method to get the UTF-8 bytes of a string.

Definition at line 185 of file protobuf/java/core/src/main/java/com/google/protobuf/Internal.java.

◆ toStringUtf8() [1/2]

static String com.google.protobuf.Internal.toStringUtf8 ( byte[]  bytes)
inlinestatic

Helper method to convert a byte array to a string using UTF-8 encoding.

Definition at line 190 of file bloaty/third_party/protobuf/java/core/src/main/java/com/google/protobuf/Internal.java.

◆ toStringUtf8() [2/2]

static String com.google.protobuf.Internal.toStringUtf8 ( byte[]  bytes)
inlinestatic

Helper method to convert a byte array to a string using UTF-8 encoding.

Definition at line 190 of file protobuf/java/core/src/main/java/com/google/protobuf/Internal.java.

Member Data Documentation

◆ DEFAULT_BUFFER_SIZE

static final int com.google.protobuf.Internal.DEFAULT_BUFFER_SIZE = 4096
staticprivate

◆ EMPTY_BYTE_ARRAY

final byte [] com.google.protobuf.Internal.EMPTY_BYTE_ARRAY = new byte[0]
static

An empty byte array constant used in generated code.

Definition at line 375 of file bloaty/third_party/protobuf/java/core/src/main/java/com/google/protobuf/Internal.java.

◆ EMPTY_BYTE_BUFFER

static final ByteBuffer com.google.protobuf.Internal.EMPTY_BYTE_BUFFER = ByteBuffer.wrap(EMPTY_BYTE_ARRAY)
static

An empty byte array constant used in generated code.

Definition at line 378 of file bloaty/third_party/protobuf/java/core/src/main/java/com/google/protobuf/Internal.java.

◆ EMPTY_CODED_INPUT_STREAM

static final CodedInputStream com.google.protobuf.Internal.EMPTY_CODED_INPUT_STREAM
static
Initial value:

An empty coded input stream constant used in generated code.

Definition at line 381 of file bloaty/third_party/protobuf/java/core/src/main/java/com/google/protobuf/Internal.java.


The documentation for this class was generated from the following file:
com.google.protobuf.Internal.EMPTY_BYTE_ARRAY
static final byte[] EMPTY_BYTE_ARRAY
Definition: bloaty/third_party/protobuf/java/core/src/main/java/com/google/protobuf/Internal.java:375
google::protobuf
Definition: bloaty/third_party/protobuf/benchmarks/util/data_proto2_to_proto3_util.h:12
grpc::protobuf::io::CodedInputStream
GRPC_CUSTOM_CODEDINPUTSTREAM CodedInputStream
Definition: include/grpcpp/impl/codegen/config_protobuf.h:102


grpc
Author(s):
autogenerated on Fri May 16 2025 03:03:06