View Javadoc

1   /*
2    * Copyright (c) 2005-2007 Creative Sphere Limited.
3    * All rights reserved. This program and the accompanying materials
4    * are made available under the terms of the Eclipse Public License v1.0
5    * which accompanies this distribution, and is available at
6    * http://www.eclipse.org/legal/epl-v10.html
7    *
8    * Contributors:
9    *
10   *   Creative Sphere - initial API and implementation
11   *
12   */
13  package org.abstracthorizon.mercury.maildir.uid;
14  
15  import java.io.File;
16  import javax.mail.Session;
17  import javax.mail.URLName;
18  import org.abstracthorizon.mercury.maildir.MaildirFolder;
19  import org.abstracthorizon.mercury.maildir.MaildirFolderData;
20  import org.abstracthorizon.mercury.maildir.MaildirStore;
21  
22  
23  /**
24   * <p>This store implementation is aggressive UID implementation.
25   * It maintains UIDs within file names instead using separate index file.
26   * Each file added to the store must have precisely defined name
27   * (see {@link org.abstracthorizon.mercury.maildir.uid.UIDMaildirMessage})
28   * or while being added its name will be changed to conform to it.</p>
29   * <p>
30   * Consequences of such store's behaviour are quicker, less complicated
31   * maintenance of UID and mapping from UIDs to messages; simple tracking
32   * of externally removed and added messages. Negative side is that external
33   * application would see messages disappearing when added to the store and
34   * new messages with exactly the same content appearing after (while)
35   * this store is executing over same directory.
36   * </p>
37   * <p>Only two files that this store needs are &quot;.nextuid&quot; where the last
38   * uid number is stored and &quot;.uidvalidity&quot; where folder's uid validity is
39   * stored.</p>
40   *
41   * @author Daniel Sendula
42   */
43  public class UIDMaildirStore extends MaildirStore {
44  
45      /** Name of a file storing next uid number */
46      public static final String NEXT_UID_FILE = ".nextuid";
47  
48      /** Name of a file storing folder's uid validity */
49      public static final String UID_VALIDITY_FILE = ".uidvalidity";
50  
51      /**
52       * Constructor
53       * @param session mail session
54       * @param urlname url name
55       */
56      public UIDMaildirStore(Session session, URLName urlname) {
57          super(session, urlname);
58      }
59  
60      /**
61       * This implementation creates {@link UIDMaildirFolder}
62       * @param folderData folder data
63       * @return new maildir folder
64       */
65      protected MaildirFolder createFolder(MaildirFolderData folderData) {
66          return new UIDMaildirFolder(this, folderData);
67      }
68  
69      /**
70       * This implementation creates {@link UIDMaildirFolderData} from supplied file.
71       * @param file file
72       * @return new maildir folder data
73       */
74      protected MaildirFolderData createFolderData(File file) {
75          return new UIDMaildirFolderData(this, file);
76      }
77  }