/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* or packager/legal/LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at packager/legal/LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
/**
* This class traverses a search-tree and generates the
* corresponding IMAP search sequence.
*
* Each IMAPProtocol instance contains an instance of this class,
* which might be subclassed by subclasses of IMAPProtocol to add
* support for additional product-specific search terms.
*
* @author John Mani
*/
public class SearchSequence {
/**
* Generate the IMAP search sequence for the given search expression.
*
* @param term the search term
* @param charset charset for the search
* @return the SEARCH Argument
* @exception SearchException for failures
* @exception IOException for I/O errors
*/
throws SearchException, IOException {
/*
* Call the appropriate handler depending on the type of
* the search-term ...
*/
}
}
charset);
}
rterm.getPattern(),
charset);
}
else
throw new SearchException("Search too complex");
}
/**
* Check if the "text" terms in the given SearchTerm contain
* non US-ASCII characters.
*
* @param term the search term
* @return true if only ASCII
*/
else if (term instanceof StringTerm)
else if (term instanceof AddressTerm)
// Any other term returns true.
return true;
}
/**
* Check if any of the "text" terms in the given SearchTerms contain
* non US-ASCII characters.
*
* @param terms the search terms
* @return true if only ASCII
*/
return false;
return true;
}
/**
* Does this string contain only ASCII characters?
*
* @param s the string
* @return true if only ASCII
*/
int l = s.length();
for (int i=0; i < l; i++) {
return false;
}
return true;
}
throws SearchException, IOException {
// Combine the sequences for both terms
// Generate the search sequence for the first term
// Append other terms
return result;
}
throws SearchException, IOException {
/* The IMAP OR operator takes only two operands. So if
* we have more than 2 operands, group them into 2-operand
* OR Terms.
*/
// Include rest of the terms
// just created
}
// 'term' now has only two operands
// Add the OR search-key, if more than one term
/* If this term is an AND expression, we need to enclose it
* within paranthesis.
*
* AND expressions are either AndTerms or FlagTerms
*/
else
// Repeat the above for the second term, if there is one
else
}
return result;
}
throws SearchException, IOException {
// Add the NOT search-key
/* If this term is an AND expression, we need to enclose it
* within paranthesis.
*
* AND expressions are either AndTerms or FlagTerms
*/
else
return result;
}
throws SearchException, IOException {
return result;
}
throws SearchException, IOException {
// XXX confirm that charset conversion ought to be done
return result;
}
throw new SearchException("Invalid FlagTerm");
}
}
return result;
}
throws SearchException, IOException {
return result;
}
throws SearchException, IOException {
else
throw new SearchException("Illegal Recipient type");
return result;
}
throws SearchException, IOException {
return result;
}
throws SearchException, IOException {
return result;
}
throws SearchException {
switch (term.getComparison()) {
case ComparisonTerm.GT:
break;
case ComparisonTerm.LT:
break;
default:
// GT and LT is all we get from IMAP for size
throw new SearchException("Cannot handle Comparison");
}
return result;
}
// Date SEARCH stuff ...
// NOTE: The built-in IMAP date comparisons are equivalent to
// "<" (BEFORE), "=" (ON), and ">=" (SINCE)!!!
// There is no built-in greater-than comparison!
/**
* Print an IMAP Date string, that is suitable for the Date
* SEARCH commands.
*
* The IMAP Date string is :
* date ::= date_day "-" date_month "-" date_year
*
* Note that this format does not contain the TimeZone
*/
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
// A GregorianCalendar object in the current timezone
StringBuffer s = new StringBuffer();
return s.toString();
}
throws SearchException {
switch (term.getComparison()) {
case ComparisonTerm.GT:
break;
case ComparisonTerm.EQ:
break;
case ComparisonTerm.LT:
break;
case ComparisonTerm.GE:
break;
case ComparisonTerm.LE:
break;
case ComparisonTerm.NE:
break;
default:
throw new SearchException("Cannot handle Date Comparison");
}
return result;
}
throws SearchException {
switch (term.getComparison()) {
case ComparisonTerm.GT:
break;
case ComparisonTerm.EQ:
break;
case ComparisonTerm.LT:
break;
case ComparisonTerm.GE:
break;
case ComparisonTerm.LE:
break;
case ComparisonTerm.NE:
break;
default:
throw new SearchException("Cannot handle Date Comparison");
}
return result;
}
/**
* Generate argument for OlderTerm.
*
* @param term the search term
* @return the SEARCH Argument
* @exception SearchException for failures
* @since JavaMail 1.5.1
*/
return result;
}
/**
* Generate argument for YoungerTerm.
*
* @param term the search term
* @return the SEARCH Argument
* @exception SearchException for failures
* @since JavaMail 1.5.1
*/
return result;
}
/**
* Generate argument for ModifiedSinceTerm.
*
* @param term the search term
* @return the SEARCH Argument
* @exception SearchException for failures
* @since JavaMail 1.5.1
*/
throws SearchException {
return result;
}
}