com.openexchange.mail.search
Class ORTerm

java.lang.Object
  extended by com.openexchange.mail.search.SearchTerm<SearchTerm<?>[]>
      extended by com.openexchange.mail.search.ORTerm
All Implemented Interfaces:
java.io.Serializable

public final class ORTerm
extends SearchTerm<SearchTerm<?>[]>

ORTerm

Author:
Thorben Betten
See Also:
Serialized Form

Constructor Summary
ORTerm(SearchTerm<?> firstTerm, SearchTerm<?> secondTerm)
          Initializes a new ORTerm
 
Method Summary
 void addMailField(java.util.Collection<MailField> col)
          Adds the addressed MailField to specified collection
 boolean containsWildcard()
          Checks if this search term's pattern contains wildcard characters '*' and '?'
 SearchTerm<?> filter(java.util.Set<java.lang.Class<? extends SearchTerm>> filterSet)
          Generates a search term with the unsupported search terms specified through filter removed.
 javax.mail.search.SearchTerm getJavaMailSearchTerm()
          Generates the corresponding JavaMail instance of SearchTerm from this search term
 javax.mail.search.SearchTerm getNonWildcardJavaMailSearchTerm()
          Generates the corresponding instance of SearchTerm from this search term without any wildcard characters.
 SearchTerm<?>[] getPattern()
          Gets the search terms that should be linked with an OR as an array of SearchTerm with length 2.
 boolean isAscii()
          Checks if this search term's pattern only consists of ASCII 7 bit characters.
 boolean matches(MailMessage mailMessage)
          Checks if specified mail message matches this search term
 boolean matches(javax.mail.Message msg)
          Checks if given message matches this search term
 void setFirstTerm(SearchTerm<?> firstTerm)
          Sets the first search term
 void setSecondTerm(SearchTerm<?> secondTerm)
          Sets the second search term
 
Methods inherited from class com.openexchange.mail.search.SearchTerm
filter
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ORTerm

public ORTerm(SearchTerm<?> firstTerm,
              SearchTerm<?> secondTerm)
Initializes a new ORTerm

Method Detail

getPattern

public SearchTerm<?>[] getPattern()
Gets the search terms that should be linked with an OR as an array of SearchTerm with length 2.

Specified by:
getPattern in class SearchTerm<SearchTerm<?>[]>
Returns:
The terms that should be linked with an OR

setFirstTerm

public void setFirstTerm(SearchTerm<?> firstTerm)
Sets the first search term

Parameters:
firstTerm - The first search term

setSecondTerm

public void setSecondTerm(SearchTerm<?> secondTerm)
Sets the second search term

Parameters:
secondTerm - The second search term

addMailField

public void addMailField(java.util.Collection<MailField> col)
Description copied from class: SearchTerm
Adds the addressed MailField to specified collection

Specified by:
addMailField in class SearchTerm<SearchTerm<?>[]>
Parameters:
col - The collection which gathers addressed fields

getJavaMailSearchTerm

public javax.mail.search.SearchTerm getJavaMailSearchTerm()
Description copied from class: SearchTerm
Generates the corresponding JavaMail instance of SearchTerm from this search term

Specified by:
getJavaMailSearchTerm in class SearchTerm<SearchTerm<?>[]>
Returns:
The corresponding instance of SearchTerm

getNonWildcardJavaMailSearchTerm

public javax.mail.search.SearchTerm getNonWildcardJavaMailSearchTerm()
Description copied from class: SearchTerm
Generates the corresponding instance of SearchTerm from this search term without any wildcard characters.

This is useful to preselect possible positives and to manually filtering out false positives.

Specified by:
getNonWildcardJavaMailSearchTerm in class SearchTerm<SearchTerm<?>[]>
Returns:
The corresponding instance of SearchTerm without any wildcard characters.
See Also:
SearchTerm.containsWildcard()

matches

public boolean matches(javax.mail.Message msg)
                throws MailException
Description copied from class: SearchTerm
Checks if given message matches this search term

Specified by:
matches in class SearchTerm<SearchTerm<?>[]>
Parameters:
msg - The message to check
Returns:
true if message matches this search term; otherwise false
Throws:
MailException - If check fails

matches

public boolean matches(MailMessage mailMessage)
                throws MailException
Description copied from class: SearchTerm
Checks if specified mail message matches this search term

Specified by:
matches in class SearchTerm<SearchTerm<?>[]>
Parameters:
mailMessage - The mail message to check
Returns:
true if specified mail message matches this search term; otherwise false
Throws:
MailException - If checking mail message against search term fails

filter

public SearchTerm<?> filter(java.util.Set<java.lang.Class<? extends SearchTerm>> filterSet)
Description copied from class: SearchTerm
Generates a search term with the unsupported search terms specified through filter removed.

For each search term contained in this search term the following rule is applied:

  1. If search term is an instance of ORTerm or ANDTerm replace the unsupported with:
  2. If search term is supported, return the search term itself
  3. Otherwise replace with BooleanTerm.FALSE

Note: Only a shallow copy is generated; meaning further working on this search term may influence return value's search term.

Overrides:
filter in class SearchTerm<SearchTerm<?>[]>
Parameters:
filterSet - The filter set containing classes unsupported search terms
Returns:
A new search term with the unsupported search terms removed

isAscii

public boolean isAscii()
Description copied from class: SearchTerm
Checks if this search term's pattern only consists of ASCII 7 bit characters.

This method implies that this search is some kind of string search term. Returns true if not appropriate.

Overrides:
isAscii in class SearchTerm<SearchTerm<?>[]>
Returns:
true if search term's pattern only consists of ASCII 7 bit characters; otherwise false

containsWildcard

public boolean containsWildcard()
Description copied from class: SearchTerm
Checks if this search term's pattern contains wildcard characters '*' and '?'.

This method implies that this search is some kind of string search term. Returns false if not appropriate.

Overrides:
containsWildcard in class SearchTerm<SearchTerm<?>[]>
Returns:
true if this search term's pattern contains wildcard characters; otherwise false