Package io.protostuff

Class StringSerializer

java.lang.Object
io.protostuff.StringSerializer

public final class StringSerializer extends Object
UTF-8 String serialization
  • 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

      public static LinkedBuffer writeInt(int value, WriteSession session, LinkedBuffer lb)
      Writes the stringified int into the LinkedBuffer.
    • writeLong

      public static LinkedBuffer writeLong(long value, WriteSession session, LinkedBuffer lb)
      Writes the stringified long into the LinkedBuffer.
    • writeFloat

      public static LinkedBuffer writeFloat(float value, WriteSession session, LinkedBuffer lb)
      Writes the stringified float into the LinkedBuffer. TODO - skip string conversion and write directly to buffer
    • writeDouble

      public static LinkedBuffer writeDouble(double value, WriteSession session, LinkedBuffer lb)
      Writes the stringified double into the LinkedBuffer. TODO - skip string conversion and write directly to buffer
    • computeUTF8Size

      public static int computeUTF8Size(CharSequence str, int index, int len)
      Computes the size of the utf8 string beginning at the specified index with the specified length.
    • 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. The LinkedBuffer's capacity is >= string length.
    • writeUTF8

      public static LinkedBuffer writeUTF8(CharSequence str, WriteSession session, LinkedBuffer lb)
      Writes the utf8-encoded bytes from the string into the LinkedBuffer.
    • writeAscii

      public static LinkedBuffer writeAscii(CharSequence str, WriteSession session, LinkedBuffer lb)
      Writes the ascii bytes from the string into the LinkedBuffer. 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 as DataOutputStream.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)