net.fortuna.mstor.connector.jcr
Class JcrFolder

java.lang.Object
  extended by org.jcrom.AbstractJcrEntity
      extended by net.fortuna.mstor.connector.jcr.JcrFolder
All Implemented Interfaces:
java.io.Serializable, FolderDelegate<JcrMessage>

public class JcrFolder
extends org.jcrom.AbstractJcrEntity
implements FolderDelegate<JcrMessage>

Author:
Ben
 $Id$

 Created on 22/01/2009
 
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.jcrom.AbstractJcrEntity
name, path
 
Constructor Summary
JcrFolder()
           
 
Method Summary
 long allocateUid(MessageDelegate message)
          Allocates a new message UID for the folder.
 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.
 int getDeletedMessageCount()
          Optional support for more efficient implementation.
 FolderDelegate<JcrMessage> getFolder(java.lang.String name)
          Returns a child folder delegate with the specified name.
 java.lang.String getFolderName()
           
 java.lang.String getFullName()
          
 long getLastModified()
          Returns the last modification timestamp of this folder.
 long getLastUid()
          Retrieves the last allocated message UID for the folder.
 JcrMessage getMessage(int messageNumber)
          Returns message delegate corresponding to the specified message id.
 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.
 FolderDelegate<JcrMessage> getParent()
          
 char getSeparator()
          
 int getType()
          
 long getUidValidity()
          Returns the UID validity associated with the metadata.
 FolderDelegate<JcrMessage>[] list(java.lang.String pattern)
          Returns a list of child folder delegates matching the specified pattern.
 void open(int mode)
          Open the folder delegate.
 boolean renameTo(java.lang.String name)
          Rename the folder delegate.
 
Methods inherited from class org.jcrom.AbstractJcrEntity
getName, getPath, setName, setPath
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JcrFolder

public JcrFolder()
Method Detail

allocateUid

public long allocateUid(MessageDelegate message)
                 throws java.lang.UnsupportedOperationException,
                        DelegateException
Allocates a new message UID for the folder.

Specified by:
allocateUid in interface FolderDelegate<JcrMessage>
Parameters:
message - the message to allocate a UID value to
Returns:
the allocated UID for the specified message
Throws:
java.lang.UnsupportedOperationException - if this method is not supported by the folder implementation
DelegateException - where an error occurs allocating a UID

appendMessages

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

Specified by:
appendMessages in interface FolderDelegate<JcrMessage>
Parameters:
messages - an array of messages to append to the folder
Throws:
javax.mail.MessagingException - where an error occurs appending the messages

close

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

Specified by:
close in interface FolderDelegate<JcrMessage>
Throws:
javax.mail.MessagingException - where an unexpected error occurs closing the folder

create

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

Specified by:
create in interface FolderDelegate<JcrMessage>
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

delete

public boolean delete()
Delete the folder delegate.

Specified by:
delete in interface FolderDelegate<JcrMessage>
Returns:
true if the delegate is deleted, otherwise false

exists

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

Specified by:
exists in interface FolderDelegate<JcrMessage>
Returns:
true if the folder exists, otherwise false

expunge

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

Specified by:
expunge in interface FolderDelegate<JcrMessage>
Parameters:
deleted - an array of deleted messages to expunge
Throws:
javax.mail.MessagingException - where an error occurs expunging the messages

getFolder

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

Specified by:
getFolder in interface FolderDelegate<JcrMessage>
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

getFullName

public java.lang.String getFullName()

Specified by:
getFullName in interface FolderDelegate<JcrMessage>
Returns:
the full name of the folder.

getLastModified

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

Specified by:
getLastModified in interface FolderDelegate<JcrMessage>
Returns:
a timestamp as a long value
Throws:
java.lang.UnsupportedOperationException - if this method is not supported by the folder implementation

getLastUid

public long getLastUid()
                throws java.lang.UnsupportedOperationException
Retrieves the last allocated message UID for the folder.

Specified by:
getLastUid in interface FolderDelegate<JcrMessage>
Returns:
the latest UID for the folder
Throws:
java.lang.UnsupportedOperationException - if this method is not supported by the folder implementation

getMessage

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

Specified by:
getMessage in interface FolderDelegate<JcrMessage>
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

getMessageAsStream

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

Specified by:
getMessageAsStream in interface FolderDelegate<JcrMessage>
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

getMessageCount

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

Specified by:
getMessageCount in interface FolderDelegate<JcrMessage>
Returns:
the total message count
Throws:
javax.mail.MessagingException - where an unexpected error occurs retrieving the message count

getDeletedMessageCount

public int getDeletedMessageCount()
                           throws javax.mail.MessagingException,
                                  java.lang.UnsupportedOperationException
Optional support for more efficient implementation.

Specified by:
getDeletedMessageCount in interface FolderDelegate<JcrMessage>
Returns:
the total deleted message count
Throws:
javax.mail.MessagingException - where an unexpected error occurs
java.lang.UnsupportedOperationException - if this method is not supported by the folder implementation

getParent

public FolderDelegate<JcrMessage> getParent()

Specified by:
getParent in interface FolderDelegate<JcrMessage>
Returns:
the parent folder delegate of this delegate.

getSeparator

public char getSeparator()

Specified by:
getSeparator in interface FolderDelegate<JcrMessage>
Returns:
the folder separator for this delegate type.

getType

public int getType()

Specified by:
getType in interface FolderDelegate<JcrMessage>
Returns:
the type of folder this delegate represents.
See Also:
Folder.HOLDS_FOLDERS, Folder.HOLDS_MESSAGES

getUidValidity

public 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.

Specified by:
getUidValidity in interface FolderDelegate<JcrMessage>
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

list

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

Specified by:
list in interface FolderDelegate<JcrMessage>
Parameters:
pattern - a pattern to match folders against
Returns:
a list of folder delegates

open

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

Specified by:
open in interface FolderDelegate<JcrMessage>
Parameters:
mode - the mode to open the folder
See Also:
Folder.READ_ONLY, Folder.READ_WRITE

renameTo

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

Specified by:
renameTo in interface FolderDelegate<JcrMessage>
Parameters:
name - the new folder name
Returns:
true if the folder is renamed, otherwise false

getFolderName

public final java.lang.String getFolderName()
Specified by:
getFolderName in interface FolderDelegate<JcrMessage>
Returns:
the folderName


Copyright © 2004-2011 Micronode. All Rights Reserved.