Package org.apache.james.protocols.imap

Examples of org.apache.james.protocols.imap.IMAPRequest


    private final static Pattern LITERAL_PATTERN = Pattern.compile(".*\\{(\\d+)\\}.*");
   
    @Override
    protected Request parseRequest(IMAPSession session, ByteBuffer buffer) throws Exception {
        IMAPRequest request = new IMAPRequest(buffer);
        Matcher matcher = LITERAL_PATTERN.matcher(request.getArgument());
        if (matcher.matches()) {
            final long bytesToRead = Long.parseLong(matcher.group(1));
            MultiLineHandler<IMAPSession> handler = new MultiLineHandler<IMAPSession>() {
               
                private static final String BYTES_READ = "BYTES_READ";
               
                /*
                 * (non-Javadoc)
                 * @see org.apache.james.protocols.api.handler.MultiLineHandler#isReady(org.apache.james.protocols.api.ProtocolSession, java.nio.ByteBuffer)
                 */
                protected boolean isReady(IMAPSession session, ByteBuffer line) {
                    long bytesRead = (Long) session.setAttachment(BYTES_READ, null, State.Transaction);
                    bytesRead += line.remaining();
                    if (bytesRead >= bytesToRead) {
                        return true;
                    } else {
                        session.setAttachment(BYTES_READ, bytesRead, State.Transaction);
                        return false;
                    }
                }

                @Override
                protected Response onLines(IMAPSession session, Collection<ByteBuffer> lines) {
                    session.popLineHandler();
                    return dispatchCommandHandlers(session, new IMAPRequest(lines));
                }
            };
            buffer.rewind();
           
            // push the line to the handler
View Full Code Here

TOP

Related Classes of org.apache.james.protocols.imap.IMAPRequest

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.