Package com.alibaba.fastjson2
Interface JSONB.IO
- Enclosing interface:
JSONB
public static interface JSONB.IO
IO utility methods for JSONB serialization
-
Method Summary
Static MethodsModifier and TypeMethodDescriptionstatic intcheckAndWriteTypeName(byte[] bytes, int off, Object object, Class<?> fieldClass, JSONWriter jsonWriter) Checks and writes a type name to a byte arraystatic intenumCapacity(Enum e, long features) Calculates the capacity needed for an enumstatic intint64Capacity(Collection<Long> values) Calculates the capacity needed for a collection of Long valuesstatic intputStringSizeLarge(byte[] bytes, int off, int strlen) Puts a large string size to a byte arraystatic intputStringSizeSmall(byte[] bytes, int off, int val) Puts a small string size to a byte arraystatic intsizeOfInt(int i) Calculates the size needed for an integer valuestatic intstartArray(byte[] bytes, int off, int size) Starts an array in a byte arraystatic intstringCapacity(String str) Calculates the capacity needed for a stringstatic intstringCapacity(String[] strings) Calculates the capacity needed for a string arraystatic intstringCapacity(Collection<String> strings) Calculates the capacity needed for a collection of stringsstatic intwriteBoolean(byte[] bytes, int off, boolean value) Writes a boolean value to a byte arraystatic intwriteBoolean(byte[] bytes, int off, boolean[] values) Writes a boolean array to a byte arraystatic intwriteBoolean(byte[] bytes, int off, Boolean value) Writes a Boolean value to a byte arraystatic intwriteDouble(byte[] bytes, int off, double value) Writes a double value to a byte arraystatic intwriteDouble(byte[] bytes, int off, double[] values) Writes a double array to a byte arraystatic intwriteDouble(byte[] bytes, int off, Double value, long features) Writes a Double value to a byte arraystatic intWrites an enum value to a byte arraystatic intwriteFloat(byte[] bytes, int off, float value) Writes a float value to a byte arraystatic intwriteFloat(byte[] bytes, int off, float[] values) Writes a float array to a byte arraystatic intwriteFloat(byte[] bytes, int off, Float value, long features) Writes a Float value to a byte arraystatic intwriteInstant(byte[] bytes, int off, Instant value) Writes an Instant value to a byte arraystatic intwriteInt16(byte[] bytes, int off, short val) Writes a short value to a byte arraystatic intwriteInt16(byte[] bytes, int off, Short val, long features) Writes a Short value to a byte arraystatic intwriteInt32(byte[] bytes, int off, int value) Writes an integer value to a byte arraystatic intwriteInt32(byte[] bytes, int off, Integer value, long features) Writes an Integer value to a byte arraystatic intwriteInt64(byte[] bytes, int off, long value) Writes a long value to a byte arraystatic intwriteInt64(byte[] bytes, int off, Long value, long features) Writes a Long value to a byte arraystatic intwriteInt64(byte[] bytes, int off, Collection<Long> values, long features) Writes a collection of Long values to a byte arraystatic intwriteInt8(byte[] bytes, int off, byte val) Writes a byte value to a byte arraystatic intWrites a Byte value to a byte arraystatic intwriteLocalDate(byte[] bytes, int off, LocalDate value) Writes a LocalDate value to a byte arraystatic intwriteLocalDateTime(byte[] bytes, int off, LocalDateTime value) Writes a LocalDateTime value to a byte arraystatic intwriteLocalTime(byte[] bytes, int off, LocalTime value) Writes a LocalTime value to a byte arraystatic intwriteNameRaw(byte[] bytes, int off, byte[] name, long nameHash, JSONWriter jsonWriter) Writes a raw name to a byte arraystatic intwriteOffsetDateTime(byte[] bytes, int off, OffsetDateTime value) Writes an OffsetDateTime value to a byte arraystatic intwriteOffsetTime(byte[] bytes, int off, OffsetTime value) Writes an OffsetTime value to a byte arraystatic intwriteReference(byte[] bytes, int off, String path, JSONWriter jsonWriter) Writes a reference to a byte arraystatic intwriteString(byte[] bytes, int off, char[] chars) Writes a character array to a byte arraystatic intwriteString(byte[] bytes, int off, char[] chars, int coff, int strlen) Writes a character array with offset and length to a byte arraystatic intwriteString(byte[] bytes, int off, String str) Writes a string to a byte arraystatic intwriteString(byte[] bytes, int off, String[] strings, long features) Writes a string array to a byte arraystatic intwriteString(byte[] bytes, int off, Collection<String> strings, long features) Writes a collection of strings to a byte arraystatic intwriteStringLatin1(byte[] bytes, int off, byte[] value) Writes a Latin-1 string to a byte arraystatic intwriteStringLatin1(byte[] bytes, int off, char[] chars, int coff, int strlen) Writes a Latin-1 character array to a byte arraystatic intwriteStringUTF16(byte[] bytes, int off, byte[] value) Writes a UTF-16 string to a byte arraystatic intwriteSymbol(byte[] bytes, int off, int symbol) Writes a symbol to a byte arraystatic intwriteSymbol(byte[] bytes, int off, String str, SymbolTable symbolTable) Writes a string with a symbol table to a byte arraystatic intwriteTypeName(byte[] bytes, int off, String typeName, JSONWriter jsonWriter) Writes a type name to a byte arraystatic intwriteUTF8(byte[] bytes, int off, char[] chars, int coff, int strlen) Writes a UTF-8 character array to a byte arraystatic intWrites a UUID value to a byte array
-
Method Details
-
enumCapacity
Calculates the capacity needed for an enum- Parameters:
e- the enum valuefeatures- the features to apply- Returns:
- the capacity needed
-
writeEnum
Writes an enum value to a byte array- Parameters:
bytes- the byte array to write tooff- the offset in the byte arraye- the enum value to writefeatures- the features to apply- Returns:
- the new offset
-
writeBoolean
Writes a Boolean value to a byte array- Parameters:
bytes- the byte array to write tooff- the offset in the byte arrayvalue- 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 tooff- the offset in the byte arrayvalue- 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 tooff- the offset in the byte arrayvalues- the boolean array to write- Returns:
- the new offset
-
writeFloat
Writes a Float value to a byte array- Parameters:
bytes- the byte array to write tooff- the offset in the byte arrayvalue- the Float value to writefeatures- 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 tooff- the offset in the byte arrayvalues- 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 tooff- the offset in the byte arrayvalue- the float value to write- Returns:
- the new offset
-
writeDouble
Writes a Double value to a byte array- Parameters:
bytes- the byte array to write tooff- the offset in the byte arrayvalue- the Double value to writefeatures- 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 tooff- the offset in the byte arrayvalue- 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 tooff- the offset in the byte arrayvalues- the double array to write- Returns:
- the new offset
-
writeInt8
Writes a Byte value to a byte array- Parameters:
bytes- the byte array to write tooff- the offset in the byte arrayval- the Byte value to writefeatures- 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 tooff- the offset in the byte arrayval- the byte value to write- Returns:
- the new offset
-
writeInt16
Writes a Short value to a byte array- Parameters:
bytes- the byte array to write tooff- the offset in the byte arrayval- the Short value to writefeatures- 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 tooff- the offset in the byte arrayval- the short value to write- Returns:
- the new offset
-
writeInt32
Writes an Integer value to a byte array- Parameters:
bytes- the byte array to write tooff- the offset in the byte arrayvalue- the Integer value to writefeatures- the features to apply- Returns:
- the new offset
-
writeSymbol
Writes a string with a symbol table to a byte array- Parameters:
bytes- the byte array to write tooff- the offset in the byte arraystr- the string to writesymbolTable- 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 tooff- the offset in the byte arraysymbol- 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 tooff- the offset in the byte arrayobject- the object to checkfieldClass- the field classjsonWriter- the JSON writer- Returns:
- the new offset
-
writeTypeName
Writes a type name to a byte array- Parameters:
bytes- the byte array to write tooff- the offset in the byte arraytypeName- the type name to writejsonWriter- 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 tooff- the offset in the byte arrayvalue- the integer value to write- Returns:
- the new offset
-
writeInt64
Writes a collection of Long values to a byte array- Parameters:
bytes- the byte array to write tooff- the offset in the byte arrayvalues- the collection of Long values to writefeatures- the features to apply- Returns:
- the new offset
-
writeInt64
Writes a Long value to a byte array- Parameters:
bytes- the byte array to write tooff- the offset in the byte arrayvalue- the Long value to writefeatures- 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 tooff- the offset in the byte arrayvalue- 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 tooff- the offset in the byte arraysize- the size of the array- Returns:
- the new offset
-
writeString
Writes a collection of strings to a byte array- Parameters:
bytes- the byte array to write tooff- the offset in the byte arraystrings- the collection of strings to writefeatures- the features to apply- Returns:
- the new offset
-
writeString
Writes a string array to a byte array- Parameters:
bytes- the byte array to write tooff- the offset in the byte arraystrings- the string array to writefeatures- the features to apply- Returns:
- the new offset
-
writeString
Writes a string to a byte array- Parameters:
bytes- the byte array to write tooff- the offset in the byte arraystr- 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 tooff- the offset in the byte arrayvalue- 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 tooff- the offset in the byte arrayvalue- the Latin-1 byte array to write- Returns:
- the new offset
-
stringCapacity
Calculates the capacity needed for a collection of strings- Parameters:
strings- the collection of strings- Returns:
- the capacity needed
-
stringCapacity
Calculates the capacity needed for a string array- Parameters:
strings- the string array- Returns:
- the capacity needed
-
int64Capacity
Calculates the capacity needed for a collection of Long values- Parameters:
values- the collection of Long values- Returns:
- the capacity needed
-
stringCapacity
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 tooff- the offset in the byte arrayval- 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 tooff- the offset in the byte arraystrlen- 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 tooff- the offset in the byte arraychars- 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 tooff- the offset in the byte arraychars- the character array to writecoff- the offset in the character arraystrlen- 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 tooff- the offset in the byte arraychars- the character array to writecoff- the offset in the character arraystrlen- 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 tooff- the offset in the byte arraychars- the character array to writecoff- the offset in the character arraystrlen- 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
Writes a UUID value to a byte array- Parameters:
bytes- the byte array to write tooff- the offset in the byte arrayvalue- the UUID value to write- Returns:
- the new offset
-
writeInstant
Writes an Instant value to a byte array- Parameters:
bytes- the byte array to write tooff- the offset in the byte arrayvalue- the Instant value to write- Returns:
- the new offset
-
writeLocalDate
Writes a LocalDate value to a byte array- Parameters:
bytes- the byte array to write tooff- the offset in the byte arrayvalue- the LocalDate value to write- Returns:
- the new offset
-
writeLocalTime
Writes a LocalTime value to a byte array- Parameters:
bytes- the byte array to write tooff- the offset in the byte arrayvalue- the LocalTime value to write- Returns:
- the new offset
-
writeLocalDateTime
Writes a LocalDateTime value to a byte array- Parameters:
bytes- the byte array to write tooff- the offset in the byte arrayvalue- the LocalDateTime value to write- Returns:
- the new offset
-
writeOffsetDateTime
Writes an OffsetDateTime value to a byte array- Parameters:
bytes- the byte array to write tooff- the offset in the byte arrayvalue- the OffsetDateTime value to write- Returns:
- the new offset
-
writeOffsetTime
Writes an OffsetTime value to a byte array- Parameters:
bytes- the byte array to write tooff- the offset in the byte arrayvalue- the OffsetTime value to write- Returns:
- the new offset
-
writeReference
Writes a reference to a byte array- Parameters:
bytes- the byte array to write tooff- the offset in the byte arraypath- the reference pathjsonWriter- the JSON writer- Returns:
- the new offset
-
writeNameRaw
Writes a raw name to a byte array- Parameters:
bytes- the byte array to write tooff- the offset in the byte arrayname- the name byte array to writenameHash- the name hashjsonWriter- the JSON writer- Returns:
- the new offset
-