james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Burrell Donkin" <robertburrelldon...@gmail.com>
Subject [MailboxAPI] Headers and FETCH ENVELOPE
Date Sun, 04 Nov 2007 20:35:54 GMT
MimeMessages are expensive to create. MessageResult
(http://svn.apache.org/repos/asf/james/server/trunk/core-library/src/main/java/org/apache/james/mailboxmanager/MessageResult.java)
was recently patched to allow headers to be returned without the
creation of a MimeMessage. the API introduced was:

    /**
     * Gets headers for the message.
     * @return <code>Headers</code>,
     * or null if {@link #HEADERS} was not fetched
     */
    Headers getHeaders();

    /**
     * Details of the mail headers for this result.
     */
    public interface Headers {
        /**
         * Gets all header lines.
         * @return <code>List</code> of <code>String</code> header
lines,
         * in their natural order
         * @throws MessagingException
         */
        List getAllLines() throws MessagingException;

        /**
         * Gets header lines whose header names matches (ignoring case)
         * any of those given.
         * @param names header names to be matched, not null
         * @return <code>List</code> of <code>String</code> header
lines,
         * in their natural order
         * @throws MessagingException
         */
        List getMatchingLines(String[] names) throws MessagingException;

        /**
         * Gets header lines whose header name fails to match (ignoring case)
         * all of the given names.
         * @param names header names, not null
         * @return <code>List</code> of <code>String</code> header
lines,
         * in their natural order
         * @throws MessagingException
         */
        List getOtherLines(String[] names) throws MessagingException;
    }

this is pretty much just pulling out the calls required.

IMAP FETCH ENVELOPE returns parsed and processed header data. ATM this
uses MimeMessage and is therefore slow.

perhaps it might be better to introduce a Header object and replace
Headers with a simple list (plus predicates to find the sublists). as
well as properties for the line, name and value, the header could also
expose simple parsing into address lists, dates and so on required by
ENVELOPE. it does mean more intermediary objects but would result in a
concise API.

opinions?

-robert

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message