parse method

  1. @override
EmailAddressParsedResult? parse(
  1. Result result
)
override

Attempts to parse the raw Result's contents as a particular type of information (email, URL, etc.) and return a ParsedResult encapsulating the result of parsing.

@param theResult the raw Result to parse @return ParsedResult encapsulating the parsing result

Implementation

@override
EmailAddressParsedResult? parse(Result result) {
  final rawText = ResultParser.getMassagedText(result);
  if (!rawText.startsWith('MATMSG:')) {
    return null;
  }
  final tos = matchDoCoMoPrefixedField('TO:', rawText);
  if (tos == null) {
    return null;
  }
  for (String to in tos) {
    if (!isBasicallyValidEmailAddress(to)) {
      return null;
    }
  }
  final subject = matchSingleDoCoMoPrefixedField('SUB:', rawText, false);
  final body = matchSingleDoCoMoPrefixedField('BODY:', rawText, false);
  return EmailAddressParsedResult(tos, null, null, subject, body);
}