getAtom method

dynamic getAtom(
  1. String code
)

Search appropriate object value by code name in object tree.

Throws DmapDecodeException in case of unknown code.

Implementation

dynamic getAtom(String code) {
  if (dmapCodeTypes.containsKey(code)) {
    var dmapCode = dmapCodeTypes[code]!;
    if (this.code == dmapCode) {
      if (this.code.type == container) {
        return this;
      }
      return value;
    }
    // check children
    if ((this.code.type == container) && value.length > 0) {
      for (var object in value) {
        var value = object.getAtom(code);
        if (value != null) {
          return value;
        }
      }
    }
    return null;
  } else {
    throw DmapDecodeException(
        "'$code' was not found in actual DMAP codes list.");
  }
}