use of jakarta.mail.search.SearchTerm in project exist by eXist-db.
the class MessageListFunctions method parseSubjectTerm.
private SearchTerm parseSubjectTerm(Node terms) throws XPathException {
SearchTerm st = null;
String pattern = ((Element) terms).getAttribute("pattern");
if (pattern != null && !pattern.isEmpty()) {
st = new SubjectTerm(pattern);
} else {
throw (new XPathException(this, "Pattern attribute must be specified for term with type: " + ((Element) terms).getAttribute("type")));
}
return (st);
}
use of jakarta.mail.search.SearchTerm in project exist by eXist-db.
the class MessageListFunctions method parseBodyTerm.
private SearchTerm parseBodyTerm(Node terms) throws XPathException {
SearchTerm st = null;
String pattern = ((Element) terms).getAttribute("pattern");
if (pattern != null && !pattern.isEmpty()) {
st = new BodyTerm(pattern);
} else {
throw (new XPathException(this, "Pattern attribute must be specified for term with type: " + ((Element) terms).getAttribute("type")));
}
return (st);
}
use of jakarta.mail.search.SearchTerm in project exist by eXist-db.
the class MessageListFunctions method parseSentDateTerm.
private SearchTerm parseSentDateTerm(Node terms) throws XPathException {
SearchTerm st = null;
String value = ((Element) terms).getAttribute("date");
String format = ((Element) terms).getAttribute("format");
if (StringUtils.isEmpty(value)) {
throw (new XPathException(this, "value not specified for term with type: " + ((Element) terms).getAttribute("type")));
}
if (StringUtils.isEmpty(format)) {
throw (new XPathException(this, "format not specified for term with type: " + ((Element) terms).getAttribute("type")));
}
int cp = parseComparisonAttribute(terms);
try {
SimpleDateFormat sdf = new SimpleDateFormat(format);
Date date = sdf.parse(value);
st = new SentDateTerm(cp, date);
} catch (ParseException pe) {
throw (new XPathException(this, "Cannot parse date value: " + value + ", using format: " + format + ", for term with type: " + ((Element) terms).getAttribute("type")));
}
return (st);
}
use of jakarta.mail.search.SearchTerm in project exist by eXist-db.
the class MessageListFunctions method parseFromTerm.
private SearchTerm parseFromTerm(Node terms) throws XPathException {
SearchTerm st = null;
String pattern = ((Element) terms).getAttribute("pattern");
if (pattern != null && !pattern.isEmpty()) {
st = new FromStringTerm(pattern);
} else {
throw (new XPathException(this, "Pattern attribute must be specified for term with type: " + ((Element) terms).getAttribute("type")));
}
return (st);
}
use of jakarta.mail.search.SearchTerm in project exist by eXist-db.
the class MessageListFunctions method parseRecipientTerm.
private SearchTerm parseRecipientTerm(Node terms) throws XPathException {
SearchTerm st = null;
String pattern = ((Element) terms).getAttribute("pattern");
String type = ((Element) terms).getAttribute("recipientType");
if (StringUtils.isEmpty(type)) {
throw (new XPathException(this, "recipientType not specified for term with type: " + ((Element) terms).getAttribute("type")));
}
if (pattern != null && !pattern.isEmpty()) {
Message.RecipientType rtype = null;
if (type.equalsIgnoreCase("to")) {
rtype = Message.RecipientType.TO;
} else if (type.equalsIgnoreCase("cc")) {
rtype = Message.RecipientType.CC;
} else if (type.equalsIgnoreCase("bcc")) {
rtype = Message.RecipientType.BCC;
} else {
throw (new XPathException(this, "Invalid recipientType: " + type + ", for term with type: " + ((Element) terms).getAttribute("type")));
}
st = new RecipientStringTerm(rtype, pattern);
} else {
throw (new XPathException(this, "Pattern attribute must be specified for term with type: " + ((Element) terms).getAttribute("type")));
}
return (st);
}
Aggregations