Updated on 2023-02-28 GMT+08:00

ObjectUtils

Path

com.roma.apic.livedata.common.v1.ObjectUtils

Description

This class is used to serialize a Java object into a byte array or deserialize a Java object from a byte array.

Example

1
2
3
4
5
6
importClass(com.roma.apic.livedata.common.v1.ObjectUtils);
function execute(data) {
    var sourceCode = "Hello world";
    var bytes = ObjectUtils.getBytes(sourceCode);
    return ObjectUtils.getObjectFromBytes(bytes)
}

Method List

Returned Type

Method and Description

static byte[]

getBytes(Object obj)

Serialize objects into byte arrays.

static Object

getObjectFromBytes(byte[] objBytes)

Deserialize byte arrays into objects.

static int

size(Object obj)

Obtains the size of an object.

Method Details

  • public static byte[] getBytes(Object obj)

    Serialize objects into byte arrays.

    Input Parameter

    obj indicates an object.

    Returns

    Byte array serialized from an object.

    Throws

    java.io.IOException

  • public static Object getObjectFromBytes(byte[] objBytes)

    Deserialize byte arrays into objects.

    Input Parameter

    objBytes indicates a byte array.

    Returns

    Serialized object.

    Throws

    java.io.IOException

  • public static int size(Object obj)

    Obtain the size of an object.

    Input Parameter

    obj indicates an object.

    Returns

    Size of the object.