001 /* 002 * Copyright 2010 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package com.hs.mail.imap.server.codec; 017 018 import java.util.LinkedList; 019 020 import org.jboss.netty.buffer.ChannelBuffer; 021 import org.jboss.netty.buffer.ChannelBuffers; 022 023 import com.hs.mail.imap.parser.Token; 024 025 /** 026 * An IMAP message. 027 * 028 * @author Won Chul Doh 029 * @since Jan 22, 2010 030 * 031 */ 032 public interface ImapMessage { 033 034 public String getCommand(); 035 036 LinkedList<Token> getTokens(); 037 038 /** 039 * Returns the content of this message. If there is no content, an 040 * {@link ChannelBuffers#EMPTY_BUFFER} is returned. 041 */ 042 ChannelBuffer getLiteral(); 043 044 /** 045 * Sets the content of this message. If {@code null} is specified, the 046 * content of this message will be set to 047 * {@link ChannelBuffers#EMPTY_BUFFER}. 048 */ 049 void setLiteral(ChannelBuffer literal); 050 051 /** 052 * Returns the length of the content. Please note that this value is 053 * not retrieved from {@link #getContent()} but from the 054 * {@code "Content-Length"} header, and thus they are independent from each 055 * other. 056 * 057 * @return the content length or {@code 0} if this message does not have 058 * the {@code "Content-Length"} header 059 */ 060 long getLiteralLength(); 061 062 void setLiteralLength(long literalLength); 063 064 /** 065 * Returns {@code true} if and only if we need to send command continuation 066 * request before reading literal data. 067 */ 068 boolean isNeedContinuationRequest(); 069 070 }