parseAttribute static method
Parse attribute
Implementation
static CoapLinkAttribute? parseAttribute(final CoapScanner scanner) {
if (scanner.scan(wordRegex)) {
final matched = scanner.lastMatch!;
final name = matched.group(0);
Object? value;
value = true;
// check for name-value-pair
if (scanner.scan(equalRegex)) {
if (scanner.matches(quotedStringRegex)) {
scanner.scan(quotedStringRegex);
final matched = scanner.lastMatch!;
final s = matched.group(0)!;
value = s.substring(1, s.length - 1);
} else if (scanner.matches(cardinalRegex)) {
scanner.scan(cardinalRegex);
final matched = scanner.lastMatch!;
final num = matched.group(0)!;
value = int.tryParse(num);
value ??= 0;
} else {
value = scanner.takeUntil(';');
}
}
return CoapLinkAttribute(name!, value);
}
return null;
}