net.fortuna.mstor.connector.mbox
Class MetaFolder

java.lang.Object
  extended by net.fortuna.mstor.connector.AbstractFolderDelegate<T>
      extended by net.fortuna.mstor.connector.mbox.AbstractMetaFolder<MetaMessage>
          extended by net.fortuna.mstor.connector.mbox.MetaFolder
All Implemented Interfaces:
FolderDelegate<MetaMessage>

public class MetaFolder
extends AbstractMetaFolder<MetaMessage>

A JDOM-based implementation of a meta folder.

Author:
benfortuna
 $Id$

 Created: 18/08/2004
 

Field Summary
static java.lang.String FILE_EXTENSION
           
 
Constructor Summary
MetaFolder(FolderDelegate<MessageDelegate> delegate)
          Constructs a new meta folder instance.
MetaFolder(org.jdom.Namespace namespace, FolderDelegate<MessageDelegate> delegate)
          Constructs a new meta folder instance with the specified namespace.
 
Method Summary
protected  MetaMessage createMessage(int messageNumber)
          
protected  java.lang.String getFileExtension()
          
 MetaFolder getFolder(java.lang.String name)
          Returns a child folder delegate with the specified name.
 long getLastUid()
          Retrieves the last allocated message UID for the folder.
 MetaMessage getMessage(int messageNumber)
          Returns message delegate corresponding to the specified message id.
 MetaFolder getParent()
          
 long getUidValidity()
          Returns the UID validity associated with the metadata.
 MetaFolder[] list(java.lang.String pattern)
          Returns a list of child folder delegates matching the specified pattern.
protected  MetaMessage[] removeMessages(javax.mail.Message[] messages)
          
 void save()
          
protected  void setLastUid(long uid)
          
 
Methods inherited from class net.fortuna.mstor.connector.mbox.AbstractMetaFolder
appendMessages, close, create, delete, exists, expunge, getDelegate, getFile, getFolderName, getFullName, getLastModified, getMessageAsStream, getMessageCount, getSeparator, getType, newUidValidity, open, renameTo
 
Methods inherited from class net.fortuna.mstor.connector.AbstractFolderDelegate
allocateUid, getDeletedMessageCount
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FILE_EXTENSION

public static final java.lang.String FILE_EXTENSION
See Also:
Constant Field Values
Constructor Detail

MetaFolder

public MetaFolder(FolderDelegate<MessageDelegate> delegate)
Constructs a new meta folder instance.

Parameters:
file - the meta folder file

MetaFolder

public MetaFolder(org.jdom.Namespace namespace,
                  FolderDelegate<MessageDelegate> delegate)
Constructs a new meta folder instance with the specified namespace.

Parameters:
file - the meta folder file
namespace - the namespace for the metadata
Method Detail

getParent

public MetaFolder getParent()

Returns:
the parent folder delegate of this delegate.

getFolder

public MetaFolder getFolder(java.lang.String name)
                     throws javax.mail.MessagingException
Returns a child folder delegate with the specified name.

Parameters:
name - a folder name
Returns:
the folder delegate with the specified name, or null if the folder doesn't exist
Throws:
javax.mail.MessagingException - where an unexpected error occurs retrieving the folder

list

public MetaFolder[] list(java.lang.String pattern)
Returns a list of child folder delegates matching the specified pattern.

Parameters:
pattern - a pattern to match folders against
Returns:
a list of folder delegates

getMessage

public final MetaMessage getMessage(int messageNumber)
                             throws DelegateException
Returns message delegate corresponding to the specified message id. If no delegate exists a new Message delegate is created.

Parameters:
messageNumber - the message number of the message to retrieve
Returns:
the message with the specified message number, or null if the messages doesn't exist
Throws:
DelegateException - where an error occurs retrieving the message

createMessage

protected final MetaMessage createMessage(int messageNumber)

Specified by:
createMessage in class AbstractFolderDelegate<MetaMessage>
Parameters:
messageNumber - the message number to associate with the new message
Returns:
a new message delegate instance

removeMessages

protected MetaMessage[] removeMessages(javax.mail.Message[] messages)

Specified by:
removeMessages in class AbstractMetaFolder<MetaMessage>

getLastUid

public final long getLastUid()
Retrieves the last allocated message UID for the folder.

Returns:
the latest UID for the folder

getUidValidity

public final long getUidValidity()
                          throws java.lang.UnsupportedOperationException,
                                 javax.mail.MessagingException
Returns the UID validity associated with the metadata. If no UID validity exist a new value is initialised.

Returns:
a long representation of the UID validity
Throws:
java.lang.UnsupportedOperationException - if this method is not supported by the folder implementation
javax.mail.MessagingException - if an error occurs retrieving the validity value

setLastUid

protected final void setLastUid(long uid)
                         throws DelegateException

Specified by:
setLastUid in class AbstractFolderDelegate<MetaMessage>
Parameters:
uid - the latest UID for the folder
Throws:
DelegateException - where an error occurs updating the latest UID

getFileExtension

protected java.lang.String getFileExtension()

Specified by:
getFileExtension in class AbstractMetaFolder<MetaMessage>
Returns:

save

public final void save()
                throws DelegateException

Specified by:
save in class AbstractMetaFolder<MetaMessage>
Throws:
DelegateException


Copyright © 2004-2011 Micronode. All Rights Reserved.