Package io.protostuff
Class StreamedStringSerializer
java.lang.Object
io.protostuff.StreamedStringSerializer
UTF-8 String serialization
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static void
flushAndReset
(LinkedBuffer node, WriteSession session) 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
.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
.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).
-
Constructor Details
-
StreamedStringSerializer
private StreamedStringSerializer()
-
-
Method Details
-
writeInt
public static LinkedBuffer writeInt(int value, WriteSession session, LinkedBuffer lb) throws IOException Writes the stringified int into theLinkedBuffer
.- Throws:
IOException
-
writeLong
public static LinkedBuffer writeLong(long value, WriteSession session, LinkedBuffer lb) throws IOException Writes the stringified long into theLinkedBuffer
.- Throws:
IOException
-
writeFloat
public static LinkedBuffer writeFloat(float value, WriteSession session, LinkedBuffer lb) throws IOException Writes the stringified float into theLinkedBuffer
. TODO - skip string conversion and write directly to buffer- Throws:
IOException
-
writeDouble
public static LinkedBuffer writeDouble(double value, WriteSession session, LinkedBuffer lb) throws IOException Writes the stringified double into theLinkedBuffer
. TODO - skip string conversion and write directly to buffer- Throws:
IOException
-
writeUTF8
public static LinkedBuffer writeUTF8(CharSequence str, WriteSession session, LinkedBuffer lb) throws IOException Writes the utf8-encoded bytes from the string into theLinkedBuffer
.- Throws:
IOException
-
writeAscii
public static LinkedBuffer writeAscii(CharSequence str, WriteSession session, LinkedBuffer lb) throws IOException 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.- Throws:
IOException
-
flushAndReset
- Throws:
IOException
-
writeUTF8FixedDelimited
public static LinkedBuffer writeUTF8FixedDelimited(CharSequence str, WriteSession session, LinkedBuffer lb) throws IOException The length of the utf8 bytes is written first (big endian) before the string - which is fixed 2-bytes. Same behavior asDataOutputStream.writeUTF(String)
.- Throws:
IOException
-
writeUTF8FixedDelimited
public static LinkedBuffer writeUTF8FixedDelimited(CharSequence str, boolean littleEndian, WriteSession session, LinkedBuffer lb) throws IOException The length of the utf8 bytes is written first before the string - which is fixed 2-bytes.- Throws:
IOException
-
writeUTF8OneByteDelimited
private static LinkedBuffer writeUTF8OneByteDelimited(CharSequence str, int index, int len, WriteSession session, LinkedBuffer lb) throws IOException - Throws:
IOException
-
writeUTF8VarDelimited
private static LinkedBuffer writeUTF8VarDelimited(CharSequence str, int index, int len, int lowerLimit, int expectedSize, WriteSession session, LinkedBuffer lb) throws IOException - Throws:
IOException
-
writeUTF8VarDelimited
public static LinkedBuffer writeUTF8VarDelimited(CharSequence str, WriteSession session, LinkedBuffer lb) throws IOException The length of the utf8 bytes is written first before the string - which is a variable int (1 to 5 bytes).- Throws:
IOException
-