KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > james > imapserver > SimpleFolderRecord


1 /***********************************************************************
2  * Copyright (c) 2000-2004 The Apache Software Foundation. *
3  * All rights reserved. *
4  * ------------------------------------------------------------------- *
5  * Licensed under the Apache License, Version 2.0 (the "License"); you *
6  * may not use this file except in compliance with the License. You *
7  * may obtain a copy of the License at: *
8  * *
9  * http://www.apache.org/licenses/LICENSE-2.0 *
10  * *
11  * Unless required by applicable law or agreed to in writing, software *
12  * distributed under the License is distributed on an "AS IS" BASIS, *
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or *
14  * implied. See the License for the specific language governing *
15  * permissions and limitations under the License. *
16  ***********************************************************************/

17
18 package org.apache.james.imapserver;
19
20 import org.apache.avalon.framework.activity.Initializable;
21
22 import java.io.Serializable JavaDoc;
23 import java.util.Map JavaDoc;
24 import java.util.Set JavaDoc;
25
26 /**
27  * Object representing the record of a folder in an IMAP on an IMAP Host.
28  *
29  * @version 0.1 on 14 Dec 2000
30  */

31
32 public class SimpleFolderRecord
33     implements FolderRecord, Serializable JavaDoc, Initializable {
34
35     private final String JavaDoc fullName;
36     private final String JavaDoc owner;
37     private final String JavaDoc absoluteName;
38
39     private boolean nameInUse;
40     private boolean deleted;
41     private int uidValidity;
42     private int highestUID;
43     private Set JavaDoc usersWithLookupRights;
44     private Set JavaDoc usersWithReadRights;
45     private boolean marked;
46     private boolean notSelectableByAnyone;
47     private int exists;
48     private int recent;
49     private Map JavaDoc unseenByUser;
50
51     /**
52      * Constructor Records the full name, including namespace, of this mailbox
53      * relative, to a specified user, and the absolute name..
54      *
55      * @param mailboxName String mailbox hierarchical name including namespace
56      * @param user String a user. An empty user parameter indicates that the
57      * mailbox name is absolute.
58      */

59     public SimpleFolderRecord( String JavaDoc user,
60                                String JavaDoc absName) {
61         //fullName = mailboxName;
62
owner = user;
63         absoluteName = absName;
64         fullName = absName;
65     }
66
67     public void initialize() {
68         nameInUse = true;
69         deleted = false;
70         uidValidity = 1;
71         highestUID = 1;
72     }
73
74     public String JavaDoc getFullName() {
75         return fullName;
76     }
77
78     public String JavaDoc getUser() {
79         return owner;
80     }
81
82     public String JavaDoc getAbsoluteName() {
83         return absoluteName;
84     }
85
86     public void setNameInUse(boolean state) {
87         nameInUse = state;
88     }
89
90     public boolean isNameInUse() {
91         return nameInUse;
92     }
93
94     public void setDeleted(boolean state) {
95         deleted = state;
96     }
97
98     public boolean isDeleted() {
99         return deleted;
100     }
101
102     public void setUidValidity(int uidV) {
103         if (uidV > uidValidity) {
104             uidValidity = uidV;
105         }
106     }
107
108     public int getUidValidity() {
109         return uidValidity;
110     }
111
112     public void setHighestUid(int uid) {
113         highestUID = uid;
114     }
115
116     public int getHighestUid() {
117         return highestUID;
118     }
119
120     public void setLookupRights(Set JavaDoc users) {
121         usersWithLookupRights = users;
122     }
123
124     public boolean hasLookupRights(String JavaDoc user) {
125         return usersWithLookupRights.contains(user) ;
126     }
127  
128     public void setReadRights(Set JavaDoc users) {
129         usersWithReadRights = users;
130     }
131
132     public boolean hasReadRights(String JavaDoc user) {
133         return usersWithReadRights.contains(user) ;
134     }
135
136     public void setMarked(boolean mark) {
137         marked = mark;
138     }
139
140     public boolean isMarked() {
141         return marked;
142     }
143
144     public void setNotSelectableByAnyone(boolean state) {
145         notSelectableByAnyone = state;
146     }
147
148     public boolean isNotSelectableByAnyone() {
149         return notSelectableByAnyone;
150     }
151
152     public boolean isSelectable(String JavaDoc user) {
153         return (!notSelectableByAnyone && hasReadRights(user));
154     }
155
156     public void setExists(int num) {
157         exists = num;
158     }
159
160     public int getExists() {
161         return exists;
162     }
163
164     public void setRecent(int num) {
165         recent = num;
166     }
167
168     public int getRecent() {
169         return recent;
170     }
171
172     public void setUnseenbyUser(Map JavaDoc unseen) {
173         unseenByUser = unseen;
174     }
175
176     public int getUnseen(String JavaDoc user) {
177         if (unseenByUser.containsKey(user)) {
178             Integer JavaDoc unseen = ((Integer JavaDoc)unseenByUser.get(user));
179             return unseen.intValue();
180         } else {
181             return exists;
182         }
183     }
184 }
185
Popular Tags