deserialize static method

CoapRemoteResource deserialize(
  1. String linkFormat
)

Deserialize

Implementation

static CoapRemoteResource deserialize(final String linkFormat) {
  final root = CoapRemoteResource('');
  final scanner = CoapScanner(linkFormat);
  while (scanner.scan(resourceNameRegex)) {
    final matched = scanner.lastMatch!;
    var path = matched.group(0)!;
    path = path.substring(1, path.length - 1);
    // Retrieve specified resource, create if necessary
    final resource = CoapRemoteResource(path);
    if (scanner.position == linkFormat.length) {
      root.addSubResource(resource);
      break;
    }
    while (scanner.readChar() == separator.codeUnitAt(0)) {
      final attr = parseAttribute(scanner);
      addAttribute(resource.attributes as HashSet<CoapLinkAttribute>, attr!);
      // ignore: invariant_booleans
      if (scanner.position == linkFormat.length) {
        break;
      }
    }
    root.addSubResource(resource);
  }
  return root;
}