Example usage for javax.mail.search NotTerm NotTerm

List of usage examples for javax.mail.search NotTerm NotTerm

Introduction

In this page you can find the example usage for javax.mail.search NotTerm NotTerm.

Prototype

public NotTerm(SearchTerm t) 

Source Link

Usage

From source file:org.exist.xquery.modules.mail.MessageListFunctions.java

private SearchTerm parseSearchTerms(Node terms) throws XPathException {
    SearchTerm st = null;/*from www.j  av a  2  s .c o  m*/

    if (terms.getNodeType() == Node.ELEMENT_NODE && terms.getLocalName().equalsIgnoreCase("searchTerm")) {
        String type = ((Element) terms).getAttribute("type");

        if (type != null) {
            if (type.equalsIgnoreCase("not")) {
                st = new NotTerm(parseChildSearchTerm(terms));
            } else if (type.equalsIgnoreCase("and")) {
                st = new AndTerm(parseChildSearchTerms(terms));
            } else if (type.equalsIgnoreCase("or")) {
                st = new OrTerm(parseChildSearchTerms(terms));
            } else if (type.equalsIgnoreCase("from")) {
                st = parseFromTerm(terms);
            } else if (type.equalsIgnoreCase("subject")) {
                st = parseSubjectTerm(terms);
            } else if (type.equalsIgnoreCase("body")) {
                st = parseBodyTerm(terms);
            } else if (type.equalsIgnoreCase("to") || type.equalsIgnoreCase("recipient")) {
                st = parseRecipientTerm(terms);
            } else if (type.equalsIgnoreCase("header")) {
                st = parseHeaderTerm(terms);
            } else if (type.equalsIgnoreCase("flag")) {
                st = parseFlagTerm(terms);
            } else if (type.equalsIgnoreCase("sent")) {
                st = parseSentDateTerm(terms);
            } else if (type.equalsIgnoreCase("received")) {
                st = parseReceivedDateTerm(terms);
            } else {
                throw (new XPathException(this, "Invalid Search Term type specified: " + type));
            }
        } else {
            throw (new XPathException(this, "Invalid Search Term type specified: null"));
        }
    }

    if (st == null) {
        throw (new XPathException(this, "Invalid Search Terms specified"));
    }

    return (st);
}

From source file:org.pentaho.di.job.entries.getpop.MailConnection.java

/**
 * Set filter on subject./*from w  ww  . ja  v a 2s  .c o m*/
 *
 * @param subject
 *          messages will be filtered on subject
 * @param notTerm
 *          negate condition
 */
public void setSubjectTerm(String subject, boolean notTerm) {
    if (!Utils.isEmpty(subject)) {
        if (notTerm) {
            addSearchTerm(new NotTerm(new SubjectTerm(subject)));
        } else {
            addSearchTerm(new SubjectTerm(subject));
        }
    }
}

From source file:org.pentaho.di.job.entries.getpop.MailConnection.java

/**
 * Search all messages with body containing the word bodyfilter
 *
 * @param bodyfilter//  w  w w.j  av a2  s. c om
 * @param notTerm
 *          negate condition
 */
public void setBodyTerm(String bodyfilter, boolean notTerm) {
    if (!Utils.isEmpty(bodyfilter)) {
        if (notTerm) {
            addSearchTerm(new NotTerm(new BodyTerm(bodyfilter)));
        } else {
            addSearchTerm(new BodyTerm(bodyfilter));
        }
    }
}

From source file:org.pentaho.di.job.entries.getpop.MailConnection.java

/**
 * Set filter on message sender./*from  www .  jav a 2s . co  m*/
 *
 * @param sender
 *          messages will be filtered on sender
 * @param notTerm
 *          negate condition
 */
public void setSenderTerm(String sender, boolean notTerm) {
    if (!Utils.isEmpty(sender)) {
        if (notTerm) {
            addSearchTerm(new NotTerm(new FromStringTerm(sender)));
        } else {
            addSearchTerm(new FromStringTerm(sender));
        }
    }
}