webkit
2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
|
Classes | |
interface | BooleanList |
interface | DoubleList |
interface | EnumLite |
interface | EnumLiteMap |
interface | FloatList |
interface | IntList |
class | ListAdapter |
interface | LongList |
class | MapAdapter |
interface | ProtobufList |
Static Public Member Functions | |
static String | stringDefaultValue (String bytes) |
static ByteString | bytesDefaultValue (String bytes) |
static byte [] | byteArrayDefaultValue (String bytes) |
static ByteBuffer | byteBufferDefaultValue (String bytes) |
static ByteBuffer | copyByteBuffer (ByteBuffer source) |
static boolean | isValidUtf8 (ByteString byteString) |
static boolean | isValidUtf8 (byte[] byteArray) |
static byte [] | toByteArray (String value) |
static String | toStringUtf8 (byte[] bytes) |
static int | hashLong (long n) |
static int | hashBoolean (boolean b) |
static int | hashEnum (EnumLite e) |
static int | hashEnumList (List<? extends EnumLite > list) |
static boolean | equals (List< byte[]> a, List< byte[]> b) |
static int | hashCode (List< byte[]> list) |
static int | hashCode (byte[] bytes) |
static boolean | equalsByteBuffer (ByteBuffer a, ByteBuffer b) |
static boolean | equalsByteBuffer (List< ByteBuffer > a, List< ByteBuffer > b) |
static int | hashCodeByteBuffer (List< ByteBuffer > list) |
static int | hashCodeByteBuffer (ByteBuffer bytes) |
static< T extends MessageLite > T | getDefaultInstance (Class< T > clazz) |
Static Public Attributes | |
static final byte [] | EMPTY_BYTE_ARRAY = new byte[0] |
static final ByteBuffer | EMPTY_BYTE_BUFFER |
static final CodedInputStream | EMPTY_CODED_INPUT_STREAM |
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.
|
inlinestatic |
Helper called by generated code to construct default values for bytes fields.
This is like bytesDefaultValue, but returns a byte array.
|
inlinestatic |
Helper called by generated code to construct default values for bytes fields.
This is like bytesDefaultValue, but returns a ByteBuffer.
|
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.
|
inlinestatic |
|
inlinestatic |
Helper method for implementing Message#equals(Object) for bytes field.
|
inlinestatic |
Helper method for implementing Message#equals(Object) for bytes field.
|
inlinestatic |
Helper method for implementing Message#equals(Object) for bytes field.
|
inlinestatic |
|
inlinestatic |
Helper method for implementing Message#hashCode() for booleans.
|
inlinestatic |
Helper method for implementing Message#hashCode() for bytes field.
|
inlinestatic |
Helper method for implementing Message#hashCode() for bytes field.
|
inlinestatic |
Helper method for implementing Message#hashCode() for bytes field.
|
inlinestatic |
Helper method for implementing Message#hashCode() for bytes field.
|
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.
|
inlinestatic |
Helper method for implementing Message#hashCode() for enum lists.
|
inlinestatic |
Helper method for implementing Message#hashCode() for longs.
|
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
whenever:
Arrays.equals(byteString.toByteArray(),
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.
byteString | the string to check |
|
inlinestatic |
Like isValidUtf8(ByteString) but for byte arrays.
|
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.
|
inlinestatic |
Helper method to get the UTF-8 bytes of a string.
|
inlinestatic |
Helper method to convert a byte array to a string using UTF-8 encoding.
An empty byte array constant used in generated code.
|
static |
An empty byte array constant used in generated code.
|
static |
An empty coded input stream constant used in generated code.