Interface JSONB.IO

Enclosing interface:
JSONB

public static interface JSONB.IO
IO utility methods for JSONB serialization
  • Method Summary

    Static Methods
    Modifier and Type
    Method
    Description
    static int
    checkAndWriteTypeName(byte[] bytes, int off, Object object, Class<?> fieldClass, JSONWriter jsonWriter)
    Checks and writes a type name to a byte array
    static int
    enumCapacity(Enum e, long features)
    Calculates the capacity needed for an enum
    static int
    Calculates the capacity needed for a collection of Long values
    static int
    putStringSizeLarge(byte[] bytes, int off, int strlen)
    Puts a large string size to a byte array
    static int
    putStringSizeSmall(byte[] bytes, int off, int val)
    Puts a small string size to a byte array
    static int
    sizeOfInt(int i)
    Calculates the size needed for an integer value
    static int
    startArray(byte[] bytes, int off, int size)
    Starts an array in a byte array
    static int
    Calculates the capacity needed for a string
    static int
    Calculates the capacity needed for a string array
    static int
    Calculates the capacity needed for a collection of strings
    static int
    writeBoolean(byte[] bytes, int off, boolean value)
    Writes a boolean value to a byte array
    static int
    writeBoolean(byte[] bytes, int off, boolean[] values)
    Writes a boolean array to a byte array
    static int
    writeBoolean(byte[] bytes, int off, Boolean value)
    Writes a Boolean value to a byte array
    static int
    writeDouble(byte[] bytes, int off, double value)
    Writes a double value to a byte array
    static int
    writeDouble(byte[] bytes, int off, double[] values)
    Writes a double array to a byte array
    static int
    writeDouble(byte[] bytes, int off, Double value, long features)
    Writes a Double value to a byte array
    static int
    writeEnum(byte[] bytes, int off, Enum e, long features)
    Writes an enum value to a byte array
    static int
    writeFloat(byte[] bytes, int off, float value)
    Writes a float value to a byte array
    static int
    writeFloat(byte[] bytes, int off, float[] values)
    Writes a float array to a byte array
    static int
    writeFloat(byte[] bytes, int off, Float value, long features)
    Writes a Float value to a byte array
    static int
    writeInstant(byte[] bytes, int off, Instant value)
    Writes an Instant value to a byte array
    static int
    writeInt16(byte[] bytes, int off, short val)
    Writes a short value to a byte array
    static int
    writeInt16(byte[] bytes, int off, Short val, long features)
    Writes a Short value to a byte array
    static int
    writeInt32(byte[] bytes, int off, int value)
    Writes an integer value to a byte array
    static int
    writeInt32(byte[] bytes, int off, Integer value, long features)
    Writes an Integer value to a byte array
    static int
    writeInt64(byte[] bytes, int off, long value)
    Writes a long value to a byte array
    static int
    writeInt64(byte[] bytes, int off, Long value, long features)
    Writes a Long value to a byte array
    static int
    writeInt64(byte[] bytes, int off, Collection<Long> values, long features)
    Writes a collection of Long values to a byte array
    static int
    writeInt8(byte[] bytes, int off, byte val)
    Writes a byte value to a byte array
    static int
    writeInt8(byte[] bytes, int off, Byte val, long features)
    Writes a Byte value to a byte array
    static int
    writeLocalDate(byte[] bytes, int off, LocalDate value)
    Writes a LocalDate value to a byte array
    static int
    writeLocalDateTime(byte[] bytes, int off, LocalDateTime value)
    Writes a LocalDateTime value to a byte array
    static int
    writeLocalTime(byte[] bytes, int off, LocalTime value)
    Writes a LocalTime value to a byte array
    static int
    writeNameRaw(byte[] bytes, int off, byte[] name, long nameHash, JSONWriter jsonWriter)
    Writes a raw name to a byte array
    static int
    writeOffsetDateTime(byte[] bytes, int off, OffsetDateTime value)
    Writes an OffsetDateTime value to a byte array
    static int
    writeOffsetTime(byte[] bytes, int off, OffsetTime value)
    Writes an OffsetTime value to a byte array
    static int
    writeReference(byte[] bytes, int off, String path, JSONWriter jsonWriter)
    Writes a reference to a byte array
    static int
    writeString(byte[] bytes, int off, char[] chars)
    Writes a character array to a byte array
    static int
    writeString(byte[] bytes, int off, char[] chars, int coff, int strlen)
    Writes a character array with offset and length to a byte array
    static int
    writeString(byte[] bytes, int off, String str)
    Writes a string to a byte array
    static int
    writeString(byte[] bytes, int off, String[] strings, long features)
    Writes a string array to a byte array
    static int
    writeString(byte[] bytes, int off, Collection<String> strings, long features)
    Writes a collection of strings to a byte array
    static int
    writeStringLatin1(byte[] bytes, int off, byte[] value)
    Writes a Latin-1 string to a byte array
    static int
    writeStringLatin1(byte[] bytes, int off, char[] chars, int coff, int strlen)
    Writes a Latin-1 character array to a byte array
    static int
    writeStringUTF16(byte[] bytes, int off, byte[] value)
    Writes a UTF-16 string to a byte array
    static int
    writeSymbol(byte[] bytes, int off, int symbol)
    Writes a symbol to a byte array
    static int
    writeSymbol(byte[] bytes, int off, String str, SymbolTable symbolTable)
    Writes a string with a symbol table to a byte array
    static int
    writeTypeName(byte[] bytes, int off, String typeName, JSONWriter jsonWriter)
    Writes a type name to a byte array
    static int
    writeUTF8(byte[] bytes, int off, char[] chars, int coff, int strlen)
    Writes a UTF-8 character array to a byte array
    static int
    writeUUID(byte[] bytes, int off, UUID value)
    Writes a UUID value to a byte array
  • Method Details

    • enumCapacity

      static int enumCapacity(Enum e, long features)
      Calculates the capacity needed for an enum
      Parameters:
      e - the enum value
      features - the features to apply
      Returns:
      the capacity needed
    • writeEnum

      static int writeEnum(byte[] bytes, int off, Enum e, long features)
      Writes an enum value to a byte array
      Parameters:
      bytes - the byte array to write to
      off - the offset in the byte array
      e - the enum value to write
      features - the features to apply
      Returns:
      the new offset
    • writeBoolean

      static int writeBoolean(byte[] bytes, int off, Boolean value)
      Writes a Boolean value to a byte array
      Parameters:
      bytes - the byte array to write to
      off - the offset in the byte array
      value - the Boolean value to write
      Returns:
      the new offset
    • writeBoolean

      static int writeBoolean(byte[] bytes, int off, boolean value)
      Writes a boolean value to a byte array
      Parameters:
      bytes - the byte array to write to
      off - the offset in the byte array
      value - the boolean value to write
      Returns:
      the new offset
    • writeBoolean

      static int writeBoolean(byte[] bytes, int off, boolean[] values)
      Writes a boolean array to a byte array
      Parameters:
      bytes - the byte array to write to
      off - the offset in the byte array
      values - the boolean array to write
      Returns:
      the new offset
    • writeFloat

      static int writeFloat(byte[] bytes, int off, Float value, long features)
      Writes a Float value to a byte array
      Parameters:
      bytes - the byte array to write to
      off - the offset in the byte array
      value - the Float value to write
      features - the features to apply
      Returns:
      the new offset
    • writeFloat

      static int writeFloat(byte[] bytes, int off, float[] values)
      Writes a float array to a byte array
      Parameters:
      bytes - the byte array to write to
      off - the offset in the byte array
      values - the float array to write
      Returns:
      the new offset
    • writeFloat

      static int writeFloat(byte[] bytes, int off, float value)
      Writes a float value to a byte array
      Parameters:
      bytes - the byte array to write to
      off - the offset in the byte array
      value - the float value to write
      Returns:
      the new offset
    • writeDouble

      static int writeDouble(byte[] bytes, int off, Double value, long features)
      Writes a Double value to a byte array
      Parameters:
      bytes - the byte array to write to
      off - the offset in the byte array
      value - the Double value to write
      features - the features to apply
      Returns:
      the new offset
    • writeDouble

      static int writeDouble(byte[] bytes, int off, double value)
      Writes a double value to a byte array
      Parameters:
      bytes - the byte array to write to
      off - the offset in the byte array
      value - the double value to write
      Returns:
      the new offset
    • writeDouble

      static int writeDouble(byte[] bytes, int off, double[] values)
      Writes a double array to a byte array
      Parameters:
      bytes - the byte array to write to
      off - the offset in the byte array
      values - the double array to write
      Returns:
      the new offset
    • writeInt8

      static int writeInt8(byte[] bytes, int off, Byte val, long features)
      Writes a Byte value to a byte array
      Parameters:
      bytes - the byte array to write to
      off - the offset in the byte array
      val - the Byte value to write
      features - the features to apply
      Returns:
      the new offset
    • writeInt8

      static int writeInt8(byte[] bytes, int off, byte val)
      Writes a byte value to a byte array
      Parameters:
      bytes - the byte array to write to
      off - the offset in the byte array
      val - the byte value to write
      Returns:
      the new offset
    • writeInt16

      static int writeInt16(byte[] bytes, int off, Short val, long features)
      Writes a Short value to a byte array
      Parameters:
      bytes - the byte array to write to
      off - the offset in the byte array
      val - the Short value to write
      features - the features to apply
      Returns:
      the new offset
    • writeInt16

      static int writeInt16(byte[] bytes, int off, short val)
      Writes a short value to a byte array
      Parameters:
      bytes - the byte array to write to
      off - the offset in the byte array
      val - the short value to write
      Returns:
      the new offset
    • writeInt32

      static int writeInt32(byte[] bytes, int off, Integer value, long features)
      Writes an Integer value to a byte array
      Parameters:
      bytes - the byte array to write to
      off - the offset in the byte array
      value - the Integer value to write
      features - the features to apply
      Returns:
      the new offset
    • writeSymbol

      static int writeSymbol(byte[] bytes, int off, String str, SymbolTable symbolTable)
      Writes a string with a symbol table to a byte array
      Parameters:
      bytes - the byte array to write to
      off - the offset in the byte array
      str - the string to write
      symbolTable - the symbol table to use
      Returns:
      the new offset
    • writeSymbol

      static int writeSymbol(byte[] bytes, int off, int symbol)
      Writes a symbol to a byte array
      Parameters:
      bytes - the byte array to write to
      off - the offset in the byte array
      symbol - the symbol to write
      Returns:
      the new offset
    • checkAndWriteTypeName

      static int checkAndWriteTypeName(byte[] bytes, int off, Object object, Class<?> fieldClass, JSONWriter jsonWriter)
      Checks and writes a type name to a byte array
      Parameters:
      bytes - the byte array to write to
      off - the offset in the byte array
      object - the object to check
      fieldClass - the field class
      jsonWriter - the JSON writer
      Returns:
      the new offset
    • writeTypeName

      static int writeTypeName(byte[] bytes, int off, String typeName, JSONWriter jsonWriter)
      Writes a type name to a byte array
      Parameters:
      bytes - the byte array to write to
      off - the offset in the byte array
      typeName - the type name to write
      jsonWriter - the JSON writer
      Returns:
      the new offset
    • writeInt32

      static int writeInt32(byte[] bytes, int off, int value)
      Writes an integer value to a byte array
      Parameters:
      bytes - the byte array to write to
      off - the offset in the byte array
      value - the integer value to write
      Returns:
      the new offset
    • writeInt64

      static int writeInt64(byte[] bytes, int off, Collection<Long> values, long features)
      Writes a collection of Long values to a byte array
      Parameters:
      bytes - the byte array to write to
      off - the offset in the byte array
      values - the collection of Long values to write
      features - the features to apply
      Returns:
      the new offset
    • writeInt64

      static int writeInt64(byte[] bytes, int off, Long value, long features)
      Writes a Long value to a byte array
      Parameters:
      bytes - the byte array to write to
      off - the offset in the byte array
      value - the Long value to write
      features - the features to apply
      Returns:
      the new offset
    • writeInt64

      static int writeInt64(byte[] bytes, int off, long value)
      Writes a long value to a byte array
      Parameters:
      bytes - the byte array to write to
      off - the offset in the byte array
      value - the long value to write
      Returns:
      the new offset
    • startArray

      static int startArray(byte[] bytes, int off, int size)
      Starts an array in a byte array
      Parameters:
      bytes - the byte array to write to
      off - the offset in the byte array
      size - the size of the array
      Returns:
      the new offset
    • writeString

      static int writeString(byte[] bytes, int off, Collection<String> strings, long features)
      Writes a collection of strings to a byte array
      Parameters:
      bytes - the byte array to write to
      off - the offset in the byte array
      strings - the collection of strings to write
      features - the features to apply
      Returns:
      the new offset
    • writeString

      static int writeString(byte[] bytes, int off, String[] strings, long features)
      Writes a string array to a byte array
      Parameters:
      bytes - the byte array to write to
      off - the offset in the byte array
      strings - the string array to write
      features - the features to apply
      Returns:
      the new offset
    • writeString

      static int writeString(byte[] bytes, int off, String str)
      Writes a string to a byte array
      Parameters:
      bytes - the byte array to write to
      off - the offset in the byte array
      str - the string to write
      Returns:
      the new offset
    • writeStringUTF16

      static int writeStringUTF16(byte[] bytes, int off, byte[] value)
      Writes a UTF-16 string to a byte array
      Parameters:
      bytes - the byte array to write to
      off - the offset in the byte array
      value - the UTF-16 byte array to write
      Returns:
      the new offset
    • writeStringLatin1

      static int writeStringLatin1(byte[] bytes, int off, byte[] value)
      Writes a Latin-1 string to a byte array
      Parameters:
      bytes - the byte array to write to
      off - the offset in the byte array
      value - the Latin-1 byte array to write
      Returns:
      the new offset
    • stringCapacity

      static int stringCapacity(Collection<String> strings)
      Calculates the capacity needed for a collection of strings
      Parameters:
      strings - the collection of strings
      Returns:
      the capacity needed
    • stringCapacity

      static int stringCapacity(String[] strings)
      Calculates the capacity needed for a string array
      Parameters:
      strings - the string array
      Returns:
      the capacity needed
    • int64Capacity

      static int int64Capacity(Collection<Long> values)
      Calculates the capacity needed for a collection of Long values
      Parameters:
      values - the collection of Long values
      Returns:
      the capacity needed
    • stringCapacity

      static int stringCapacity(String str)
      Calculates the capacity needed for a string
      Parameters:
      str - the string
      Returns:
      the capacity needed
    • putStringSizeSmall

      static int putStringSizeSmall(byte[] bytes, int off, int val)
      Puts a small string size to a byte array
      Parameters:
      bytes - the byte array to write to
      off - the offset in the byte array
      val - the size value to write
      Returns:
      the new offset
    • putStringSizeLarge

      static int putStringSizeLarge(byte[] bytes, int off, int strlen)
      Puts a large string size to a byte array
      Parameters:
      bytes - the byte array to write to
      off - the offset in the byte array
      strlen - the size value to write
      Returns:
      the new offset
    • writeString

      static int writeString(byte[] bytes, int off, char[] chars)
      Writes a character array to a byte array
      Parameters:
      bytes - the byte array to write to
      off - the offset in the byte array
      chars - the character array to write
      Returns:
      the new offset
    • writeString

      static int writeString(byte[] bytes, int off, char[] chars, int coff, int strlen)
      Writes a character array with offset and length to a byte array
      Parameters:
      bytes - the byte array to write to
      off - the offset in the byte array
      chars - the character array to write
      coff - the offset in the character array
      strlen - the length of characters to write
      Returns:
      the new offset
    • writeStringLatin1

      static int writeStringLatin1(byte[] bytes, int off, char[] chars, int coff, int strlen)
      Writes a Latin-1 character array to a byte array
      Parameters:
      bytes - the byte array to write to
      off - the offset in the byte array
      chars - the character array to write
      coff - the offset in the character array
      strlen - the length of characters to write
      Returns:
      the new offset
    • writeUTF8

      static int writeUTF8(byte[] bytes, int off, char[] chars, int coff, int strlen)
      Writes a UTF-8 character array to a byte array
      Parameters:
      bytes - the byte array to write to
      off - the offset in the byte array
      chars - the character array to write
      coff - the offset in the character array
      strlen - the length of characters to write
      Returns:
      the new offset
    • sizeOfInt

      static int sizeOfInt(int i)
      Calculates the size needed for an integer value
      Parameters:
      i - the integer value
      Returns:
      the size needed
    • writeUUID

      static int writeUUID(byte[] bytes, int off, UUID value)
      Writes a UUID value to a byte array
      Parameters:
      bytes - the byte array to write to
      off - the offset in the byte array
      value - the UUID value to write
      Returns:
      the new offset
    • writeInstant

      static int writeInstant(byte[] bytes, int off, Instant value)
      Writes an Instant value to a byte array
      Parameters:
      bytes - the byte array to write to
      off - the offset in the byte array
      value - the Instant value to write
      Returns:
      the new offset
    • writeLocalDate

      static int writeLocalDate(byte[] bytes, int off, LocalDate value)
      Writes a LocalDate value to a byte array
      Parameters:
      bytes - the byte array to write to
      off - the offset in the byte array
      value - the LocalDate value to write
      Returns:
      the new offset
    • writeLocalTime

      static int writeLocalTime(byte[] bytes, int off, LocalTime value)
      Writes a LocalTime value to a byte array
      Parameters:
      bytes - the byte array to write to
      off - the offset in the byte array
      value - the LocalTime value to write
      Returns:
      the new offset
    • writeLocalDateTime

      static int writeLocalDateTime(byte[] bytes, int off, LocalDateTime value)
      Writes a LocalDateTime value to a byte array
      Parameters:
      bytes - the byte array to write to
      off - the offset in the byte array
      value - the LocalDateTime value to write
      Returns:
      the new offset
    • writeOffsetDateTime

      static int writeOffsetDateTime(byte[] bytes, int off, OffsetDateTime value)
      Writes an OffsetDateTime value to a byte array
      Parameters:
      bytes - the byte array to write to
      off - the offset in the byte array
      value - the OffsetDateTime value to write
      Returns:
      the new offset
    • writeOffsetTime

      static int writeOffsetTime(byte[] bytes, int off, OffsetTime value)
      Writes an OffsetTime value to a byte array
      Parameters:
      bytes - the byte array to write to
      off - the offset in the byte array
      value - the OffsetTime value to write
      Returns:
      the new offset
    • writeReference

      static int writeReference(byte[] bytes, int off, String path, JSONWriter jsonWriter)
      Writes a reference to a byte array
      Parameters:
      bytes - the byte array to write to
      off - the offset in the byte array
      path - the reference path
      jsonWriter - the JSON writer
      Returns:
      the new offset
    • writeNameRaw

      static int writeNameRaw(byte[] bytes, int off, byte[] name, long nameHash, JSONWriter jsonWriter)
      Writes a raw name to a byte array
      Parameters:
      bytes - the byte array to write to
      off - the offset in the byte array
      name - the name byte array to write
      nameHash - the name hash
      jsonWriter - the JSON writer
      Returns:
      the new offset