public class EmailFilter
extends java.lang.Object
EmailFilter
helps in building boolean queries of search terms.
There are two ways how it can be used, both can be combined.
First way is constructing boolean expression using groups.
Just use and(EmailFilter...)
, or(EmailFilter...)
and not(EmailFilter)
methods that takes any number
of filters that will be joined with chosen boolean operator.
Second way is more fluent. It may not be used to express some
complex queries, but for every-day use it would be enough.
Use methods and()
and or()
to define
how all next terms will be joined. Method not()
marks the one next term to be added as NOT term.
Modifier and Type | Class and Description |
---|---|
static class |
EmailFilter.Operator
Comparison operator.
|
Modifier and Type | Field and Description |
---|---|
protected javax.mail.search.SearchTerm |
searchTerm
The
SearchTerm to be used. |
Constructor and Description |
---|
EmailFilter() |
Modifier and Type | Method and Description |
---|---|
EmailFilter |
and()
Changes concatenation mode to AND.
|
EmailFilter |
and(EmailFilter... emailFilters)
Defines AND group of filters.
|
protected void |
and(javax.mail.search.SearchTerm searchTerm)
Sets
AndTerm as searchTerm. |
EmailFilter |
bcc(java.lang.String bccAddress)
Defines filter for BCC field.
|
EmailFilter |
cc(java.lang.String ccAddress)
Defines filter for CC field.
|
protected void |
concat(javax.mail.search.SearchTerm searchTerm)
Concatenates last search term with new one.
|
static EmailFilter |
filter()
Creates new Email filter.
|
EmailFilter |
flag(javax.mail.Flags.Flag flag,
boolean value)
Defines filter for single flag.
|
EmailFilter |
flags(javax.mail.Flags flags,
boolean value)
Defines filter for many flags at once.
|
EmailFilter |
from(java.lang.String fromAddress)
Defines filter for FROM field.
|
javax.mail.search.SearchTerm |
getSearchTerm()
Returns search term.
|
EmailFilter |
header(java.lang.String headerName,
java.lang.String pattern)
Defines filter for
Header . |
EmailFilter |
messageId(java.lang.String messageId)
Defines filter for message id.
|
EmailFilter |
messageNumber(int messageNumber)
Defines filteer for message number.
|
EmailFilter |
not()
Marks next condition to be NOT.
|
EmailFilter |
not(EmailFilter emailFilter)
Appends single filter as NOT.
|
EmailFilter |
or()
Changes concatenation mode to OR.
|
EmailFilter |
or(EmailFilter... emailFilters)
Defines OR group of filters.
|
protected void |
or(javax.mail.search.SearchTerm searchTerm)
Sets
OrTerm searchTerm. |
EmailFilter |
receivedDate(EmailFilter.Operator operator,
long milliseconds)
Defines filter for received date.
|
EmailFilter |
sentDate(EmailFilter.Operator operator,
long milliseconds)
Defines filter for sent date.
|
EmailFilter |
size(EmailFilter.Operator comparison,
int size)
Defines filter for message size.
|
EmailFilter |
subject(java.lang.String subject)
Defines filter for SUBJECT field.
|
EmailFilter |
text(java.lang.String pattern)
Defines filter on a message body.
|
EmailFilter |
to(java.lang.String toAddress)
Defines filter for TO field.
|
protected javax.mail.search.SearchTerm searchTerm
SearchTerm
to be used.public static EmailFilter filter()
public EmailFilter subject(java.lang.String subject)
subject
- The SUBJECT.public EmailFilter messageId(java.lang.String messageId)
messageId
- The message ID.public EmailFilter messageNumber(int messageNumber)
messageNumber
- The message number.public EmailFilter from(java.lang.String fromAddress)
fromAddress
- The FROM addresspublic EmailFilter to(java.lang.String toAddress)
toAddress
- The TO address.public EmailFilter cc(java.lang.String ccAddress)
ccAddress
- CC addreses.public EmailFilter bcc(java.lang.String bccAddress)
bccAddress
- BCC address.public EmailFilter flags(javax.mail.Flags flags, boolean value)
flags
- The Flags
to filter on.value
- The Flags.Flag
setting to check for.public EmailFilter flag(javax.mail.Flags.Flag flag, boolean value)
flag
- The flag to filter on.value
- The Flags.Flag
setting to check for.public EmailFilter receivedDate(EmailFilter.Operator operator, long milliseconds)
public EmailFilter sentDate(EmailFilter.Operator operator, long milliseconds)
operator
- EmailFilter.Operator
to use.milliseconds
- the milliseconds since January 1, 1970, 00:00:00 GMT.public EmailFilter text(java.lang.String pattern)
pattern
- String pattern use in body.public EmailFilter header(java.lang.String headerName, java.lang.String pattern)
Header
.headerName
- The name of the Header
.pattern
- String pattern to use for headerName.public EmailFilter size(EmailFilter.Operator comparison, int size)
comparison
- EmailFilter.Operator
.size
- size of message.public EmailFilter and()
public EmailFilter or()
public EmailFilter not()
public EmailFilter and(EmailFilter... emailFilters)
emailFilters
- array of EmailFilter
s to AND.public EmailFilter or(EmailFilter... emailFilters)
emailFilters
- array of EmailFilter
s to OR.public EmailFilter not(EmailFilter emailFilter)
emailFilter
- EmailFilter
to append.protected void concat(javax.mail.search.SearchTerm searchTerm)
searchTerm
- searchTerm SearchTerm
concatenate.and(SearchTerm)
,
or(SearchTerm)
protected void and(javax.mail.search.SearchTerm searchTerm)
AndTerm
as searchTerm.searchTerm
- SearchTerm
to set as AND.protected void or(javax.mail.search.SearchTerm searchTerm)
OrTerm
searchTerm.searchTerm
- SearchTerm
to set as OR.public javax.mail.search.SearchTerm getSearchTerm()
SearchTerm
.Copyright © 2003-present Jodd Team