You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by rd...@apache.org on 2008/09/18 23:45:03 UTC
svn commit: r696828 [2/32] - in /james/protocols/imap/trunk:
api/src/main/java/org/apache/james/api/imap/
api/src/main/java/org/apache/james/api/imap/display/
api/src/main/java/org/apache/james/api/imap/imap4rev1/
api/src/main/java/org/apache/james/api...
Modified: james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/message/MessageFlags.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/message/MessageFlags.java?rev=696828&r1=696827&r2=696828&view=diff
==============================================================================
--- james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/message/MessageFlags.java (original)
+++ james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/message/MessageFlags.java Thu Sep 18 14:44:56 2008
@@ -24,22 +24,27 @@
import javax.mail.Flags;
-
/**
- * The set of flags associated with a message.
- * TODO - why not use javax.mail.Flags instead of having our own.
- *
- * <p>Reference: RFC 2060 - para 2.3</p>
+ * The set of flags associated with a message. TODO - why not use
+ * javax.mail.Flags instead of having our own.
+ *
+ * <p>
+ * Reference: RFC 2060 - para 2.3
+ * </p>
*/
-public class MessageFlags
-{
+public class MessageFlags {
public static final String SEEN_OUTPUT_CAPITALISED = "\\Seen";
+
public static final String RECENT_OUTPUT_CAPITALISED = "\\Recent";
+
public static final String FLAGGED_OUTPUT_CAPITALISED = "\\Flagged";
+
public static final String DRAFT_OUTPUT_CAPITALISED = "\\Draft";
+
public static final String DELETED_OUTPUT_CAPITALISED = "\\Deleted";
+
public static final String ANSWERED_OUTPUT_CAPITALISED = "\\Answered";
-
+
public static final Flags ALL_FLAGS = new Flags();
static {
ALL_FLAGS.add(Flags.Flag.ANSWERED);
@@ -49,74 +54,77 @@
ALL_FLAGS.add(Flags.Flag.RECENT);
ALL_FLAGS.add(Flags.Flag.SEEN);
}
-
+
public static final String ANSWERED_ALL_CAPS = "\\ANSWERED";
+
public static final String DELETED_ALL_CAPS = "\\DELETED";
+
public static final String DRAFT_ALL_CAPS = "\\DRAFT";
+
public static final String FLAGGED_ALL_CAPS = "\\FLAGGED";
+
public static final String SEEN_ALL_CAPS = "\\SEEN";
+
public static final String RECENT_ALL_CAPS = "\\RECENT";
/**
* Returns IMAP formatted String naming flags.
- * @return <code>Collection</code> of <code>String</code>'s
- * naming the flags.
+ *
+ * @return <code>Collection</code> of <code>String</code>'s naming the
+ * flags.
*/
public static Collection names(Flags flags) {
final Collection results = new ArrayList();
- if ( flags.contains(Flags.Flag.ANSWERED) ) {
- results.add( ANSWERED_OUTPUT_CAPITALISED );
+ if (flags.contains(Flags.Flag.ANSWERED)) {
+ results.add(ANSWERED_OUTPUT_CAPITALISED);
}
- if ( flags.contains(Flags.Flag.DELETED) ) {
- results.add( DELETED_OUTPUT_CAPITALISED );
+ if (flags.contains(Flags.Flag.DELETED)) {
+ results.add(DELETED_OUTPUT_CAPITALISED);
}
- if ( flags.contains(Flags.Flag.DRAFT) ) {
- results.add( DRAFT_OUTPUT_CAPITALISED );
+ if (flags.contains(Flags.Flag.DRAFT)) {
+ results.add(DRAFT_OUTPUT_CAPITALISED);
}
- if ( flags.contains(Flags.Flag.FLAGGED) ) {
- results.add( FLAGGED_OUTPUT_CAPITALISED );
+ if (flags.contains(Flags.Flag.FLAGGED)) {
+ results.add(FLAGGED_OUTPUT_CAPITALISED);
}
- if ( flags.contains(Flags.Flag.RECENT) ) {
- results.add( RECENT_OUTPUT_CAPITALISED );
+ if (flags.contains(Flags.Flag.RECENT)) {
+ results.add(RECENT_OUTPUT_CAPITALISED);
}
- if ( flags.contains(Flags.Flag.SEEN) ) {
- results.add( SEEN_OUTPUT_CAPITALISED );
+ if (flags.contains(Flags.Flag.SEEN)) {
+ results.add(SEEN_OUTPUT_CAPITALISED);
}
return results;
}
-
+
/**
* Returns IMAP formatted String of MessageFlags for named user
*/
- public static String format(Flags flags)
- {
+ public static String format(Flags flags) {
StringBuffer buf = new StringBuffer();
- buf.append( "(" );
- if ( flags.contains(Flags.Flag.ANSWERED) ) {
- buf.append( "\\Answered " );
+ buf.append("(");
+ if (flags.contains(Flags.Flag.ANSWERED)) {
+ buf.append("\\Answered ");
}
- if ( flags.contains(Flags.Flag.DELETED) ) {
- buf.append( "\\Deleted " );
+ if (flags.contains(Flags.Flag.DELETED)) {
+ buf.append("\\Deleted ");
}
- if ( flags.contains(Flags.Flag.DRAFT) ) {
- buf.append( "\\Draft " );
+ if (flags.contains(Flags.Flag.DRAFT)) {
+ buf.append("\\Draft ");
}
- if ( flags.contains(Flags.Flag.FLAGGED) ) {
- buf.append( "\\Flagged " );
+ if (flags.contains(Flags.Flag.FLAGGED)) {
+ buf.append("\\Flagged ");
}
- if ( flags.contains(Flags.Flag.RECENT) ) {
- buf.append( "\\Recent " );
+ if (flags.contains(Flags.Flag.RECENT)) {
+ buf.append("\\Recent ");
}
- if ( flags.contains(Flags.Flag.SEEN) ) {
- buf.append( "\\Seen " );
+ if (flags.contains(Flags.Flag.SEEN)) {
+ buf.append("\\Seen ");
}
// Remove the trailing space, if necessary.
- if ( buf.length() > 1 )
- {
- buf.setLength( buf.length() - 1 );
+ if (buf.length() > 1) {
+ buf.setLength(buf.length() - 1);
}
- buf.append( ")" );
+ buf.append(")");
return buf.toString();
}
}
-
Modified: james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/message/StatusDataItems.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/message/StatusDataItems.java?rev=696828&r1=696827&r2=696828&view=diff
==============================================================================
--- james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/message/StatusDataItems.java (original)
+++ james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/message/StatusDataItems.java Thu Sep 18 14:44:56 2008
@@ -18,44 +18,55 @@
****************************************************************/
package org.apache.james.api.imap.message;
-public class StatusDataItems
-{
+public class StatusDataItems {
private boolean messages;
+
private boolean recent;
+
private boolean uidNext;
+
private boolean uidValidity;
+
private boolean unseen;
-
+
public boolean isMessages() {
return messages;
}
+
public void setMessages(boolean messages) {
this.messages = messages;
}
+
public boolean isRecent() {
return recent;
}
+
public void setRecent(boolean recent) {
this.recent = recent;
}
+
public boolean isUidNext() {
return uidNext;
}
+
public void setUidNext(boolean uidNext) {
this.uidNext = uidNext;
}
+
public boolean isUidValidity() {
return uidValidity;
}
+
public void setUidValidity(boolean uidValidity) {
this.uidValidity = uidValidity;
}
+
public boolean isUnseen() {
return unseen;
}
+
public void setUnseen(boolean unseen) {
this.unseen = unseen;
}
-
-
+
}
Modified: james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/message/request/DayMonthYear.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/message/request/DayMonthYear.java?rev=696828&r1=696827&r2=696828&view=diff
==============================================================================
--- james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/message/request/DayMonthYear.java (original)
+++ james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/message/request/DayMonthYear.java Thu Sep 18 14:44:56 2008
@@ -25,42 +25,47 @@
public class DayMonthYear {
private final int day;
+
private final int month;
+
private final int year;
-
+
public DayMonthYear(final int day, final int month, final int year) {
super();
this.day = day;
this.month = month;
this.year = year;
}
-
+
/**
* Gets the day component of this date.
+ *
* @return the day of the month, one based
*/
public final int getDay() {
return day;
}
-
+
/**
* Gets the month component of this date.
+ *
* @return the month of the year, one based
*/
public final int getMonth() {
return month;
}
-
+
/**
* Gets the year component of this date.
+ *
* @return the year
*/
public final int getYear() {
return year;
}
-
+
public String toString() {
- return day + "-" + month + "-" + year;
+ return day + "-" + month + "-" + year;
}
/**
@@ -94,6 +99,5 @@
return false;
return true;
}
-
-
+
}
Modified: james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/message/request/SearchKey.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/message/request/SearchKey.java?rev=696828&r1=696827&r2=696828&view=diff
==============================================================================
--- james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/message/request/SearchKey.java (original)
+++ james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/message/request/SearchKey.java Thu Sep 18 14:44:56 2008
@@ -7,104 +7,138 @@
import org.apache.james.api.imap.message.IdRange;
/**
- * Atom key used by a search.
- * Build instances by factory methods.
+ * Atom key used by a search. Build instances by factory methods.
*/
public final class SearchKey {
// NUMBERS
public static final int TYPE_SEQUENCE_SET = 1;
- public static final int TYPE_UID = 2;
+
+ public static final int TYPE_UID = 2;
+
// NO PARAMETERS
public static final int TYPE_ALL = 3;
+
public static final int TYPE_ANSWERED = 4;
+
public static final int TYPE_DELETED = 5;
+
public static final int TYPE_DRAFT = 6;
+
public static final int TYPE_FLAGGED = 7;
+
public static final int TYPE_NEW = 8;
+
public static final int TYPE_OLD = 9;
+
public static final int TYPE_RECENT = 10;
+
public static final int TYPE_SEEN = 11;
+
public static final int TYPE_UNANSWERED = 12;
+
public static final int TYPE_UNDELETED = 13;
+
public static final int TYPE_UNDRAFT = 14;
+
public static final int TYPE_UNFLAGGED = 15;
+
public static final int TYPE_UNSEEN = 16;
+
// ONE VALUE
public static final int TYPE_BCC = 17;
+
public static final int TYPE_BODY = 18;
+
public static final int TYPE_CC = 19;
+
public static final int TYPE_FROM = 20;
+
public static final int TYPE_KEYWORD = 21;
+
public static final int TYPE_SUBJECT = 22;
+
public static final int TYPE_TEXT = 23;
+
public static final int TYPE_TO = 24;
+
public static final int TYPE_UNKEYWORD = 25;
+
// ONE DATE
public static final int TYPE_BEFORE = 26;
+
public static final int TYPE_ON = 27;
+
public static final int TYPE_SENTBEFORE = 28;
+
public static final int TYPE_SENTON = 29;
+
public static final int TYPE_SENTSINCE = 30;
+
public static final int TYPE_SINCE = 31;
+
// FIELD VALUE
public static final int TYPE_HEADER = 32;
+
// ONE NUMBER
public static final int TYPE_LARGER = 33;
+
public static final int TYPE_SMALLER = 34;
+
// NOT
public static final int TYPE_NOT = 35;
+
// OR
public static final int TYPE_OR = 36;
+
// AND
public static final int TYPE_AND = 37;
-
- private static final SearchKey UNSEEN = new SearchKey(TYPE_UNSEEN,
+
+ private static final SearchKey UNSEEN = new SearchKey(TYPE_UNSEEN, null,
+ null, 0, null, null, null);
+
+ private static final SearchKey UNFLAGGED = new SearchKey(TYPE_UNFLAGGED,
null, null, 0, null, null, null);
- private static final SearchKey UNFLAGGED = new SearchKey(
- TYPE_UNFLAGGED, null, null, 0, null, null, null);
+ private static final SearchKey UNDRAFT = new SearchKey(TYPE_UNDRAFT, null,
+ null, 0, null, null, null);
- private static final SearchKey UNDRAFT = new SearchKey(TYPE_UNDRAFT,
+ private static final SearchKey UNDELETED = new SearchKey(TYPE_UNDELETED,
null, null, 0, null, null, null);
- private static final SearchKey UNDELETED = new SearchKey(
- TYPE_UNDELETED, null, null, 0, null, null, null);
+ private static final SearchKey UNANSWERED = new SearchKey(TYPE_UNANSWERED,
+ null, null, 0, null, null, null);
- private static final SearchKey UNANSWERED = new SearchKey(
- TYPE_UNANSWERED, null, null, 0, null, null, null);
+ private static final SearchKey SEEN = new SearchKey(TYPE_SEEN, null, null,
+ 0, null, null, null);
- private static final SearchKey SEEN = new SearchKey(TYPE_SEEN, null,
+ private static final SearchKey RECENT = new SearchKey(TYPE_RECENT, null,
null, 0, null, null, null);
- private static final SearchKey RECENT = new SearchKey(TYPE_RECENT,
- null, null, 0, null, null, null);
+ private static final SearchKey OLD = new SearchKey(TYPE_OLD, null, null, 0,
+ null, null, null);
- private static final SearchKey OLD = new SearchKey(TYPE_OLD, null,
- null, 0, null, null, null);
+ private static final SearchKey NEW = new SearchKey(TYPE_NEW, null, null, 0,
+ null, null, null);
- private static final SearchKey NEW = new SearchKey(TYPE_NEW, null,
+ private static final SearchKey FLAGGED = new SearchKey(TYPE_FLAGGED, null,
null, 0, null, null, null);
- private static final SearchKey FLAGGED = new SearchKey(TYPE_FLAGGED,
- null, null, 0, null, null, null);
-
private static final SearchKey DRAFT = new SearchKey(TYPE_DRAFT, null,
null, 0, null, null, null);
- private static final SearchKey DELETED = new SearchKey(TYPE_DELETED,
- null,null, 0, null, null, null);
+ private static final SearchKey DELETED = new SearchKey(TYPE_DELETED, null,
+ null, 0, null, null, null);
private static final SearchKey ANSWERED = new SearchKey(TYPE_ANSWERED,
null, null, 0, null, null, null);
- private static final SearchKey ALL = new SearchKey(TYPE_ALL, null,
- null, 0, null, null, null);
+ private static final SearchKey ALL = new SearchKey(TYPE_ALL, null, null, 0,
+ null, null, null);
// NUMBERS
public static SearchKey buildSequenceSet(IdRange[] ids) {
- return new SearchKey(TYPE_SEQUENCE_SET, null, null, 0, null,
- null, ids);
+ return new SearchKey(TYPE_SEQUENCE_SET, null, null, 0, null, null, ids);
}
public static SearchKey buildUidSet(IdRange[] ids) {
@@ -170,54 +204,44 @@
// ONE VALUE
public static SearchKey buildBcc(String value) {
- return new SearchKey(TYPE_BCC, null, null, 0, null, value,
- null);
+ return new SearchKey(TYPE_BCC, null, null, 0, null, value, null);
}
public static SearchKey buildBody(String value) {
- return new SearchKey(TYPE_BODY, null, null, 0, null, value,
- null);
+ return new SearchKey(TYPE_BODY, null, null, 0, null, value, null);
}
public static SearchKey buildCc(String value) {
- return new SearchKey(TYPE_CC, null, null, 0, null, value,
- null);
+ return new SearchKey(TYPE_CC, null, null, 0, null, value, null);
}
public static SearchKey buildFrom(String value) {
- return new SearchKey(TYPE_FROM, null, null, 0, null, value,
- null);
+ return new SearchKey(TYPE_FROM, null, null, 0, null, value, null);
}
public static SearchKey buildKeyword(String value) {
- return new SearchKey(TYPE_KEYWORD, null, null, 0, null,
- value, null);
+ return new SearchKey(TYPE_KEYWORD, null, null, 0, null, value, null);
}
public static SearchKey buildSubject(String value) {
- return new SearchKey(TYPE_SUBJECT, null, null, 0, null,
- value, null);
+ return new SearchKey(TYPE_SUBJECT, null, null, 0, null, value, null);
}
public static SearchKey buildText(String value) {
- return new SearchKey(TYPE_TEXT, null, null, 0, null, value,
- null);
+ return new SearchKey(TYPE_TEXT, null, null, 0, null, value, null);
}
public static SearchKey buildTo(String value) {
- return new SearchKey(TYPE_TO, null, null, 0, null, value,
- null);
+ return new SearchKey(TYPE_TO, null, null, 0, null, value, null);
}
public static SearchKey buildUnkeyword(String value) {
- return new SearchKey(TYPE_UNKEYWORD, null, null, 0, null,
- value, null);
+ return new SearchKey(TYPE_UNKEYWORD, null, null, 0, null, value, null);
}
// ONE DATE
public static SearchKey buildBefore(DayMonthYear date) {
- return new SearchKey(TYPE_BEFORE, date, null, 0, null, null,
- null);
+ return new SearchKey(TYPE_BEFORE, date, null, 0, null, null, null);
}
public static SearchKey buildOn(DayMonthYear date) {
@@ -225,40 +249,33 @@
}
public static SearchKey buildSentBefore(DayMonthYear date) {
- return new SearchKey(TYPE_SENTBEFORE, date, null, 0, null,
- null, null);
+ return new SearchKey(TYPE_SENTBEFORE, date, null, 0, null, null, null);
}
public static SearchKey buildSentOn(DayMonthYear date) {
- return new SearchKey(TYPE_SENTON, date, null, 0, null, null,
- null);
+ return new SearchKey(TYPE_SENTON, date, null, 0, null, null, null);
}
public static SearchKey buildSentSince(DayMonthYear date) {
- return new SearchKey(TYPE_SENTSINCE, date, null, 0, null,
- null, null);
+ return new SearchKey(TYPE_SENTSINCE, date, null, 0, null, null, null);
}
public static SearchKey buildSince(DayMonthYear date) {
- return new SearchKey(TYPE_SINCE, date, null, 0, null, null,
- null);
+ return new SearchKey(TYPE_SINCE, date, null, 0, null, null, null);
}
// FIELD VALUE
public static SearchKey buildHeader(String name, String value) {
- return new SearchKey(TYPE_HEADER, null, null, 0, name, value,
- null);
+ return new SearchKey(TYPE_HEADER, null, null, 0, name, value, null);
}
// ONE NUMBER
public static SearchKey buildLarger(long size) {
- return new SearchKey(TYPE_LARGER, null, null, size, null,
- null, null);
+ return new SearchKey(TYPE_LARGER, null, null, size, null, null, null);
}
public static SearchKey buildSmaller(long size) {
- return new SearchKey(TYPE_SMALLER, null, null, size, null,
- null, null);
+ return new SearchKey(TYPE_SMALLER, null, null, size, null, null, null);
}
// NOT
@@ -273,32 +290,37 @@
final List keys = new ArrayList();
keys.add(keyOne);
keys.add(keyTwo);
- return new SearchKey(TYPE_OR, null, keys, 0, null, null,
- null);
+ return new SearchKey(TYPE_OR, null, keys, 0, null, null, null);
}
-
+
/**
- * Componses an <code>AND</code> key from
- * given keys.
- * @param keys <code>List</code> of {@link SearchKey}'s
- * composing this key
+ * Componses an <code>AND</code> key from given keys.
+ *
+ * @param keys
+ * <code>List</code> of {@link SearchKey}'s composing this key
* @return <code>SearchKey</code>, not null
*/
public static SearchKey buildAnd(final List keys) {
return new SearchKey(TYPE_AND, null, keys, 0, null, null, null);
}
-
private final int type;
+
private final DayMonthYear date;
+
private final List keys;
+
private final long size;
+
private final String name;
+
private final String value;
+
private IdRange[] sequence;
- private SearchKey(final int type, final DayMonthYear date, final List keys,
- final long number, final String name, final String value, IdRange[] sequence) {
+ private SearchKey(final int type, final DayMonthYear date, final List keys,
+ final long number, final String name, final String value,
+ IdRange[] sequence) {
super();
this.type = type;
this.date = date;
@@ -311,9 +333,10 @@
/**
* Gets a date value to be search upon.
+ *
* @return the date when: {@link #TYPE_BEFORE}, {@link #TYPE_ON},
- * {@link #TYPE_SENTBEFORE}, {@link #TYPE_SENTON}, {@link #TYPE_SENTSINCE},
- * {@link #TYPE_SINCE}; otherwise null
+ * {@link #TYPE_SENTBEFORE}, {@link #TYPE_SENTON},
+ * {@link #TYPE_SENTSINCE}, {@link #TYPE_SINCE}; otherwise null
*/
public final DayMonthYear getDate() {
return date;
@@ -321,8 +344,9 @@
/**
* Gets sequence numbers.
+ *
* @return msn when {@link #TYPE_SEQUENCE_SET}, uids when {@link #TYPE_UID},
- * null otherwise
+ * null otherwise
*/
public final IdRange[] getSequenceNumbers() {
return sequence;
@@ -330,8 +354,8 @@
/**
* Gets the field name.
- * @return the field name when {@link #TYPE_HEADER},
- * null otherwise
+ *
+ * @return the field name when {@link #TYPE_HEADER}, null otherwise
*/
public final String getName() {
return name;
@@ -339,18 +363,20 @@
/**
* Gets the size searched for.
+ *
* @return the size when {@link #TYPE_LARGER} or {@link #TYPE_SMALLER},
- * otherwise 0
+ * otherwise 0
*/
public final long getSize() {
return size;
}
-
+
/**
* Gets key two.
- * @return <code>List</code> of <code>SearchKey</code>'s when {@link #TYPE_OR},
- * {@link #TYPE_AND} or {@link #TYPE_NOT}
- * otherwise null
+ *
+ * @return <code>List</code> of <code>SearchKey</code>'s when
+ * {@link #TYPE_OR}, {@link #TYPE_AND} or {@link #TYPE_NOT}
+ * otherwise null
*/
public final List getKeys() {
return keys;
@@ -358,17 +384,17 @@
/**
* Gets the type of key.
+ *
* @return the type
*/
public final int getType() {
return type;
}
-
/**
* Gets the value to be searched for.
- * @return the value,
- * or null when this type is not associated with a value.
+ *
+ * @return the value, or null when this type is not associated with a value.
*/
public final String getValue() {
return value;
@@ -428,5 +454,5 @@
} else if (!value.equals(other.value))
return false;
return true;
- }
+ }
}
\ No newline at end of file
Modified: james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/message/response/ImapResponseMessage.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/message/response/ImapResponseMessage.java?rev=696828&r1=696827&r2=696828&view=diff
==============================================================================
--- james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/message/response/ImapResponseMessage.java (original)
+++ james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/message/response/ImapResponseMessage.java Thu Sep 18 14:44:56 2008
@@ -21,14 +21,14 @@
import org.apache.james.api.imap.ImapMessage;
-
/**
- * <p>Responds to an IMAP command.</p>
* <p>
- * <strong>Note:</strong> this is a transitional API
- * and is liable to change.
+ * Responds to an IMAP command.
+ * </p>
+ * <p>
+ * <strong>Note:</strong> this is a transitional API and is liable to change.
* </p>
*/
public interface ImapResponseMessage extends ImapMessage {
-
+
}
Modified: james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/message/response/imap4rev1/StatusResponse.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/message/response/imap4rev1/StatusResponse.java?rev=696828&r1=696827&r2=696828&view=diff
==============================================================================
--- james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/message/response/imap4rev1/StatusResponse.java (original)
+++ james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/message/response/imap4rev1/StatusResponse.java Thu Sep 18 14:44:56 2008
@@ -31,63 +31,71 @@
/**
* <p>
- * Represents an <code>RFC2060</code> status response.
- * The five specified status server responses (<code>OK<code>.
+ * Represents an <code>RFC2060</code> status response. The five specified
+ * status server responses (<code>OK<code>.
* <code>NO</code>, <code>BAD</code>, <code>PREAUTH</code>
* and <code>BYE</code>) are modeled by this single interface.
* They are differentiated by {@link #getServerResponseType()}
* </p>
*/
public interface StatusResponse extends ImapResponseMessage {
-
+
/**
* Gets the server response type of this status message.
+ *
* @return
*/
public Type getServerResponseType();
-
+
/**
* Gets the tag.
+ *
* @return if tagged response, the tag. Otherwise null.
*/
public String getTag();
-
+
/**
* Gets the command.
+ *
* @return if tagged response, the command. Otherwise null
*/
public ImapCommand getCommand();
-
+
/**
- * Gets the key to the human readable text to be displayed.
- * Required.
+ * Gets the key to the human readable text to be displayed. Required.
+ *
* @return key for the text message to be displayed, not null
*/
public HumanReadableTextKey getTextKey();
-
+
/**
- * Gets the response code.
- * Optional.
- * @return <code>ResponseCode</code>,
- * or null if there is no response code
+ * Gets the response code. Optional.
+ *
+ * @return <code>ResponseCode</code>, or null if there is no response
+ * code
*/
public ResponseCode getResponseCode();
-
+
/**
- * Enumerates types of RC2060 status response
+ * Enumerates types of RC2060 status response
*/
public static final class Type {
/** RFC2060 <code>OK</code> server response */
public static final Type OK = new Type("OK");
+
/** RFC2060 <code>OK</code> server response */
public static final Type NO = new Type("NO");
+
/** RFC2060 <code>BAD</code> server response */
public static final Type BAD = new Type("BAD")
- /** RFC2060 <code>PREAUTH</code> server response */;
+ /** RFC2060 <code>PREAUTH</code> server response */
+ ;
+
public static final Type PREAUTH = new Type("PREAUTH");
+
/** RFC2060 <code>BYE</code> server response */
public static final Type BYE = new Type("BYE");
-
+
private final String code;
private Type(final String code) {
@@ -101,7 +109,7 @@
result = PRIME * result + ((code == null) ? 0 : code.hashCode());
return result;
}
-
+
public final String getCode() {
return code;
}
@@ -121,117 +129,142 @@
return false;
return true;
}
-
+
public String toString() {
return code;
}
}
-
+
/**
* Enumerates response codes.
*/
public static final class ResponseCode {
-
+
/** RFC2060 <code>ALERT</code> response code */
private static final ResponseCode ALERT = new ResponseCode("ALERT");
+
/** RFC2060 <code>PARSE</code> response code */
private static final ResponseCode PARSE = new ResponseCode("PARSE");
+
/** RFC2060 <code>READ_ONLY</code> response code */
- private static final ResponseCode READ_ONLY = new ResponseCode("READ-ONLY");
+ private static final ResponseCode READ_ONLY = new ResponseCode(
+ "READ-ONLY");
+
/** RFC2060 <code>READ_WRITE</code> response code */
- private static final ResponseCode READ_WRITE = new ResponseCode("READ-WRITE");
+ private static final ResponseCode READ_WRITE = new ResponseCode(
+ "READ-WRITE");
+
/** RFC2060 <code>TRYCREATE</code> response code */
- private static final ResponseCode TRYCREATE = new ResponseCode("TRYCREATE");
-
+ private static final ResponseCode TRYCREATE = new ResponseCode(
+ "TRYCREATE");
+
/**
* Creates a RFC2060 <code>ALERT</code> response code.
+ *
* @return <code>ResponseCode</code>, not null
*/
public static final ResponseCode alert() {
return ALERT;
}
-
+
/**
* Creates a RFC2060 <code>BADCHARSET</code> response code.
- * @param charsetNames <code>Collection<String></code> containing charset names
+ *
+ * @param charsetNames
+ * <code>Collection<String></code> containing charset
+ * names
* @return <code>ResponseCode</code>, not null
*/
public static final ResponseCode badCharset(Collection charsetNames) {
return new ResponseCode("BADCHARSET", charsetNames);
}
-
+
/**
* Creates a RFC2060 <code>PARSE</code> response code.
+ *
* @return <code>ResponseCode</code>, not null
*/
public static final ResponseCode parse() {
return PARSE;
}
-
+
/**
* Creates a RFC2060 <code>PERMENANTFLAGS</code> response code.
- * @param flagNames <code>Collection<String></code> containing flag names
+ *
+ * @param flagNames
+ * <code>Collection<String></code> containing flag names
* @return <code>ResponseCode</code>, not null
*/
public static final ResponseCode permanentFlags(Flags flags) {
return new ResponseCode("PERMANENTFLAGS", MessageFlags.names(flags));
}
-
+
/**
* Creates a RFC2060 <code>READ-ONLY</code> response code.
+ *
* @return <code>ResponseCode</code>, not null
*/
public static final ResponseCode readOnly() {
return READ_ONLY;
}
-
+
/**
* Creates a RFC2060 <code>READ-WRITE</code> response code.
+ *
* @return <code>ResponseCode</code>, not null
*/
public static final ResponseCode readWrite() {
return READ_WRITE;
}
-
+
/**
* Creates a RFC2060 <code>TRYCREATE</code> response code.
+ *
* @return <code>ResponseCode</code>, not null
*/
public static final ResponseCode tryCreate() {
return TRYCREATE;
}
-
+
/**
* Creates a RFC2060 <code>UIDVALIDITY</code> response code.
- * @param uid positive non-zero integer
+ *
+ * @param uid
+ * positive non-zero integer
* @return <code>ResponseCode</code>, not null
*/
public static final ResponseCode uidValidity(long uid) {
return new ResponseCode("UIDVALIDITY", uid);
}
-
+
/**
* Creates a RFC2060 <code>UNSEEN</code> response code.
- * @param numberUnseen positive non-zero integer
+ *
+ * @param numberUnseen
+ * positive non-zero integer
* @return <code>ResponseCode</code>, not null
*/
public static final ResponseCode unseen(int numberUnseen) {
return new ResponseCode("UNSEEN", numberUnseen);
}
-
+
/**
* Creates a RFC2060 <code>UIDNEXT</code> response code.
- * @param uid positive non-zero integer
+ *
+ * @param uid
+ * positive non-zero integer
* @return <code>ResponseCode</code>, not null
*/
public static final ResponseCode uidNext(int uid) {
return new ResponseCode("UIDNEXT", uid);
}
-
+
/**
- * Creates an extension response code.
- * Names that do not begin with 'X' will have 'X' prepended
- * @param name extension code, not null
+ * Creates an extension response code. Names that do not begin with 'X'
+ * will have 'X' prepended
+ *
+ * @param name
+ * extension code, not null
* @return <code>ResponseCode</code>, not null
*/
public static ResponseCode createExtension(String name) {
@@ -243,24 +276,27 @@
final ResponseCode result = new ResponseCode(buffer.toString());
return result;
}
-
+
private final String code;
+
private final Collection parameters;
+
private final long number;
private ResponseCode(final String code) {
this(code, Collections.EMPTY_LIST, 0);
}
-
+
private ResponseCode(final String code, final long number) {
this(code, Collections.EMPTY_LIST, number);
}
-
+
private ResponseCode(final String code, final Collection parameters) {
this(code, parameters, 0);
}
-
- private ResponseCode(final String code, final Collection parameters, final long number) {
+
+ private ResponseCode(final String code, final Collection parameters,
+ final long number) {
super();
this.code = code;
this.parameters = parameters;
@@ -270,11 +306,11 @@
public final String getCode() {
return code;
}
-
+
/**
* Gets number for this response.
- * @return the number,
- * or zero if no number has been set
+ *
+ * @return the number, or zero if no number has been set
*/
public final long getNumber() {
return number;
@@ -282,19 +318,21 @@
/**
* Gets parameters for this code.
- * @return the parameters <code>Collection</code>
- * of <code>String</code> parameters, not null
+ *
+ * @return the parameters <code>Collection</code> of
+ * <code>String</code> parameters, not null
*/
public final Collection getParameters() {
return parameters;
- }
-
+ }
+
public int hashCode() {
final int PRIME = 31;
int result = 1;
result = PRIME * result + ((code == null) ? 0 : code.hashCode());
result = PRIME * result + (int) (number ^ (number >>> 32));
- result = PRIME * result + ((parameters == null) ? 0 : parameters.hashCode());
+ result = PRIME * result
+ + ((parameters == null) ? 0 : parameters.hashCode());
return result;
}
Modified: james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/message/response/imap4rev1/StatusResponseFactory.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/message/response/imap4rev1/StatusResponseFactory.java?rev=696828&r1=696827&r2=696828&view=diff
==============================================================================
--- james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/message/response/imap4rev1/StatusResponseFactory.java (original)
+++ james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/message/response/imap4rev1/StatusResponseFactory.java Thu Sep 18 14:44:56 2008
@@ -23,143 +23,205 @@
import org.apache.james.api.imap.display.HumanReadableTextKey;
/**
- * Constructs {@link StatusResponse} instances.
- * This interface enforces RFC2060 rules.
+ * Constructs {@link StatusResponse} instances. This interface enforces RFC2060
+ * rules.
*/
public interface StatusResponseFactory {
/**
* Creates a tagged OK status response.
- * @param tag operation tag, not null
- * @param command <code>ImapCommand</code>, not null
- * @param displayTextKey key to the human readable code to be displayed
- * @param code <code>ResponseCode</code>, not null
+ *
+ * @param tag
+ * operation tag, not null
+ * @param command
+ * <code>ImapCommand</code>, not null
+ * @param displayTextKey
+ * key to the human readable code to be displayed
+ * @param code
+ * <code>ResponseCode</code>, not null
* @return <code>StatusResponse</code>, not null
*/
- public StatusResponse taggedOk(String tag, ImapCommand command, HumanReadableTextKey displayTextKey, StatusResponse.ResponseCode code);
-
+ public StatusResponse taggedOk(String tag, ImapCommand command,
+ HumanReadableTextKey displayTextKey,
+ StatusResponse.ResponseCode code);
+
/**
* Creates a tagged NO status response.
- * @param tag <code>CharSequence</code>, not null
- * @param command <code>ImapCommand</code>, not null
- * @param displayTextKey key to the human readable code to be displayed
- * @param code <code>ResponseCode</code>, not null
+ *
+ * @param tag
+ * <code>CharSequence</code>, not null
+ * @param command
+ * <code>ImapCommand</code>, not null
+ * @param displayTextKey
+ * key to the human readable code to be displayed
+ * @param code
+ * <code>ResponseCode</code>, not null
* @return <code>StatusResponse</code>, not null
*/
- public StatusResponse taggedNo(String tag, ImapCommand command, HumanReadableTextKey displayTextKey, StatusResponse.ResponseCode code);
-
+ public StatusResponse taggedNo(String tag, ImapCommand command,
+ HumanReadableTextKey displayTextKey,
+ StatusResponse.ResponseCode code);
+
/**
* Creates a tagged BAD status response.
- * @param tag <code>CharSequence</code>, not null
- * @param command <code>ImapCommand</code>, not null
- * @param displayTextKey key to the human readable code to be displayed
- * @param code <code>ResponseCode</code>, not null
+ *
+ * @param tag
+ * <code>CharSequence</code>, not null
+ * @param command
+ * <code>ImapCommand</code>, not null
+ * @param displayTextKey
+ * key to the human readable code to be displayed
+ * @param code
+ * <code>ResponseCode</code>, not null
* @return <code>StatusResponse</code>, not null
*/
- public StatusResponse taggedBad(String tag, ImapCommand command, HumanReadableTextKey displayTextKey, StatusResponse.ResponseCode code);
+ public StatusResponse taggedBad(String tag, ImapCommand command,
+ HumanReadableTextKey displayTextKey,
+ StatusResponse.ResponseCode code);
/**
* Creates a untagged OK status response.
- * @param displayTextKey key to the human readable code to be displayed
- * @param code <code>ResponseCode</code>, not null
+ *
+ * @param displayTextKey
+ * key to the human readable code to be displayed
+ * @param code
+ * <code>ResponseCode</code>, not null
* @return <code>StatusResponse</code>, not null
*/
- public StatusResponse untaggedOk(HumanReadableTextKey displayTextKey, StatusResponse.ResponseCode code);
+ public StatusResponse untaggedOk(HumanReadableTextKey displayTextKey,
+ StatusResponse.ResponseCode code);
/**
* Creates a untagged NO status response.
- * @param displayTextKey key to the human readable code to be displayed
- * @param code <code>ResponseCode</code>, not null
+ *
+ * @param displayTextKey
+ * key to the human readable code to be displayed
+ * @param code
+ * <code>ResponseCode</code>, not null
* @return <code>StatusResponse</code>, not null
*/
- public StatusResponse untaggedNo(HumanReadableTextKey displayTextKey, StatusResponse.ResponseCode code);
+ public StatusResponse untaggedNo(HumanReadableTextKey displayTextKey,
+ StatusResponse.ResponseCode code);
/**
* Creates a untagged BAD status response.
- * @param displayTextKey key to the human readable code to be displayed
- * @param code <code>ResponseCode</code>, not null
+ *
+ * @param displayTextKey
+ * key to the human readable code to be displayed
+ * @param code
+ * <code>ResponseCode</code>, not null
* @return <code>StatusResponse</code>, not null
*/
- public StatusResponse untaggedBad(HumanReadableTextKey displayTextKey, StatusResponse.ResponseCode code);
+ public StatusResponse untaggedBad(HumanReadableTextKey displayTextKey,
+ StatusResponse.ResponseCode code);
/**
- * Creates a PREAUTH status response.
- * These are always untagged.
- * @param displayTextKey key to the human readable code to be displayed
- * @param code <code>ResponseCode</code>, not null
+ * Creates a PREAUTH status response. These are always untagged.
+ *
+ * @param displayTextKey
+ * key to the human readable code to be displayed
+ * @param code
+ * <code>ResponseCode</code>, not null
* @return <code>StatusResponse</code>, not null
*/
- public StatusResponse preauth(HumanReadableTextKey displayTextKey, StatusResponse.ResponseCode code);
+ public StatusResponse preauth(HumanReadableTextKey displayTextKey,
+ StatusResponse.ResponseCode code);
/**
- * Creates a BYE status response.
- * These are always untagged.
- * @param displayTextKey key to the human readable code to be displayed
- * @param code <code>ResponseCode</code>, not null
+ * Creates a BYE status response. These are always untagged.
+ *
+ * @param displayTextKey
+ * key to the human readable code to be displayed
+ * @param code
+ * <code>ResponseCode</code>, not null
* @return <code>StatusResponse</code>, not null
*/
- public StatusResponse bye(HumanReadableTextKey displayTextKey, StatusResponse.ResponseCode code);
+ public StatusResponse bye(HumanReadableTextKey displayTextKey,
+ StatusResponse.ResponseCode code);
/**
* Creates a tagged OK status response.
- * @param tag <code>CharSequence</code>, not null
- * @param command <code>ImapCommand</code>, not null
- * @param displayTextKey key to the human readable code to be displayed
+ *
+ * @param tag
+ * <code>CharSequence</code>, not null
+ * @param command
+ * <code>ImapCommand</code>, not null
+ * @param displayTextKey
+ * key to the human readable code to be displayed
* @return <code>StatusResponse</code>, not null
*/
- public StatusResponse taggedOk(String tag, ImapCommand command, HumanReadableTextKey displayTextKey);
-
+ public StatusResponse taggedOk(String tag, ImapCommand command,
+ HumanReadableTextKey displayTextKey);
+
/**
* Creates a tagged NO status response.
- * @param tag <code>CharSequence</code>, not null
- * @param command <code>ImapCommand</code>, not null
- * @param displayTextKey key to the human readable code to be displayed
+ *
+ * @param tag
+ * <code>CharSequence</code>, not null
+ * @param command
+ * <code>ImapCommand</code>, not null
+ * @param displayTextKey
+ * key to the human readable code to be displayed
* @return <code>StatusResponse</code>, not null
*/
- public StatusResponse taggedNo(String tag, ImapCommand command, HumanReadableTextKey displayTextKey);
-
+ public StatusResponse taggedNo(String tag, ImapCommand command,
+ HumanReadableTextKey displayTextKey);
+
/**
* Creates a tagged BAD status response.
- * @param tag <code>CharSequence</code>, not null
- * @param command <code>ImapCommand</code>, not null
- * @param displayTextKey key to the human readable code to be displayed
+ *
+ * @param tag
+ * <code>CharSequence</code>, not null
+ * @param command
+ * <code>ImapCommand</code>, not null
+ * @param displayTextKey
+ * key to the human readable code to be displayed
* @return <code>StatusResponse</code>, not null
*/
- public StatusResponse taggedBad(String tag, ImapCommand command, HumanReadableTextKey displayTextKey);
+ public StatusResponse taggedBad(String tag, ImapCommand command,
+ HumanReadableTextKey displayTextKey);
/**
* Creates a untagged OK status response.
- * @param displayTextKey key to the human readable code to be displayed
+ *
+ * @param displayTextKey
+ * key to the human readable code to be displayed
* @return <code>StatusResponse</code>, not null
*/
public StatusResponse untaggedOk(HumanReadableTextKey displayTextKey);
/**
* Creates a untagged NO status response.
- * @param displayTextKey key to the human readable code to be displayed
+ *
+ * @param displayTextKey
+ * key to the human readable code to be displayed
* @return <code>StatusResponse</code>, not null
*/
public StatusResponse untaggedNo(HumanReadableTextKey displayTextKey);
/**
* Creates a untagged BAD status response.
- * @param displayTextKey key to the human readable code to be displayed
+ *
+ * @param displayTextKey
+ * key to the human readable code to be displayed
* @return <code>StatusResponse</code>, not null
*/
public StatusResponse untaggedBad(HumanReadableTextKey displayTextKey);
/**
- * Creates a PREAUTH status response.
- * These are always untagged.
- * @param displayTextKey key to the human readable code to be displayed
+ * Creates a PREAUTH status response. These are always untagged.
+ *
+ * @param displayTextKey
+ * key to the human readable code to be displayed
* @return <code>StatusResponse</code>, not null
*/
public StatusResponse preauth(HumanReadableTextKey displayTextKey);
/**
- * Creates a BYE status response.
- * These are always untagged.
- * @param displayTextKey key to the human readable code to be displayed
+ * Creates a BYE status response. These are always untagged.
+ *
+ * @param displayTextKey
+ * key to the human readable code to be displayed
* @return <code>StatusResponse</code>, not null
*/
public StatusResponse bye(HumanReadableTextKey displayTextKey);
Modified: james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/process/ImapProcessor.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/process/ImapProcessor.java?rev=696828&r1=696827&r2=696828&view=diff
==============================================================================
--- james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/process/ImapProcessor.java (original)
+++ james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/process/ImapProcessor.java Thu Sep 18 14:44:56 2008
@@ -43,15 +43,18 @@
* <code>ImapSession</code>
* @return response, not null
*/
- public void process(ImapMessage message, Responder responder, ImapSession session);
-
+ public void process(ImapMessage message, Responder responder,
+ ImapSession session);
+
/**
* Response message sink.
*/
public interface Responder {
/**
* Writes the given response.
- * @param message <code>ImapResponseMessage</code>, not null
+ *
+ * @param message
+ * <code>ImapResponseMessage</code>, not null
*/
public void respond(ImapResponseMessage message);
}
Modified: james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/process/ImapProcessorFactory.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/process/ImapProcessorFactory.java?rev=696828&r1=696827&r2=696828&view=diff
==============================================================================
--- james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/process/ImapProcessorFactory.java (original)
+++ james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/process/ImapProcessorFactory.java Thu Sep 18 14:44:56 2008
@@ -20,7 +20,7 @@
package org.apache.james.api.imap.process;
/**
- * Builds processors.
+ * Builds processors.
*/
public interface ImapProcessorFactory {
Modified: james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/process/ImapSession.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/process/ImapSession.java?rev=696828&r1=696827&r2=696828&view=diff
==============================================================================
--- james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/process/ImapSession.java (original)
+++ james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/process/ImapSession.java Thu Sep 18 14:44:56 2008
@@ -23,32 +23,32 @@
import org.apache.james.api.imap.ImapSessionState;
-
/**
- * Encapsulates all state held for an ongoing Imap session,
- * which commences when a client first establishes a connection to the Imap
- * server, and continues until that connection is closed.
+ * Encapsulates all state held for an ongoing Imap session, which commences when
+ * a client first establishes a connection to the Imap server, and continues
+ * until that connection is closed.
+ *
* @version $Revision: 109034 $
*/
-public interface ImapSession
-{
+public interface ImapSession {
/**
* Sends any unsolicited responses to the client, such as EXISTS and FLAGS
* responses when the selected mailbox is modified by another user.
+ *
* @return <code>List</code> of {@link ImapResponseMessage}'s
*/
- List unsolicitedResponses( boolean useUid );
+ List unsolicitedResponses(boolean useUid);
+
+ List unsolicitedResponses(boolean omitExpunged, boolean useUid);
- List unsolicitedResponses( boolean omitExpunged, boolean useUid);
-
/**
- * Logs out the session.
- * Marks the connection for closure;
+ * Logs out the session. Marks the connection for closure;
*/
void logout();
/**
* Gets the current client state.
+ *
* @return Returns the current state of this session.
*/
ImapSessionState getState();
@@ -59,44 +59,52 @@
void authenticated();
/**
- * Moves this session into {@link ImapSessionState#SELECTED} state and sets the
- * supplied mailbox to be the currently selected mailbox.
- * @param mailbox The selected mailbox.
- * @param readOnly If <code>true</code>, the selection is set to be read only.
- * @throws MailboxManagerException
- */
- void selected( SelectedImapMailbox mailbox );
+ * Moves this session into {@link ImapSessionState#SELECTED} state and sets
+ * the supplied mailbox to be the currently selected mailbox.
+ *
+ * @param mailbox
+ * The selected mailbox.
+ * @param readOnly
+ * If <code>true</code>, the selection is set to be read only.
+ * @throws MailboxManagerException
+ */
+ void selected(SelectedImapMailbox mailbox);
/**
- * Moves the session out of {@link ImapSessionState#SELECTED} state and back into
- * {@link ImapSessionState#AUTHENTICATED} state. The selected mailbox is cleared.
+ * Moves the session out of {@link ImapSessionState#SELECTED} state and back
+ * into {@link ImapSessionState#AUTHENTICATED} state. The selected mailbox
+ * is cleared.
*/
void deselect();
/**
- * Provides the selected mailbox for this session, or <code>null</code> if this
- * session is not in {@link ImapSessionState#SELECTED} state.
+ * Provides the selected mailbox for this session, or <code>null</code> if
+ * this session is not in {@link ImapSessionState#SELECTED} state.
+ *
* @return the currently selected mailbox.
*/
SelectedImapMailbox getSelected();
/**
- * Gets an attribute of this session by name.
- * Implementations should ensure that access
- * is thread safe.
- * @param key name of the key, not null
- * @return <code>Object</code> value
- * or null if this attribute has unvalued
+ * Gets an attribute of this session by name. Implementations should ensure
+ * that access is thread safe.
+ *
+ * @param key
+ * name of the key, not null
+ * @return <code>Object</code> value or null if this attribute has
+ * unvalued
*/
public Object getAttribute(String key);
-
+
/**
- * Sets an attribute of this session by name.
- * Implementations should ensure that access
- * is thread safe.
- * @param key name of the key, not null
- * @param value <code>Object</code> value
- * or null to set this attribute as unvalued
+ * Sets an attribute of this session by name. Implementations should ensure
+ * that access is thread safe.
+ *
+ * @param key
+ * name of the key, not null
+ * @param value
+ * <code>Object</code> value or null to set this attribute as
+ * unvalued
*/
public void setAttribute(String key, Object value);
}
Modified: james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/process/SelectedImapMailbox.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/process/SelectedImapMailbox.java?rev=696828&r1=696827&r2=696828&view=diff
==============================================================================
--- james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/process/SelectedImapMailbox.java (original)
+++ james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/process/SelectedImapMailbox.java Thu Sep 18 14:44:56 2008
@@ -27,27 +27,28 @@
public abstract List unsolicitedResponses(boolean omitExpunged,
boolean useUid);
-
+
public int msn(long uid);
public abstract long uid(int i);
-
+
public boolean addRecent(long uid);
-
+
public boolean removeRecent(long uid);
-
+
public long[] getRecent();
-
+
public int recentCount();
-
+
public String getName();
public boolean isRecent(long uid);
-
+
/**
* Is the mailbox deleted?
- * @return true when the mailbox has been deleted by another session,
- * false otherwise
+ *
+ * @return true when the mailbox has been deleted by another session, false
+ * otherwise
*/
public boolean isDeletedByOtherSession();
}
\ No newline at end of file
Modified: james/protocols/imap/trunk/api/src/test/java/org/apache/james/api/imap/message/response/imap4rev1/AbstractTestForStatusResponseFactory.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/api/src/test/java/org/apache/james/api/imap/message/response/imap4rev1/AbstractTestForStatusResponseFactory.java?rev=696828&r1=696827&r2=696828&view=diff
==============================================================================
--- james/protocols/imap/trunk/api/src/test/java/org/apache/james/api/imap/message/response/imap4rev1/AbstractTestForStatusResponseFactory.java (original)
+++ james/protocols/imap/trunk/api/src/test/java/org/apache/james/api/imap/message/response/imap4rev1/AbstractTestForStatusResponseFactory.java Thu Sep 18 14:44:56 2008
@@ -23,18 +23,23 @@
import org.apache.james.api.imap.display.HumanReadableTextKey;
import org.jmock.MockObjectTestCase;
-abstract public class AbstractTestForStatusResponseFactory extends MockObjectTestCase {
+abstract public class AbstractTestForStatusResponseFactory extends
+ MockObjectTestCase {
private static final String TAG = "ATAG";
- private static final HumanReadableTextKey KEY = new HumanReadableTextKey("KEY", "TEXT");
- private static final StatusResponse.ResponseCode CODE = StatusResponse.ResponseCode.alert();
-
+
+ private static final HumanReadableTextKey KEY = new HumanReadableTextKey(
+ "KEY", "TEXT");
+
+ private static final StatusResponse.ResponseCode CODE = StatusResponse.ResponseCode
+ .alert();
+
private ImapCommand command;
-
+
StatusResponseFactory factory;
-
+
abstract protected StatusResponseFactory createInstance();
-
+
protected void setUp() throws Exception {
super.setUp();
factory = createInstance();
@@ -150,14 +155,16 @@
public void testPreauth() {
StatusResponse response = factory.preauth(KEY);
assertNotNull(response);
- assertEquals(StatusResponse.Type.PREAUTH, response.getServerResponseType());
+ assertEquals(StatusResponse.Type.PREAUTH, response
+ .getServerResponseType());
assertEquals(null, response.getTag());
assertEquals(KEY, response.getTextKey());
assertNull(response.getResponseCode());
assertNull(response.getCommand());
response = factory.preauth(KEY, CODE);
assertNotNull(response);
- assertEquals(StatusResponse.Type.PREAUTH, response.getServerResponseType());
+ assertEquals(StatusResponse.Type.PREAUTH, response
+ .getServerResponseType());
assertEquals(null, response.getTag());
assertEquals(KEY, response.getTextKey());
assertEquals(CODE, response.getResponseCode());
Modified: james/protocols/imap/trunk/api/src/test/java/org/apache/james/api/imap/message/response/imap4rev1/StatusResponseTest.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/api/src/test/java/org/apache/james/api/imap/message/response/imap4rev1/StatusResponseTest.java?rev=696828&r1=696827&r2=696828&view=diff
==============================================================================
--- james/protocols/imap/trunk/api/src/test/java/org/apache/james/api/imap/message/response/imap4rev1/StatusResponseTest.java (original)
+++ james/protocols/imap/trunk/api/src/test/java/org/apache/james/api/imap/message/response/imap4rev1/StatusResponseTest.java Thu Sep 18 14:44:56 2008
@@ -30,7 +30,11 @@
}
public void testResponseCodeExtension() throws Exception {
- assertEquals("Preserve names beginning with X", "XEXTENSION", StatusResponse.ResponseCode.createExtension("XEXTENSION").getCode());
- assertEquals("Correct other names", "XEXTENSION", StatusResponse.ResponseCode.createExtension("EXTENSION").getCode());
+ assertEquals("Preserve names beginning with X", "XEXTENSION",
+ StatusResponse.ResponseCode.createExtension("XEXTENSION")
+ .getCode());
+ assertEquals("Correct other names", "XEXTENSION",
+ StatusResponse.ResponseCode.createExtension("EXTENSION")
+ .getCode());
}
}
Modified: james/protocols/imap/trunk/codec/src/main/java/org/apache/james/imapserver/codec/decode/DecoderUtils.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/codec/src/main/java/org/apache/james/imapserver/codec/decode/DecoderUtils.java?rev=696828&r1=696827&r2=696828&view=diff
==============================================================================
--- james/protocols/imap/trunk/codec/src/main/java/org/apache/james/imapserver/codec/decode/DecoderUtils.java (original)
+++ james/protocols/imap/trunk/codec/src/main/java/org/apache/james/imapserver/codec/decode/DecoderUtils.java Thu Sep 18 14:44:56 2008
@@ -36,40 +36,49 @@
public final class DecoderUtils {
private static final int ASCII_ZERO = '0';
-
+
private static final int JAN_BIT = 0x1;
+
private static final int FEB_BIT = 0x2;
+
private static final int MAR_BIT = 0x4;
+
private static final int APR_BIT = 0x8;
+
private static final int MAY_BIT = 0x10;
+
private static final int JUN_BIT = 0x20;
+
private static final int JUL_BIT = 0x40;
+
private static final int AUG_BIT = 0x80;
+
private static final int SEP_BIT = 0x100;
+
private static final int OCT_BIT = 0x200;
+
private static final int NOV_BIT = 0x400;
+
private static final int DEC_BIT = 0x800;
- private static final int ALL_MONTH_BITS = JAN_BIT | FEB_BIT | MAR_BIT | APR_BIT | MAY_BIT | JUN_BIT
- | JUL_BIT | AUG_BIT | SEP_BIT | OCT_BIT | NOV_BIT | DEC_BIT;
-
- public static void setFlag( final String flagString, final Flags flags ) {
- if ( flagString.equalsIgnoreCase( MessageFlags.ANSWERED_ALL_CAPS ) ) {
+
+ private static final int ALL_MONTH_BITS = JAN_BIT | FEB_BIT | MAR_BIT
+ | APR_BIT | MAY_BIT | JUN_BIT | JUL_BIT | AUG_BIT | SEP_BIT
+ | OCT_BIT | NOV_BIT | DEC_BIT;
+
+ public static void setFlag(final String flagString, final Flags flags) {
+ if (flagString.equalsIgnoreCase(MessageFlags.ANSWERED_ALL_CAPS)) {
flags.add(Flags.Flag.ANSWERED);
- }
- else if ( flagString.equalsIgnoreCase( MessageFlags.DELETED_ALL_CAPS ) ) {
+ } else if (flagString.equalsIgnoreCase(MessageFlags.DELETED_ALL_CAPS)) {
flags.add(Flags.Flag.DELETED);
- }
- else if ( flagString.equalsIgnoreCase( MessageFlags.DRAFT_ALL_CAPS ) ) {
+ } else if (flagString.equalsIgnoreCase(MessageFlags.DRAFT_ALL_CAPS)) {
flags.add(Flags.Flag.DRAFT);
- }
- else if ( flagString.equalsIgnoreCase( MessageFlags.FLAGGED_ALL_CAPS ) ) {
+ } else if (flagString.equalsIgnoreCase(MessageFlags.FLAGGED_ALL_CAPS)) {
flags.add(Flags.Flag.FLAGGED);
- }
- else if ( flagString.equalsIgnoreCase( MessageFlags.SEEN_ALL_CAPS ) ) {
+ } else if (flagString.equalsIgnoreCase(MessageFlags.SEEN_ALL_CAPS)) {
flags.add(Flags.Flag.SEEN);
} else {
- if ( flagString.equalsIgnoreCase( MessageFlags.RECENT_ALL_CAPS) ) {
- // RFC3501 specifically excludes /Recent
+ if (flagString.equalsIgnoreCase(MessageFlags.RECENT_ALL_CAPS)) {
+ // RFC3501 specifically excludes /Recent
// The /Recent flag should be set automatically by the server
} else {
// RFC3501 allows novel flags
@@ -77,50 +86,60 @@
}
}
}
-
+
/**
* Decodes the given string as a standard IMAP date-time.
- * @param dateString standard IMAP date-time
+ *
+ * @param dateString
+ * standard IMAP date-time
* @return <code>Date</code> with time component, not null
- * @throws ProtocolException when this conversion fails
+ * @throws ProtocolException
+ * when this conversion fails
*/
- public static final Date decodeDateTime(CharSequence chars) throws ProtocolException {
+ public static final Date decodeDateTime(CharSequence chars)
+ throws ProtocolException {
if (isDateTime(chars)) {
final char dayHigh = chars.charAt(0);
final char dayLow = chars.charAt(1);
final int day = decodeFixedDay(dayHigh, dayLow);
-
+
final char monthFirstChar = chars.charAt(3);
final char monthSecondChar = chars.charAt(4);
final char monthThirdChar = chars.charAt(5);
- final int month = decodeMonth(monthFirstChar, monthSecondChar, monthThirdChar);
-
+ final int month = decodeMonth(monthFirstChar, monthSecondChar,
+ monthThirdChar);
+
final char milleniumChar = chars.charAt(7);
final char centuryChar = chars.charAt(8);
final char decadeChar = chars.charAt(9);
final char yearChar = chars.charAt(10);
- final int year = decodeYear(milleniumChar, centuryChar, decadeChar, yearChar);
-
+ final int year = decodeYear(milleniumChar, centuryChar, decadeChar,
+ yearChar);
+
final char zoneDeterminent = chars.charAt(21);
final char zoneDigitOne = chars.charAt(22);
final char zoneDigitTwo = chars.charAt(23);
final char zoneDigitThree = chars.charAt(24);
final char zoneDigitFour = chars.charAt(25);
- final int offset = decodeZone(zoneDeterminent, zoneDigitOne, zoneDigitTwo, zoneDigitThree, zoneDigitFour);
-
+ final int offset = decodeZone(zoneDeterminent, zoneDigitOne,
+ zoneDigitTwo, zoneDigitThree, zoneDigitFour);
+
final char hourHigh = chars.charAt(12);
final char hourLow = chars.charAt(13);
- final int hour = applyHourOffset(offset, decodeNumber(hourHigh, hourLow));
-
+ final int hour = applyHourOffset(offset, decodeNumber(hourHigh,
+ hourLow));
+
final char minuteHigh = chars.charAt(15);
final char minuteLow = chars.charAt(16);
- final int minute = applyMinuteOffset(offset, decodeNumber(minuteHigh, minuteLow));
-
+ final int minute = applyMinuteOffset(offset, decodeNumber(
+ minuteHigh, minuteLow));
+
final char secondHigh = chars.charAt(18);
final char secondLow = chars.charAt(19);
final int second = decodeNumber(secondHigh, secondLow);
-
- final GregorianCalendar calendar = new GregorianCalendar(TimeZone.getTimeZone("GMT"), Locale.US);
+
+ final GregorianCalendar calendar = new GregorianCalendar(TimeZone
+ .getTimeZone("GMT"), Locale.US);
calendar.clear();
calendar.set(year, month, day, hour, minute, second);
final Date result = calendar.getTime();
@@ -130,14 +149,15 @@
if (chars == null) {
message = "Expected a date-time but was nothing.";
} else {
- message = new StringBuffer("Expected a date-time but was "). append(chars.toString()).toString();
+ message = new StringBuffer("Expected a date-time but was ")
+ .append(chars.toString()).toString();
}
-
+
throw new ProtocolException(message);
}
-
+
}
-
+
private static boolean isDateTime(CharSequence chars) {
final boolean result;
if (chars == null) {
@@ -146,30 +166,35 @@
// Be liberal in what you accept
result = false;
} else {
- result =true;
+ result = true;
}
return result;
}
private static int applyMinuteOffset(final int offset, final int minutes) {
- final int result = minutes - ((Math.abs(offset) % 100) * (offset == 0 ? 0 : offset > 0 ? 1 : -1));
+ final int result = minutes
+ - ((Math.abs(offset) % 100) * (offset == 0 ? 0 : offset > 0 ? 1
+ : -1));
return result;
}
-
+
private static int applyHourOffset(final int offset, final int hours) {
final int result = hours - (offset / 100);
return result;
}
-
- public static int decodeNumber(final char high, final char low) throws ProtocolException {
+
+ public static int decodeNumber(final char high, final char low)
+ throws ProtocolException {
return (10 * decodeDigit(high)) + decodeDigit(low);
}
-
- public static int decodeZone(char zoneDeterminent, char zoneDigitOne,
- char zoneDigitTwo, char zoneDigitThree, char zoneDigitFour) throws ProtocolException {
- if (isInvalidZone(zoneDeterminent, zoneDigitOne, zoneDigitTwo,
+
+ public static int decodeZone(char zoneDeterminent, char zoneDigitOne,
+ char zoneDigitTwo, char zoneDigitThree, char zoneDigitFour)
+ throws ProtocolException {
+ if (isInvalidZone(zoneDeterminent, zoneDigitOne, zoneDigitTwo,
zoneDigitThree, zoneDigitFour)) {
- throw createTimeZoneException(zoneDeterminent, zoneDigitOne, zoneDigitTwo, zoneDigitThree, zoneDigitFour);
+ throw createTimeZoneException(zoneDeterminent, zoneDigitOne,
+ zoneDigitTwo, zoneDigitThree, zoneDigitFour);
}
final int sign;
if (zoneDeterminent == '+') {
@@ -177,67 +202,87 @@
} else if (zoneDeterminent == '-') {
sign = -1;
} else {
- throw createTimeZoneException(zoneDeterminent, zoneDigitOne, zoneDigitTwo, zoneDigitThree, zoneDigitFour);
+ throw createTimeZoneException(zoneDeterminent, zoneDigitOne,
+ zoneDigitTwo, zoneDigitThree, zoneDigitFour);
}
- final int result = sign * ((1000 * decodeDigit(zoneDigitOne)) +
- (100 * decodeDigit(zoneDigitTwo)) +
- (10 * decodeDigit(zoneDigitThree)) +
- decodeDigit(zoneDigitFour));
+ final int result = sign
+ * ((1000 * decodeDigit(zoneDigitOne))
+ + (100 * decodeDigit(zoneDigitTwo))
+ + (10 * decodeDigit(zoneDigitThree)) + decodeDigit(zoneDigitFour));
return result;
}
- private static ProtocolException createTimeZoneException(char zoneDeterminent, char zoneDigitOne, char zoneDigitTwo, char zoneDigitThree, char zoneDigitFour) {
- return new ProtocolException ("Expected time-zone but was " + zoneDeterminent +
- zoneDigitOne + zoneDigitTwo + zoneDigitThree + zoneDigitFour);
+ private static ProtocolException createTimeZoneException(
+ char zoneDeterminent, char zoneDigitOne, char zoneDigitTwo,
+ char zoneDigitThree, char zoneDigitFour) {
+ return new ProtocolException("Expected time-zone but was "
+ + zoneDeterminent + zoneDigitOne + zoneDigitTwo
+ + zoneDigitThree + zoneDigitFour);
}
- private static boolean isInvalidZone(char zoneDeterminent, char zoneDigitOne,
- char zoneDigitTwo, char zoneDigitThree, char zoneDigitFour) {
+ private static boolean isInvalidZone(char zoneDeterminent,
+ char zoneDigitOne, char zoneDigitTwo, char zoneDigitThree,
+ char zoneDigitFour) {
final boolean result;
if (zoneDeterminent == '+' || zoneDeterminent == '-') {
- result = !(isSimpleDigit(zoneDigitOne) && isSimpleDigit(zoneDigitTwo)
+ result = !(isSimpleDigit(zoneDigitOne)
+ && isSimpleDigit(zoneDigitTwo)
&& isSimpleDigit(zoneDigitThree) && isSimpleDigit(zoneDigitFour));
} else {
result = true;
}
return result;
}
-
+
/**
* Is the given character an ASCII digit.
- * @param character character
+ *
+ * @param character
+ * character
* @return true if ASCII 0-9, false otherwise
*/
public static boolean isSimpleDigit(char character) {
final boolean result = !(character < '0' || character > '9');
return result;
}
-
+
/**
* Decodes a year.
- * @param milleniumChar first digit
- * @param centuryChar second digit
- * @param decadeChar third digit
- * @param yearChar forth digit
+ *
+ * @param milleniumChar
+ * first digit
+ * @param centuryChar
+ * second digit
+ * @param decadeChar
+ * third digit
+ * @param yearChar
+ * forth digit
* @return {@link Calendar} year
* @throws ProtocolException
*/
- public static int decodeYear(final char milleniumChar, final char centuryChar, final char decadeChar, final char yearChar) throws ProtocolException {
- return (decodeDigit(milleniumChar) * 1000) +
- (decodeDigit(centuryChar) * 100) +
- (decodeDigit(decadeChar) * 10) +
- decodeDigit(yearChar);
+ public static int decodeYear(final char milleniumChar,
+ final char centuryChar, final char decadeChar, final char yearChar)
+ throws ProtocolException {
+ return (decodeDigit(milleniumChar) * 1000)
+ + (decodeDigit(centuryChar) * 100)
+ + (decodeDigit(decadeChar) * 10) + decodeDigit(yearChar);
}
/**
* Decodes asn IMAP <code>date-month</code> to a {@link Calendar} month.
- * @param monthFirstChar first character in a month triple
- * @param monthSecondChar second character in a month triple
- * @param monthThirdChar third character in a month triple
+ *
+ * @param monthFirstChar
+ * first character in a month triple
+ * @param monthSecondChar
+ * second character in a month triple
+ * @param monthThirdChar
+ * third character in a month triple
* @return {@link Calendar} month (<code>JAN</code>=0)
* @throws ProtocolException
*/
- public static int decodeMonth(final char monthFirstChar, final char monthSecondChar, final char monthThirdChar) throws ProtocolException {
+ public static int decodeMonth(final char monthFirstChar,
+ final char monthSecondChar, final char monthThirdChar)
+ throws ProtocolException {
final int result;
// Bitwise magic! Eliminate possibility by three switches
int possibleMonths = ALL_MONTH_BITS;
@@ -275,7 +320,7 @@
possibleMonths &= DEC_BIT;
break;
default:
- possibleMonths = 0;
+ possibleMonths = 0;
break;
}
switch (monthSecondChar) {
@@ -390,35 +435,45 @@
result = Calendar.DECEMBER;
break;
default:
- throw new ProtocolException("Expected month name but was "
+ throw new ProtocolException("Expected month name but was "
+ monthFirstChar + monthSecondChar + monthThirdChar);
}
return result;
}
-
- public static int decodeFixedDay(final char dayHigh, final char dayLow) throws ProtocolException {
+ public static int decodeFixedDay(final char dayHigh, final char dayLow)
+ throws ProtocolException {
int result = decodeDigit(dayLow);
switch (dayHigh) {
- case '0': return result;
- case '1': return result += 10;
- case '2': return result += 20;
- case '3': return result += 30;
- case ' ': return result;
+ case '0':
+ return result;
+ case '1':
+ return result += 10;
+ case '2':
+ return result += 20;
+ case '3':
+ return result += 30;
+ case ' ':
+ return result;
}
- throw new ProtocolException("Expected SP, 0, 1, 2, or 3 but was " + dayHigh);
+ throw new ProtocolException("Expected SP, 0, 1, 2, or 3 but was "
+ + dayHigh);
}
-
+
/**
* Decodes a number character into a <code>0-9</code> digit.
+ *
* @param character
* @return a digit
- * @throws ProtocolException if the char is not a digit
+ * @throws ProtocolException
+ * if the char is not a digit
*/
- public static final int decodeDigit(char character) throws ProtocolException {
+ public static final int decodeDigit(char character)
+ throws ProtocolException {
final int result = character - ASCII_ZERO;
if (result < 0 || result > 9) {
- throw new ProtocolException("Expected a digit but was '" + character + "'");
+ throw new ProtocolException("Expected a digit but was '"
+ + character + "'");
}
return result;
}
Modified: james/protocols/imap/trunk/codec/src/main/java/org/apache/james/imapserver/codec/decode/DelegatingImapCommandParser.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/codec/src/main/java/org/apache/james/imapserver/codec/decode/DelegatingImapCommandParser.java?rev=696828&r1=696827&r2=696828&view=diff
==============================================================================
--- james/protocols/imap/trunk/codec/src/main/java/org/apache/james/imapserver/codec/decode/DelegatingImapCommandParser.java (original)
+++ james/protocols/imap/trunk/codec/src/main/java/org/apache/james/imapserver/codec/decode/DelegatingImapCommandParser.java Thu Sep 18 14:44:56 2008
@@ -18,11 +18,11 @@
****************************************************************/
package org.apache.james.imapserver.codec.decode;
-
public interface DelegatingImapCommandParser {
public abstract ImapCommandParserFactory getParserFactory();
- public abstract void setParserFactory(ImapCommandParserFactory imapCommandFactory);
+ public abstract void setParserFactory(
+ ImapCommandParserFactory imapCommandFactory);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org