parse method
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('smtp:') || rawText.startsWith('SMTP:'))) {
return null;
}
String emailAddress = rawText.substring(5);
String? subject;
String? body;
int colon = emailAddress.indexOf(':');
if (colon >= 0) {
subject = emailAddress.substring(colon + 1);
emailAddress = emailAddress.substring(0, colon);
colon = subject.indexOf(':');
if (colon >= 0) {
body = subject.substring(colon + 1);
subject = subject.substring(0, colon);
}
}
return EmailAddressParsedResult([emailAddress], null, null, subject, body);
}