KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > ristretto > message > MailboxInfo


1 /* ***** BEGIN LICENSE BLOCK *****
2  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3  *
4  * The contents of this file are subject to the Mozilla Public License Version
5  * 1.1 (the "License"); you may not use this file except in compliance with
6  * the License. You may obtain a copy of the License at
7  * http://www.mozilla.org/MPL/
8  *
9  * Software distributed under the License is distributed on an "AS IS" basis,
10  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11  * for the specific language governing rights and limitations under the
12  * License.
13  *
14  * The Original Code is Ristretto Mail API.
15  *
16  * The Initial Developers of the Original Code are
17  * Timo Stich and Frederik Dietz.
18  * Portions created by the Initial Developers are Copyright (C) 2004
19  * All Rights Reserved.
20  *
21  * Contributor(s):
22  *
23  * Alternatively, the contents of this file may be used under the terms of
24  * either the GNU General Public License Version 2 or later (the "GPL"), or
25  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26  * in which case the provisions of the GPL or the LGPL are applicable instead
27  * of those above. If you wish to allow use of your version of this file only
28  * under the terms of either the GPL or the LGPL, and not to allow others to
29  * use your version of this file under the terms of the MPL, indicate your
30  * decision by deleting the provisions above and replace them with the notice
31  * and other provisions required by the GPL or the LGPL. If you do not delete
32  * the provisions above, a recipient may use your version of this file under
33  * the terms of any one of the MPL, the GPL or the LGPL.
34  *
35  * ***** END LICENSE BLOCK ***** */

36 package org.columba.ristretto.message;
37
38 /**
39  * Datastructure that stores the status
40  * of a mailbox.
41  *
42  * @author tstich
43  *
44  */

45 public class MailboxInfo {
46     
47     private String JavaDoc[] definedFlags;
48     private int exists;
49     private int recent;
50     private int unseen;
51     
52     private int firstUnseen;
53     private String JavaDoc[] permanentFlags;
54     
55     private int uidNext;
56     private int uidValidity;
57     
58     private boolean writeAccess;
59     
60     /**
61      * Constructs the MailboxInfo.
62      */

63     public MailboxInfo() {
64         exists = recent = unseen = firstUnseen = 0;
65         uidNext = uidValidity = -1;
66     }
67     
68     /**
69      * Resets the MailboxInfo.
70      *
71      */

72     public void reset() {
73         exists = recent = unseen = firstUnseen = 0;
74         uidNext = uidValidity = -1;
75     }
76     
77     /**
78      * @return Returns the definedFlags.
79      */

80     public String JavaDoc[] getDefinedFlags() {
81         return (String JavaDoc[]) definedFlags.clone();
82     }
83     /**
84      * @param definedFlags The definedFlags to set.
85      */

86     public void setDefinedFlags(String JavaDoc[] definedFlags) {
87         this.definedFlags = definedFlags;
88     }
89     /**
90      * @return Returns the exists.
91      */

92     public int getExists() {
93         return exists;
94     }
95     /**
96      * @param exists The exists to set.
97      */

98     public void setExists(int exists) {
99         this.exists = exists;
100     }
101     /**
102      * @return Returns the firstUnseen.
103      */

104     public int getFirstUnseen() {
105         return firstUnseen;
106     }
107     /**
108      * @param firstUnseen The firstUnseen to set.
109      */

110     public void setFirstUnseen(int firstUnseen) {
111         this.firstUnseen = firstUnseen;
112     }
113     /**
114      * @return Returns the permanentFlags.
115      */

116     public String JavaDoc[] getPermanentFlags() {
117         return (String JavaDoc[]) permanentFlags.clone();
118     }
119     /**
120      * @param permanentFlags The permanentFlags to set.
121      */

122     public void setPermanentFlags(String JavaDoc[] permanentFlags) {
123         this.permanentFlags = permanentFlags;
124     }
125     /**
126      * @return Returns the recent.
127      */

128     public int getRecent() {
129         return recent;
130     }
131     /**
132      * @param recent The recent to set.
133      */

134     public void setRecent(int recent) {
135         this.recent = recent;
136     }
137     /**
138      * @return Returns the uidNext.
139      */

140     public int getUidNext() {
141         return uidNext;
142     }
143     /**
144      * @param uidNext The uidNext to set.
145      */

146     public void setUidNext(int uidNext) {
147         this.uidNext = uidNext;
148     }
149     /**
150      * @return Returns the uidValidity.
151      */

152     public int getUidValidity() {
153         return uidValidity;
154     }
155     /**
156      * @param uidValidity The uidValidity to set.
157      */

158     public void setUidValidity(int uidValidity) {
159         this.uidValidity = uidValidity;
160     }
161     /**
162      * @return Returns the writeAccess.
163      */

164     public boolean isWriteAccess() {
165         return writeAccess;
166     }
167     /**
168      * @param writeAccess The writeAccess to set.
169      */

170     public void setWriteAccess(boolean writeAccess) {
171         this.writeAccess = writeAccess;
172     }
173     
174     /**
175      * @return the predicted next UID.
176      */

177     public int predictNextUid() {
178         return uidNext++;
179     }
180     
181     /**
182      * Increase the number of existing messages.
183      */

184     public void incExists() {
185         exists++;
186     }
187     
188     /**
189      * Increase the number of unseen messages.
190      */

191     public void incUnseen() {
192         unseen++;
193     }
194     
195     /**
196      * Increase the number of recent messages.
197      */

198     public void incRecent() {
199         recent ++;
200     }
201
202     /**
203      * Decrease the number of exising messages.
204      */

205     public void decExists() {
206         exists--;
207     }
208     
209     /**
210      * Decrease the number of unseen messages.
211      */

212     public void decUnseen() {
213         unseen--;
214     }
215     
216     /**
217      * Decrease the number of recent messages
218      */

219     public void decRecent() {
220         recent--;
221     }
222     /**
223      * @return Returns the unseen.
224      */

225     public int getUnseen() {
226         return unseen;
227     }
228     /**
229      * @param unseen The unseen to set.
230      */

231     public void setUnseen(int unseen) {
232         this.unseen = unseen;
233     }
234
235     /**
236      * This equals method checks if the number of existing, unseen and recent
237      * Messages of the both MailboxInfos are equal. Other attributes are
238      * not compared.
239      *
240      * @see java.lang.Object#equals(java.lang.Object)
241      */

242     public boolean equals(Object JavaDoc obj) {
243         if( !(obj instanceof MailboxInfo) ) return false;
244         
245         MailboxInfo other = (MailboxInfo) obj;
246         
247         return exists == other.exists && recent == other.recent && unseen == other.unseen;
248     }
249 }
250
Popular Tags