AbstractDecoder
A skeleton implementation of both Decoder and CompositeDecoder that can be used for simple formats and for testability purpose. Most of the decode*
methods have default implementation that delegates decodeValue(value: Any) as TargetType
. See Decoder documentation for information about each particular decode*
method.
Properties
Functions
Decodes the beginning of the nested structure in a serialized form and returns CompositeDecoder responsible for decoding this very structure.
Decodes a boolean value. Corresponding kind is PrimitiveKind.BOOLEAN.
Decodes a boolean value from the underlying input. The resulting value is associated with the descriptor element at the given index. The element at the given index should have PrimitiveKind.BOOLEAN kind.
Decodes a single byte value. Corresponding kind is PrimitiveKind.BYTE.
Decodes a single byte value from the underlying input. The resulting value is associated with the descriptor element at the given index. The element at the given index should have PrimitiveKind.BYTE kind.
Decodes a 16-bit unicode character value. Corresponding kind is PrimitiveKind.CHAR.
Decodes a 16-bit unicode character value from the underlying input. The resulting value is associated with the descriptor element at the given index. The element at the given index should have PrimitiveKind.CHAR kind.
Method to decode collection size that may be called before the collection decoding. Collection type includes Collection, Map and Array (including primitive arrays). Method can return -1
if the size is not known in advance, though for sequential decoding knowing precise size is a mandatory requirement.
Decodes a 64-bit IEEE 754 floating point value. Corresponding kind is PrimitiveKind.DOUBLE.
Decodes a 64-bit IEEE 754 floating point value from the underlying input. The resulting value is associated with the descriptor element at the given index. The element at the given index should have PrimitiveKind.DOUBLE kind.
Decodes the index of the next element to be decoded. Index represents a position of the current element in the serial descriptor element that can be found with SerialDescriptor.getElementIndex.
Decodes a enum value and returns its index in enumDescriptor elements collection. Corresponding kind is SerialKind.ENUM.
Decodes a 32-bit IEEE 754 floating point value. Corresponding kind is PrimitiveKind.FLOAT.
Decodes a 32-bit IEEE 754 floating point value from the underlying input. The resulting value is associated with the descriptor element at the given index. The element at the given index should have PrimitiveKind.FLOAT kind.
Returns Decoder for decoding an underlying type of a value class in an inline manner. descriptor describes a target value class.
Returns Decoder for decoding an underlying type of a value class in an inline manner. Serializable value class is described by the child descriptor of given descriptor at index.
Decodes a 32-bit integer value. Corresponding kind is PrimitiveKind.INT.
Decodes a 32-bit integer value from the underlying input. The resulting value is associated with the descriptor element at the given index. The element at the given index should have PrimitiveKind.INT kind.
Decodes a 64-bit integer value. Corresponding kind is PrimitiveKind.LONG.
Decodes a 64-bit integer value from the underlying input. The resulting value is associated with the descriptor element at the given index. The element at the given index should have PrimitiveKind.LONG kind.
Returns true
if the current value in decoder is not null, false otherwise. This method is usually used to decode potentially nullable data:
Decodes the null
value and returns it.
Decodes nullable value of the type T with the given deserializer.
Decodes the nullable value of type T by delegating the decoding process to the given deserializer.
Checks whether the current decoder supports strictly ordered decoding of the data without calling to decodeElementIndex. If the method returns true
, the caller might skip decodeElementIndex calls and start invoking decode*Element
directly, incrementing the index of the element one by one. This method can be called by serializers (either generated or user-defined) as a performance optimization, but there is no guarantee that the method will be ever called. Practically, it means that implementations that may benefit from sequential decoding should also support a regular decodeElementIndex-based decoding as well.
Decodes value of the type T with the given deserializer.
Decodes the value of type T by delegating the decoding process to the given deserializer. For example, decodeInt
call is equivalent to delegating integer decoding to Int.serializer: decodeSerializableValue(Int.serializer())
Decodes a 16-bit short value. Corresponding kind is PrimitiveKind.SHORT.
Decodes a 16-bit short value from the underlying input. The resulting value is associated with the descriptor element at the given index. The element at the given index should have PrimitiveKind.SHORT kind.
Decodes a string value. Corresponding kind is PrimitiveKind.STRING.
Decodes a string value from the underlying input. The resulting value is associated with the descriptor element at the given index. The element at the given index should have PrimitiveKind.STRING kind.
Begins a structure, decodes it using the given block, ends it and returns decoded element.
Invoked to decode a value when specialized decode*
method was not overridden.
Denotes the end of the structure associated with current decoder. For example, composite decoder of JSON format will expect (and parse) a closing bracket in the underlying input.