CompositeDecoder
CompositeDecoder is a part of decoding process that is bound to a particular structured part of the serialized form, described by the serial descriptor passed to Decoder.beginStructure.
Typically, for unordered data, CompositeDecoder is used by a serializer withing a decodeElementIndex-based loop that decodes all the required data one-by-one in any order and then terminates by calling endStructure. Please refer to decodeElementIndex for example of such loop.
All decode*
methods have index
and serialDescriptor
parameters with a strict semantics and constraints:
descriptor
argument is always the same as one used in Decoder.beginStructure.index
of the element being decoded. For sequential decoding, it is always a monotonic sequence from0
todescriptor.elementsCount
and for indexing-loop it is always an index that decodeElementIndex has returned from the last call.
The symmetric interface for the serialization process is CompositeEncoder.
Not stable for inheritance
CompositeDecoder
interface is not stable for inheritance in 3rd party libraries, as new methods might be added to this interface or contracts of the existing methods can be changed.
Inheritors
Types
Results of decodeElementIndex used for decoding control flow.
Properties
Functions
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 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 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 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 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. Serializable value class is described by the child descriptor of given descriptor at index.
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 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.
Decodes nullable value of the type T with 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 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 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.
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.