corda / net.corda.core.serialization / SerializationFactory

SerializationFactory

abstract class SerializationFactory

An abstraction for serializing and deserializing objects, with support for versioning of the wire format via a header / prefix in the bytes.

Constructors

<init>

SerializationFactory()

An abstraction for serializing and deserializing objects, with support for versioning of the wire format via a header / prefix in the bytes.

Properties

currentContext

val currentContext: SerializationContext?

If there is a need to nest serialization/deserialization with a modified context during serialization or deserialization, this will return the current context used to start serialization/deserialization.

defaultContext

val defaultContext: SerializationContext

A context to use as a default if you do not require a specially configured context. It will be the current context if the use is somehow nested (see currentContext).

Functions

asCurrent

fun <T> asCurrent(block: SerializationFactory.() -> T): T

Allow subclasses to temporarily mark themselves as the current factory for the current thread during serialization/deserialization. Will restore the prior context on exiting the block.

deserialize

abstract fun <T : Any> deserialize(byteSequence: ByteSequence, clazz: Class<T>, context: SerializationContext): T

Deserialize the bytes in to an object, using the prefixed bytes to determine the format.

deserializeWithCompatibleContext

abstract fun <T : Any> deserializeWithCompatibleContext(byteSequence: ByteSequence, clazz: Class<T>, context: SerializationContext): ObjectWithCompatibleContext<T>

Deserialize the bytes in to an object, using the prefixed bytes to determine the format.

serialize

abstract fun <T : Any> serialize(obj: T, context: SerializationContext): SerializedBytes<T>

Serialize an object to bytes using the preferred serialization format version from the context.

withCurrentContext

fun <T> withCurrentContext(context: SerializationContext?, block: () -> T): T

Change the current context inside the block to that supplied.

Companion Object Properties

currentFactory

val currentFactory: SerializationFactory?

If there is a need to nest serialization/deserialization with a modified context during serialization or deserialization, this will return the current factory used to start serialization/deserialization.

defaultFactory

val defaultFactory: SerializationFactory

A default factory for serialization/deserialization, taking into account the currentFactory if set.

Extension Functions

contextLogger

fun Any.contextLogger(): Logger

When called from a companion object, returns the logger for the enclosing class.