Package io.protostuff
Class StringSerializer
java.lang.Object
io.protostuff.StringSerializer
UTF-8 String serialization
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final char[]
(package private) static final char[]
(package private) static final char[]
(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final byte[]
(package private) static final byte[]
(package private) static final int
(package private) static final int[]
(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic int
computeUTF8Size
(CharSequence str, int index, int len) Computes the size of the utf8 string beginning at the specifiedindex
with the specifiedlength
.static char
highSurrogate
(int codePoint) static char
lowSurrogate
(int codePoint) (package private) static void
putBytesFromInt
(int i, int offset, int size, byte[] buf) (package private) static void
putBytesFromLong
(long i, int offset, int size, byte[] buf) (package private) static int
stringSize
(int x) (package private) static int
stringSize
(long x) static LinkedBuffer
writeAscii
(CharSequence str, WriteSession session, LinkedBuffer lb) Writes the ascii bytes from the string into theLinkedBuffer
.static LinkedBuffer
writeDouble
(double value, WriteSession session, LinkedBuffer lb) Writes the stringified double into theLinkedBuffer
.(package private) static void
writeFixed2ByteInt
(int value, byte[] buffer, int offset, boolean littleEndian) static LinkedBuffer
writeFloat
(float value, WriteSession session, LinkedBuffer lb) Writes the stringified float into theLinkedBuffer
.static LinkedBuffer
writeInt
(int value, WriteSession session, LinkedBuffer lb) Writes the stringified int into theLinkedBuffer
.static LinkedBuffer
writeLong
(long value, WriteSession session, LinkedBuffer lb) Writes the stringified long into theLinkedBuffer
.(package private) static LinkedBuffer
writeUTF8
(CharSequence str, int i, int len, byte[] buffer, int offset, int limit, WriteSession session, LinkedBuffer lb) Slow path.(package private) static LinkedBuffer
writeUTF8
(CharSequence str, int i, int len, WriteSession session, LinkedBuffer lb) Fast path.static LinkedBuffer
writeUTF8
(CharSequence str, WriteSession session, LinkedBuffer lb) Writes the utf8-encoded bytes from the string into theLinkedBuffer
.static LinkedBuffer
writeUTF8FixedDelimited
(CharSequence str, boolean littleEndian, WriteSession session, LinkedBuffer lb) The length of the utf8 bytes is written first before the string - which is fixed 2-bytes.static LinkedBuffer
writeUTF8FixedDelimited
(CharSequence str, WriteSession session, LinkedBuffer lb) The length of the utf8 bytes is written first (big endian) before the string - which is fixed 2-bytes.private static LinkedBuffer
writeUTF8OneByteDelimited
(CharSequence str, int index, int len, WriteSession session, LinkedBuffer lb) private static LinkedBuffer
writeUTF8VarDelimited
(CharSequence str, int index, int len, int lowerLimit, int expectedSize, WriteSession session, LinkedBuffer lb) static LinkedBuffer
writeUTF8VarDelimited
(CharSequence str, WriteSession session, LinkedBuffer lb) The length of the utf8 bytes is written first before the string - which is a variable int (1 to 5 bytes).
-
Field Details
-
sizeTable
static final int[] sizeTable -
DigitTens
static final char[] DigitTens -
DigitOnes
static final char[] DigitOnes -
digits
static final char[] digits -
INT_MIN_VALUE
static final byte[] INT_MIN_VALUE -
LONG_MIN_VALUE
static final byte[] LONG_MIN_VALUE -
TWO_BYTE_LOWER_LIMIT
static final int TWO_BYTE_LOWER_LIMIT- See Also:
-
ONE_BYTE_EXCLUSIVE
static final int ONE_BYTE_EXCLUSIVE- See Also:
-
THREE_BYTE_LOWER_LIMIT
static final int THREE_BYTE_LOWER_LIMIT- See Also:
-
TWO_BYTE_EXCLUSIVE
static final int TWO_BYTE_EXCLUSIVE- See Also:
-
FOUR_BYTE_LOWER_LIMIT
static final int FOUR_BYTE_LOWER_LIMIT- See Also:
-
THREE_BYTE_EXCLUSIVE
static final int THREE_BYTE_EXCLUSIVE- See Also:
-
FIVE_BYTE_LOWER_LIMIT
static final int FIVE_BYTE_LOWER_LIMIT- See Also:
-
FOUR_BYTE_EXCLUSIVE
static final int FOUR_BYTE_EXCLUSIVE- See Also:
-
-
Constructor Details
-
StringSerializer
private StringSerializer()
-
-
Method Details
-
putBytesFromInt
static void putBytesFromInt(int i, int offset, int size, byte[] buf) -
putBytesFromLong
static void putBytesFromLong(long i, int offset, int size, byte[] buf) -
stringSize
static int stringSize(int x) -
stringSize
static int stringSize(long x) -
writeInt
Writes the stringified int into theLinkedBuffer
. -
writeLong
Writes the stringified long into theLinkedBuffer
. -
writeFloat
Writes the stringified float into theLinkedBuffer
. TODO - skip string conversion and write directly to buffer -
writeDouble
Writes the stringified double into theLinkedBuffer
. TODO - skip string conversion and write directly to buffer -
computeUTF8Size
Computes the size of the utf8 string beginning at the specifiedindex
with the specifiedlength
. -
writeUTF8
static LinkedBuffer writeUTF8(CharSequence str, int i, int len, byte[] buffer, int offset, int limit, WriteSession session, LinkedBuffer lb) Slow path. It checks the limit before every write. Shared with StreamedStringSerializer. -
writeUTF8
static LinkedBuffer writeUTF8(CharSequence str, int i, int len, WriteSession session, LinkedBuffer lb) Fast path. TheLinkedBuffer
's capacity is >= string length. -
writeUTF8
Writes the utf8-encoded bytes from the string into theLinkedBuffer
. -
writeAscii
Writes the ascii bytes from the string into theLinkedBuffer
. It is the responsibility of the caller to know in advance that the string is 100% ascii. E.g if you convert a double/float to a string, you are sure it only contains ascii chars. -
writeFixed2ByteInt
static void writeFixed2ByteInt(int value, byte[] buffer, int offset, boolean littleEndian) -
writeUTF8FixedDelimited
public static LinkedBuffer writeUTF8FixedDelimited(CharSequence str, WriteSession session, LinkedBuffer lb) The length of the utf8 bytes is written first (big endian) before the string - which is fixed 2-bytes. Same behavior asDataOutputStream.writeUTF(String)
. -
writeUTF8FixedDelimited
public static LinkedBuffer writeUTF8FixedDelimited(CharSequence str, boolean littleEndian, WriteSession session, LinkedBuffer lb) The length of the utf8 bytes is written first before the string - which is fixed 2-bytes. -
writeUTF8OneByteDelimited
private static LinkedBuffer writeUTF8OneByteDelimited(CharSequence str, int index, int len, WriteSession session, LinkedBuffer lb) -
writeUTF8VarDelimited
private static LinkedBuffer writeUTF8VarDelimited(CharSequence str, int index, int len, int lowerLimit, int expectedSize, WriteSession session, LinkedBuffer lb) -
writeUTF8VarDelimited
public static LinkedBuffer writeUTF8VarDelimited(CharSequence str, WriteSession session, LinkedBuffer lb) The length of the utf8 bytes is written first before the string - which is a variable int (1 to 5 bytes). -
highSurrogate
public static char highSurrogate(int codePoint) -
lowSurrogate
public static char lowSurrogate(int codePoint)
-