fromByteArrayStream static method

Future<NodeImpl> fromByteArrayStream(
  1. ByteStream in_
)
override

Deserializes a NodeValue from a byteStream.

@param in the stream to be read @return the deserialized NodeValue @throws IOException if an exception happens deserializing the stream

Implementation

static Future<NodeImpl> fromByteArrayStream(ByteStream in_) async {
  if (await SerializerHelper.readLong(in_) != serialversionUID) {
    throw Exception('failed to parse NodeImpl (bad stream?)');
  }
  var skel = (await SerializerHelper.readInt(in_) == 1);
  var n = NodeImpl(await SerializerHelper.readString(in_) ?? '', 'NONE');
  n._skeleton.set(skel);
  if (skel) {
    // TODO: provide controller via parameter
    n.controller = GenericController.getDefault();
  }
  int counter = await SerializerHelper.readInt(in_);
  for (var i = 0; i < counter; i++) {
    n._ordinals[
        Field.fromString(await SerializerHelper.readString(in_) ?? '') ??
            Field.owner] = await SerializerHelper.readString(in_) ?? '';
  }
  if (!skel) {
    counter = await SerializerHelper.readInt(in_);
    for (var i = 0; i < counter; i++) {
      n._values[await SerializerHelper.readString(in_) ?? ''] =
          await NodeValueImpl.fromByteArrayStream(in_);
    }
  }
  counter = await SerializerHelper.readInt(in_);
  for (var i = 0; i < counter; i++) {
    n._childNodes[await SerializerHelper.readString(in_) ?? ''] =
        await NodeImpl.fromByteArrayStream(in_);
  }
  if (await SerializerHelper.readLong(in_) != serialversionUID) {
    throw Exception('failed to parse NodeImpl (bad stream end?)');
  }
  return n;
}