1 36 package org.columba.ristretto.imap; 37 38 import java.util.ArrayList ; 39 import java.util.Arrays ; 40 import java.util.Iterator ; 41 import java.util.List ; 42 43 49 public class NamespaceCollection { 50 51 54 public static final int PERSONAL = 0; 55 58 public static final int OTHER_USER = 1; 59 62 public static final int SHARED = 2; 63 64 65 private List personal; 66 private List otherUser; 67 private List shared; 68 69 72 public NamespaceCollection() { 73 personal = new ArrayList (); 74 otherUser = new ArrayList (); 75 shared = new ArrayList (); 76 } 77 78 83 public void addPersonalNamespace(Namespace ns) { 84 personal.add(ns); 85 } 86 87 92 public void addOtherUserNamespace(Namespace ns) { 93 otherUser.add(ns); 94 } 95 96 101 public void addSharedNamespace(Namespace ns) { 102 shared.add(ns); 103 } 104 105 110 public Namespace getPersonalNamespace() { 111 return (Namespace) personal.get(0); 112 } 113 114 120 public Namespace getPersonalNamespace(int i) { 121 return (Namespace) personal.get(i); 122 } 123 124 129 public Namespace getOtherUserNamespace() { 130 return (Namespace) otherUser.get(0); 131 } 132 133 139 public Namespace getOtherUserNamespace(int i) { 140 return (Namespace) otherUser.get(i); 141 } 142 143 148 public Namespace getSharedNamespace() { 149 return (Namespace) shared.get(0); 150 } 151 152 158 public Namespace getSharedNamespace(int i) { 159 return (Namespace) shared.get(i); 160 } 161 162 163 169 public Iterator getPersonalIterator() { 170 return personal.iterator(); 171 } 172 173 178 public Iterator getOtherUserIterator() { 179 return otherUser.iterator(); 180 } 181 182 187 public Iterator getSharedIterator() { 188 return shared.iterator(); 189 } 190 191 197 public void addNamespace(int type, Namespace ns) { 198 switch( type ) { 199 case PERSONAL : { 200 addPersonalNamespace(ns); 201 break; 202 } 203 204 case OTHER_USER : { 205 addOtherUserNamespace(ns); 206 break; 207 } 208 209 case SHARED : { 210 addSharedNamespace(ns); 211 break; 212 } 213 } 214 } 215 216 219 public void addPersonalNamespace(Namespace[] namespaces) { 220 personal.addAll(Arrays.asList(namespaces)); 221 } 222 223 226 public void addOtherUserNamespace(Namespace[] namespaces) { 227 otherUser.addAll(Arrays.asList(namespaces)); 228 } 229 230 233 public void addSharedNamespace(Namespace[] namespaces) { 234 shared.addAll(Arrays.asList(namespaces)); 235 } 236 237 242 public int getPersonalNamespaceSize() { 243 return personal.size(); 244 } 245 246 251 public int getOtherUserNamespaceSize() { 252 return otherUser.size(); 253 } 254 255 260 public int getSharedNamespaceSize() { 261 return shared.size(); 262 } 263 264 } 265 | Popular Tags |