Status.fromXML constructor

Status.fromXML(
  1. String xmlSTR
)

Implementation

factory Status.fromXML(String xmlSTR) {
  final document = XmlDocument.parse(xmlSTR);
  String typeCode = document.firstElementChild!.name.toString().substring(0, 2);
  switch (typeCode) {
    case "bp":
      return BpStatus.fromXML(xmlSTR);
    case "bt":
      return BtStatus.fromXML(xmlSTR);
    case "bg":
      return BgStatus.fromXML(xmlSTR);
    case "bc":
      return BcStatus.fromXML(xmlSTR);
    case "be":
      return BeStatus.fromXML(xmlSTR);
    case "dd":
      return DdStatus.fromXML(xmlSTR);
    case "zl":
      return ZlStatus.fromXML(xmlSTR);
    case "zi":
      return ZiStatus.fromXML(xmlSTR);
    case "pr":
      return PrStatus.fromXML(xmlSTR);
    case "oc":
      return OcStatus.fromXML(xmlSTR);
    case "ms":
      return MsStatus.fromXML(xmlSTR);
  }

  String desc =
      document.firstChild!.attributes.firstWhere((element) => element.name.toString() == "desc", orElse: orElseEmpty).value;
  String init = document.firstChild!.attributes.firstWhere((element) => element.name.toString() == "init").value;
  String powerOff = document.firstChild!.attributes.firstWhere((element) => element.name.toString() == "powerOff").value;
  String ready = document.firstChild!.attributes.firstWhere((element) => element.name.toString() == "ready").value;
  String unknown = document.firstChild!.attributes.firstWhere((element) => element.name.toString() == "unknown").value;
  return BcStatus(desc: desc, init: init, powerOff: powerOff, ready: ready, unknown: unknown);
}