public class SearchQuery extends Object
Models a query used to search for messages. A query is the logical
AND
of the contained criteria.
Each Criterion
is composed of an Operator
(combining value and operation) together with field information (optional
since the criteria type may imply a particular field). Factory methods are
provided for criteria.
Modifier and Type | Class and Description |
---|---|
static class |
SearchQuery.AddressOperator |
static class |
SearchQuery.AddressType |
static class |
SearchQuery.AllCriterion
Any message.
|
static class |
SearchQuery.BooleanOperator
Boolean value search.
|
static class |
SearchQuery.Conjunction |
static class |
SearchQuery.ConjunctionCriterion
Conjunction applying to the contained criteria.
|
static class |
SearchQuery.ContainsOperator
Contained value search.
|
static class |
SearchQuery.Criterion
Marker superclass for criteria.
|
static class |
SearchQuery.CustomFlagCriterion
Filters on a custom flag valuation.
|
static class |
SearchQuery.DateComparator |
static class |
SearchQuery.DateOperator
Operates on a date.
|
static class |
SearchQuery.DateResolution
The Resolution which should get used for
Date searches |
static class |
SearchQuery.ExistsOperator
Existance search.
|
static class |
SearchQuery.FlagCriterion
Filters on a standard flag.
|
static class |
SearchQuery.HeaderCriterion
Header value content search.
|
static interface |
SearchQuery.HeaderOperator
Marks operator as suitable for header value searching.
|
static class |
SearchQuery.InOperator
Search for numbers within set of ranges.
|
static class |
SearchQuery.InternalDateCriterion
Filters on the internal date.
|
static class |
SearchQuery.ModSeqCriterion
Filters on the mod-sequence of the messages.
|
static class |
SearchQuery.NumericComparator |
static class |
SearchQuery.NumericOperator
Searches numeric values.
|
static class |
SearchQuery.NumericRange
Numbers within a particular range.
|
static interface |
SearchQuery.Operator
Search operator.
|
static class |
SearchQuery.Scope |
static class |
SearchQuery.SizeCriterion |
static class |
SearchQuery.Sort
Allow to sort a
SearchQuery response in different ways. |
static class |
SearchQuery.TextCriterion
Message text.
|
static class |
SearchQuery.UidCriterion
Filters on message identity.
|
Constructor and Description |
---|
SearchQuery() |
Modifier and Type | Method and Description |
---|---|
void |
addRecentMessageUids(Collection<Long> uids)
Adds all the uids to the collection of recents.
|
static SearchQuery.Criterion |
address(SearchQuery.AddressType type,
String address)
Creates a filter matching messages whose Address header contains the given address.
|
static SearchQuery.Criterion |
all()
Creates a filter matching all messages.
|
static SearchQuery.Criterion |
and(List<SearchQuery.Criterion> criteria)
Creates a filter composing the listed criteria.
|
static SearchQuery.Criterion |
and(SearchQuery.Criterion one,
SearchQuery.Criterion two)
Creates a filter composing the two different criteria.
|
void |
andCriteria(SearchQuery.Criterion crit) |
static SearchQuery.Criterion |
bodyContains(String value)
Creates a filter matching messages which contains the given text within
the body.
|
boolean |
equals(Object obj) |
static SearchQuery.Criterion |
flagIsSet(javax.mail.Flags.Flag flag)
Creates a filter on the given flag selecting messages where the given
flag is selected.
|
static SearchQuery.Criterion |
flagIsSet(String flag)
Creates a filter on the given flag selecting messages where the given
flag is selected.
|
static SearchQuery.Criterion |
flagIsUnSet(javax.mail.Flags.Flag flag)
Creates a filter on the given flag selecting messages where the given
flag is not selected.
|
static SearchQuery.Criterion |
flagIsUnSet(String flag)
Creates a filter on the given flag selecting messages where the given
flag is not selected.
|
static SearchQuery.Criterion |
flagSet(javax.mail.Flags.Flag flag,
boolean isSet)
Creates a filter on the given flag.
|
static SearchQuery.Criterion |
flagSet(String flag,
boolean isSet)
Creates a filter on the given flag.
|
List<SearchQuery.Criterion> |
getCriterias() |
Set<Long> |
getRecentMessageUids()
Gets the UIDS of messages which are recent for this client session.
|
List<SearchQuery.Sort> |
getSorts()
Return the
SearchQuery.Sort 's which should get used for sorting the result. |
int |
hashCode() |
static SearchQuery.Criterion |
headerContains(String headerName,
String value)
Creates a filter matching messages whose header value contains the given
value.
|
static SearchQuery.Criterion |
headerDateAfter(String headerName,
Date date,
SearchQuery.DateResolution res)
Creates a filter matching messages with the date of the given header
after the given date.
|
static SearchQuery.Criterion |
headerDateBefore(String headerName,
Date date,
SearchQuery.DateResolution res)
Creates a filter matching messages with the date of the given header
before the given date.
|
static SearchQuery.Criterion |
headerDateOn(String headerName,
Date date,
SearchQuery.DateResolution res)
Creates a filter matching messages with the date of the given header on
the given date.
|
static SearchQuery.Criterion |
headerExists(String headerName)
Creates a filter matching messages with a header matching the given name.
|
static SearchQuery.Criterion |
internalDateAfter(Date date,
SearchQuery.DateResolution res)
Creates a filter matching messages with internal date after the given
date.
|
static SearchQuery.Criterion |
internalDateBefore(Date date,
SearchQuery.DateResolution res)
Creates a filter matching messages with internal date before the given
date.
|
static SearchQuery.Criterion |
internalDateOn(Date date,
SearchQuery.DateResolution res)
Creates a filter matching messages with internal date on the given date.
|
static SearchQuery.Criterion |
mailContains(String value)
Creates a filter matching messages which contains the given text either
within the body or in the headers.
|
static SearchQuery.Criterion |
modSeqEquals(long value)
Creates a filter for message mod-sequence equal to the given value
|
static SearchQuery.Criterion |
modSeqGreaterThan(long value)
Creates a filter for message mod-sequence greater than the given value
|
static SearchQuery.Criterion |
modSeqLessThan(long value)
Creates a filter for message mod-sequence less than the given value
|
static SearchQuery.Criterion |
not(SearchQuery.Criterion criterion)
Creates a filter inverting the given criteria.
|
static SearchQuery.Criterion |
or(SearchQuery.Criterion one,
SearchQuery.Criterion two)
Creates a filter composing the two different criteria.
|
void |
setSorts(List<SearchQuery.Sort> sorts)
Set the
SearchQuery.Sort 's to use |
static SearchQuery.Criterion |
sizeEquals(long value)
Creates a filter for message size equal to the given value
|
static SearchQuery.Criterion |
sizeGreaterThan(long value)
Creates a filter for message size greater than the given value
|
static SearchQuery.Criterion |
sizeLessThan(long value)
Creates a filter for message size less than the given value
|
String |
toString() |
static SearchQuery.Criterion |
uid(SearchQuery.NumericRange[] range)
Creates a filter matching messages within any of the given ranges.
|
public static final SearchQuery.Criterion sizeLessThan(long value)
value
- messages with size less than this value will be selected by
the returned criterionCriterion
, not nullpublic static final SearchQuery.Criterion sizeGreaterThan(long value)
value
- messages with size greater than this value will be selected by
the returned criterionCriterion
, not nullpublic static final SearchQuery.Criterion sizeEquals(long value)
value
- messages with size equal to this value will be selected by the
returned criterionCriterion
, not nullpublic static final SearchQuery.Criterion modSeqLessThan(long value)
value
- messages with mod-sequence less than this value will be selected by
the returned criterionCriterion
, not nullpublic static final SearchQuery.Criterion modSeqGreaterThan(long value)
value
- messages with mod-sequence greater than this value will be selected by
the returned criterionCriterion
, not nullpublic static final SearchQuery.Criterion modSeqEquals(long value)
value
- messages with mod-sequence equal to this value will be selected by the
returned criterionCriterion
, not nullpublic static final SearchQuery.Criterion internalDateAfter(Date date, SearchQuery.DateResolution res)
date
- given dateres
- the date resolution, either SearchQuery.DateResolution.Year
, SearchQuery.DateResolution.Month
, SearchQuery.DateResolution.Day
,
SearchQuery.DateResolution.Hour
, SearchQuery.DateResolution.Minute
or SearchQuery.DateResolution.Second
Criterion
, not nullpublic static final SearchQuery.Criterion internalDateOn(Date date, SearchQuery.DateResolution res)
date
- given dateres
- the date resolution, either SearchQuery.DateResolution.Year
, SearchQuery.DateResolution.Month
, SearchQuery.DateResolution.Day
,
SearchQuery.DateResolution.Hour
, SearchQuery.DateResolution.Minute
or SearchQuery.DateResolution.Second
Criterion
, not nullpublic static final SearchQuery.Criterion internalDateBefore(Date date, SearchQuery.DateResolution res)
date
- given dateres
- the date resolution, either SearchQuery.DateResolution.Year
, SearchQuery.DateResolution.Month
, SearchQuery.DateResolution.Day
,
SearchQuery.DateResolution.Hour
, SearchQuery.DateResolution.Minute
or SearchQuery.DateResolution.Second
Criterion
, not nullpublic static final SearchQuery.Criterion headerDateAfter(String headerName, Date date, SearchQuery.DateResolution res)
headerName
- name of the header whose value will be compared, not nulldate
- given dateres
- the date resolution, either SearchQuery.DateResolution.Year
, SearchQuery.DateResolution.Month
, SearchQuery.DateResolution.Day
,
SearchQuery.DateResolution.Hour
, SearchQuery.DateResolution.Minute
or SearchQuery.DateResolution.Second
Criterion
, not nullpublic static final SearchQuery.Criterion headerDateOn(String headerName, Date date, SearchQuery.DateResolution res)
headerName
- name of the header whose value will be compared, not nulldate
- given dateres
- the date resolution, either SearchQuery.DateResolution.Year
, SearchQuery.DateResolution.Month
, SearchQuery.DateResolution.Day
,
SearchQuery.DateResolution.Hour
, SearchQuery.DateResolution.Minute
or SearchQuery.DateResolution.Second
Criterion
, not nullpublic static final SearchQuery.Criterion headerDateBefore(String headerName, Date date, SearchQuery.DateResolution res)
headerName
- name of the header whose value will be compared, not nulldate
- given dateres
- the date resolution, either SearchQuery.DateResolution.Year
, SearchQuery.DateResolution.Month
, SearchQuery.DateResolution.Day
,
SearchQuery.DateResolution.Hour
, SearchQuery.DateResolution.Minute
or SearchQuery.DateResolution.Second
Criterion
, not nullpublic static final SearchQuery.Criterion address(SearchQuery.AddressType type, String address)
type
- address
- Criterion
public static final SearchQuery.Criterion headerContains(String headerName, String value)
headerName
- name of the header whose value will be compared, not nullvalue
- when null or empty the existance of the header will be
checked, otherwise contained valueCriterion
, not nullpublic static final SearchQuery.Criterion headerExists(String headerName)
headerName
- name of the header whose value will be compared, not nullCriterion
, not nullpublic static final SearchQuery.Criterion mailContains(String value)
value
- search valueCriterion
, not nullpublic static final SearchQuery.Criterion bodyContains(String value)
value
- search valueCriterion
, not nullpublic static final SearchQuery.Criterion uid(SearchQuery.NumericRange[] range)
range
- NumericRange
's, not nullCriterion
, not nullpublic static final SearchQuery.Criterion or(SearchQuery.Criterion one, SearchQuery.Criterion two)
one
- Criterion
, not nulltwo
- Criterion
, not nullCriterion
, not nullpublic static final SearchQuery.Criterion and(SearchQuery.Criterion one, SearchQuery.Criterion two)
one
- Criterion
, not nulltwo
- Criterion
, not nullCriterion
, not nullpublic static final SearchQuery.Criterion and(List<SearchQuery.Criterion> criteria)
criteria
- List
of SearchQuery.Criterion
Criterion
, not nullpublic static final SearchQuery.Criterion not(SearchQuery.Criterion criterion)
criterion
- Criterion
, not nullCriterion
, not nullpublic static final SearchQuery.Criterion flagSet(javax.mail.Flags.Flag flag, boolean isSet)
flag
- Flag
, not nullisSet
- true if the messages with the flag set should be matched,
false otherwiseCriterion
, not nullpublic static final SearchQuery.Criterion flagIsSet(javax.mail.Flags.Flag flag)
flag
- Flag
, not nullCriterion
, not nullpublic static final SearchQuery.Criterion flagIsUnSet(javax.mail.Flags.Flag flag)
flag
- Flag
, not nullCriterion
, not nullpublic static final SearchQuery.Criterion flagSet(String flag, boolean isSet)
flag
- Flag
, not nullisSet
- true if the messages with the flag set should be matched,
false otherwiseCriterion
, not nullpublic static final SearchQuery.Criterion flagIsSet(String flag)
flag
- Flag
, not nullCriterion
, not nullpublic static final SearchQuery.Criterion flagIsUnSet(String flag)
flag
- Flag
, not nullCriterion
, not nullpublic static final SearchQuery.Criterion all()
Criterion
, not nullpublic void andCriteria(SearchQuery.Criterion crit)
public List<SearchQuery.Criterion> getCriterias()
public void setSorts(List<SearchQuery.Sort> sorts)
SearchQuery.Sort
's to usesorts
- public List<SearchQuery.Sort> getSorts()
SearchQuery.Sort
's which should get used for sorting the result. They get "executed" in a chain, if the first does not
give an result the second will get executed etc.
If not set via setSorts(List)
it will sort via SearchQuery.Sort.SortClause.Uid
public Set<Long> getRecentMessageUids()
Set
of Long
UIDSpublic void addRecentMessageUids(Collection<Long> uids)
uids
- not nullpublic int hashCode()
hashCode
in class Object
Object.hashCode()
public boolean equals(Object obj)
equals
in class Object
Object.equals(java.lang.Object)
Copyright © 2010-2012 The Apache Software Foundation. All Rights Reserved.