Java 类javax.mail.search.OrTerm 实例源码

项目:Java-9-Programming-Blueprints    文件:RuleTest.java   
@Test
public void multipleFieldsShouldReturnOrTerm() {
    final Set fields = new HashSet();
    fields.add("to");
    fields.add("from");
    fields.add("cc");

    Rule rule = Rule.create()
            .sourceFolder("INBOX")
            .matchingText("testText")
            .fields(fields);
    SearchTerm term = rule.getSearchTerm();
    Assert.assertTrue(term instanceof OrTerm);
    SearchTerm[] terms = ((OrTerm) term).getTerms();
    for (SearchTerm t : terms) {
        Assert.assertTrue(t instanceof FromStringTerm
                || (t instanceof RecipientStringTerm && ((RecipientStringTerm) t).getRecipientType() == Message.RecipientType.CC)
                || (t instanceof RecipientStringTerm && ((RecipientStringTerm) t).getRecipientType() == Message.RecipientType.TO));
    }
}
项目:tabellarium    文件:ImapMailboxFolderTaskExecutor.java   
/**
 * Returns a <pre>{@link SearchTerm}</pre> to be used when retrieving messages.
 * Default term is only for unseen emails, but when retrieveSeenEmails is
 * set to true it returns a union of terms for both unseen and seen messages.
 *
 * @return a search term to be used for message retrieval.
 */
private SearchTerm getSearchTerm() {
    Flags seenFlag = new Flags(Flag.SEEN);
    FlagTerm unseenFlagTerm = new FlagTerm(seenFlag, false);
    if (retrieveSeenEmails) {
        FlagTerm seenFlagTerm = new FlagTerm(seenFlag, true);
        return new OrTerm(unseenFlagTerm, seenFlagTerm);
    }
    return unseenFlagTerm;
}
项目:camunda-bpm-mail    文件:DeleteMailConnector.java   
protected Message[] getMessagesByIds(Folder folder, List<String> messageIds) throws MessagingException {

    List<MessageIDTerm> idTerms = messageIds.stream()
        .map(MessageIDTerm::new)
        .collect(Collectors.toList());

    OrTerm searchTerm = new OrTerm(idTerms.toArray(new MessageIDTerm[idTerms.size()]));

    return folder.search(searchTerm);
  }