Package org.apache.james.imap.api.message.request

Examples of org.apache.james.imap.api.message.request.SearchKey


            throw new DecodingException(HumanReadableText.ILLEGAL_ARGUMENTS, "Unknown search key");
        }
    }

    private SearchKey answered(ImapRequestLineReader request) throws DecodingException {
        final SearchKey result;
        nextIsS(request);
        nextIsW(request);
        nextIsE(request);
        nextIsR(request);
        nextIsE(request);
View Full Code Here


        result = SearchKey.buildAnswered();
        return result;
    }

    private SearchKey all(ImapRequestLineReader request) throws DecodingException {
        final SearchKey result;
        nextIsL(request);
        result = SearchKey.buildAll();
        return result;
    }
View Full Code Here

        }
    }

    public SearchKey decode(ImapSession session, ImapRequestLineReader request) throws DecodingException, IllegalCharsetNameException, UnsupportedCharsetException {
        request.nextWordChar();
        final SearchKey firstKey = searchKey(session, request, null, true);
        final SearchKey result;
        if (request.nextChar() == ' ') {
            List<SearchKey> keys = new ArrayList<SearchKey>();
            keys.add(firstKey);
            while (request.nextChar() == ' ') {
                request.nextWordChar();
                final SearchKey key = searchKey(session, request, null, false);
                keys.add(key);
            }
            result = SearchKey.buildAnd(keys);
        } else {
            result = firstKey;
View Full Code Here

     * org.apache.james.imap.decode.ImapRequestLineReader, java.lang.String,
     * boolean, org.apache.james.imap.api.process.ImapSession)
     */
    protected ImapMessage decode(ImapCommand command, ImapRequestLineReader request, String tag, boolean useUids, ImapSession session) throws DecodingException {
        try {
            SearchKey recent = null;
            List<SearchResultOption> options = null;
            int c = ImapRequestLineReader.cap(request.nextWordChar());
            if (c == 'R') {
                // if we found a R its either RECENT or RETURN so consume it
                request.consume();
               
                nextIsE(request);
                c = consumeAndCap(request);

                switch (c) {
                case 'C':
                    recent = recent(request);
                    break;
                case 'T':
                    nextIsU(request);
                    nextIsR(request);
                    nextIsN(request);
                    request.nextWordChar();
                    options = parseOptions(request);
                    break;

                default:
                    throw new DecodingException(HumanReadableText.ILLEGAL_ARGUMENTS, "Unknown search key");
                }
            }
            final SearchKey finalKey;

            if (recent != null) {
                if (request.nextChar() != ' ') {
                    request.eol();
                    finalKey = recent;
                } else {
                    // Parse the search term from the request
                    final SearchKey key = decode(session, request);
                    finalKey = SearchKey.buildAnd(Arrays.asList(recent, key));
                }
            } else {
                // Parse the search term from the request
                finalKey = decode(session, request);
View Full Code Here

   

    @Test
    public void testShouldParseAll() throws Exception {
        SearchKey key = SearchKey.buildAll();
        checkValid("ALL\r\n", key);
        checkValid("all\r\n", key);
        checkValid("alL\r\n", key);
        checkInvalid("al\r\n", key);
        checkInvalid("alm\r\n", key);
View Full Code Here

        checkInvalid("alm\r\n", key);
    }

    @Test
    public void testShouldParseAnswered() throws Exception {
        SearchKey key = SearchKey.buildAnswered();
        checkValid("ANSWERED\r\n", key);
        checkValid("answered\r\n", key);
        checkValid("aNSWEred\r\n", key);
        checkInvalid("a\r\n", key);
        checkInvalid("an\r\n", key);
View Full Code Here

        checkInvalid("answere\r\n", key);
    }

    @Test
    public void testShouldParseBcc() throws Exception {
        SearchKey key = SearchKey.buildBcc("Somebody");
        checkValid("BCC Somebody\r\n", key);
        checkValid("BCC \"Somebody\"\r\n", key);
        checkValid("bcc Somebody\r\n", key);
        checkValid("bcc \"Somebody\"\r\n", key);
        checkValid("Bcc Somebody\r\n", key);
View Full Code Here

        checkInvalid("bccc\r\n", key);
    }

    @Test
    public void testShouldParseOn() throws Exception {
        SearchKey key = SearchKey.buildOn(DATE);
        checkValid("ON 1-Jan-2000\r\n", key);
        checkValid("on 1-Jan-2000\r\n", key);
        checkValid("oN 1-Jan-2000\r\n", key);
        checkInvalid("o\r\n", key);
        checkInvalid("om\r\n", key);
View Full Code Here

        checkInvalid("on 1-Jan-\r\n", key);
    }

    @Test
    public void testShouldParseSentBefore() throws Exception {
        SearchKey key = SearchKey.buildSentBefore(DATE);
        checkValid("SENTBEFORE 1-Jan-2000\r\n", key);
        checkValid("sentbefore 1-Jan-2000\r\n", key);
        checkValid("SentBefore 1-Jan-2000\r\n", key);
        checkInvalid("s\r\n", key);
        checkInvalid("se\r\n", key);
View Full Code Here

        checkInvalid("sentbefore 1-Jan-\r\n", key);
    }

    @Test
    public void testShouldParseSentOn() throws Exception {
        SearchKey key = SearchKey.buildSentOn(DATE);
        checkValid("SENTON 1-Jan-2000\r\n", key);
        checkValid("senton 1-Jan-2000\r\n", key);
        checkValid("SentOn 1-Jan-2000\r\n", key);
        checkInvalid("s\r\n", key);
        checkInvalid("se\r\n", key);
View Full Code Here

TOP

Related Classes of org.apache.james.imap.api.message.request.SearchKey

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.