net.fortuna.mstor.connector.mbox
Class AbstractMetaFolder<T extends MessageDelegate>

java.lang.Object
  extended by net.fortuna.mstor.connector.AbstractFolderDelegate<T>
      extended by net.fortuna.mstor.connector.mbox.AbstractMetaFolder<T>
Type Parameters:
T - message delegate type
All Implemented Interfaces:
FolderDelegate<T>
Direct Known Subclasses:
MetaFolder, YamlMetaFolder

public abstract class AbstractMetaFolder<T extends MessageDelegate>
extends AbstractFolderDelegate<T>

Base implementation of a meta folder.

Author:
benfortuna
 $Id$

 Created: 18/08/2004
 

Constructor Summary
AbstractMetaFolder(FolderDelegate<MessageDelegate> delegate)
          Constructs a new meta folder instance.
 
Method Summary
 void appendMessages(javax.mail.Message[] messages)
          Append the specified messages to this delegate.
 void close()
          Close the folder delegate.
 boolean create(int type)
          Initialise the delegate based on the specified folder type.
 boolean delete()
          Delete the folder delegate.
 boolean exists()
          Indicates whether the folder represented by this delegate exists.
 void expunge(javax.mail.Message[] deleted)
          Permanently delete the specified messages from this delegate.
protected  FolderDelegate<MessageDelegate> getDelegate()
           
protected  java.io.File getFile()
           
protected abstract  java.lang.String getFileExtension()
           
 java.lang.String getFolderName()
          
 java.lang.String getFullName()
          
 long getLastModified()
          Returns the last modification timestamp of this folder.
 java.io.InputStream getMessageAsStream(int index)
          Returns an input stream from which to read the specified message.
 int getMessageCount()
          Returns the number of messages in the folder delegate.
 char getSeparator()
          
 int getType()
          
protected  int newUidValidity()
           
 void open(int mode)
          Open the folder delegate.
protected abstract  T[] removeMessages(javax.mail.Message[] deleted)
           
 boolean renameTo(java.lang.String name)
          Rename the folder delegate.
protected abstract  void save()
           
 
Methods inherited from class net.fortuna.mstor.connector.AbstractFolderDelegate
allocateUid, createMessage, getDeletedMessageCount, setLastUid
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.fortuna.mstor.connector.FolderDelegate
getFolder, getLastUid, getMessage, getParent, getUidValidity, list
 

Constructor Detail

AbstractMetaFolder

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

Parameters:
file - the meta folder file
Method Detail

getType

public final int getType()

Returns:
the type of folder this delegate represents.
See Also:
Folder.HOLDS_FOLDERS, Folder.HOLDS_MESSAGES

getFolderName

public final java.lang.String getFolderName()

Returns:
Returns the name.

getFullName

public final java.lang.String getFullName()

Returns:
the full name of the folder.

exists

public final boolean exists()
Indicates whether the folder represented by this delegate exists.

Returns:
true if the folder exists, otherwise false

delete

public final boolean delete()
Delete the folder delegate.

Returns:
true if the delegate is deleted, otherwise false

renameTo

public final boolean renameTo(java.lang.String name)
Rename the folder delegate.

Parameters:
name - the new folder name
Returns:
true if the folder is renamed, otherwise false

open

public final void open(int mode)
Open the folder delegate.

Parameters:
mode - the mode to open the folder
See Also:
Folder.READ_ONLY, Folder.READ_WRITE

close

public final void close()
                 throws javax.mail.MessagingException
Close the folder delegate.

Throws:
javax.mail.MessagingException - where an unexpected error occurs closing the folder

getSeparator

public final char getSeparator()

Returns:
the folder separator for this delegate type.

getMessageCount

public final int getMessageCount()
                          throws javax.mail.MessagingException
Returns the number of messages in the folder delegate.

Returns:
the total message count
Throws:
javax.mail.MessagingException - where an unexpected error occurs retrieving the message count

getMessageAsStream

public final java.io.InputStream getMessageAsStream(int index)
                                             throws java.io.IOException
Returns an input stream from which to read the specified message.

Parameters:
index - the index of the message to return
Returns:
an input stream for the specified message
Throws:
java.io.IOException - where an error occurs

appendMessages

public final void appendMessages(javax.mail.Message[] messages)
                          throws javax.mail.MessagingException
Append the specified messages to this delegate.

Parameters:
messages - an array of messages to append to the folder
Throws:
javax.mail.MessagingException - where an error occurs appending the messages

create

public final boolean create(int type)
                     throws javax.mail.MessagingException
Initialise the delegate based on the specified folder type.

Parameters:
type - a folder type
Returns:
true if the delegate is created, otherwise false
Throws:
javax.mail.MessagingException - where an unexpected error occurs creating the delegate

expunge

public final void expunge(javax.mail.Message[] deleted)
                   throws javax.mail.MessagingException
Permanently delete the specified messages from this delegate.

Parameters:
deleted - an array of deleted messages to expunge
Throws:
javax.mail.MessagingException - where an error occurs expunging the messages

newUidValidity

protected int newUidValidity()
Returns:

getFile

protected final java.io.File getFile()
Returns:
the underlying meta file

getDelegate

protected final FolderDelegate<MessageDelegate> getDelegate()
Returns:

getFileExtension

protected abstract java.lang.String getFileExtension()
Returns:

removeMessages

protected abstract T[] removeMessages(javax.mail.Message[] deleted)
Parameters:
deleted -

save

protected abstract void save()
                      throws DelegateException
Throws:
DelegateException

getLastModified

public final long getLastModified()
                           throws java.lang.UnsupportedOperationException
Returns the last modification timestamp of this folder.

Returns:
a timestamp as a long value
Throws:
java.lang.UnsupportedOperationException - if this method is not supported by the folder implementation


Copyright © 2004-2011 Micronode. All Rights Reserved.