Package net.fortuna.mstor.connector.jcr
Class JcrFolder
- java.lang.Object
-
- org.jcrom.AbstractJcrEntity
-
- net.fortuna.mstor.connector.jcr.JcrFolder
-
- All Implemented Interfaces:
Serializable,FolderDelegate<JcrMessage>
public class JcrFolder extends org.jcrom.AbstractJcrEntity implements FolderDelegate<JcrMessage>
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description JcrFolder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longallocateUid(MessageDelegate message)Allocates a new message UID for the folder.voidappendMessages(javax.mail.Message[] messages)Append the specified messages to this delegate.voidclose()Close the folder delegate.booleancreate(int type)Initialise the delegate based on the specified folder type.booleandelete()Delete the folder delegate.booleanexists()Indicates whether the folder represented by this delegate exists.voidexpunge(javax.mail.Message[] deleted)Permanently delete the specified messages from this delegate.intgetDeletedMessageCount()Optional support for more efficient implementation.FolderDelegate<JcrMessage>getFolder(String name)Returns a child folder delegate with the specified name.StringgetFolderName()StringgetFullName()longgetLastModified()Returns the last modification timestamp of this folder.longgetLastUid()Retrieves the last allocated message UID for the folder.JcrMessagegetMessage(int messageNumber)Returns message delegate corresponding to the specified message id.InputStreamgetMessageAsStream(int index)Returns an input stream from which to read the specified message.intgetMessageCount()Returns the number of messages in the folder delegate.FolderDelegate<JcrMessage>getParent()chargetSeparator()intgetType()longgetUidValidity()Returns the UID validity associated with the metadata.FolderDelegate<JcrMessage>[]list(String pattern)Returns a list of child folder delegates matching the specified pattern.voidopen(int mode)Open the folder delegate.booleanrenameTo(String name)Rename the folder delegate.
-
-
-
Method Detail
-
allocateUid
public long allocateUid(MessageDelegate message) throws UnsupportedOperationException
Allocates a new message UID for the folder.- Specified by:
allocateUidin interfaceFolderDelegate<JcrMessage>- Parameters:
message- the message to allocate a UID value to- Returns:
- the allocated UID for the specified message
- Throws:
UnsupportedOperationException- if this method is not supported by the folder implementation
-
appendMessages
public void appendMessages(javax.mail.Message[] messages) throws javax.mail.MessagingExceptionAppend the specified messages to this delegate.- Specified by:
appendMessagesin interfaceFolderDelegate<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()
Close the folder delegate.- Specified by:
closein interfaceFolderDelegate<JcrMessage>
-
create
public boolean create(int type) throws javax.mail.MessagingExceptionInitialise the delegate based on the specified folder type.- Specified by:
createin interfaceFolderDelegate<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:
deletein interfaceFolderDelegate<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:
existsin interfaceFolderDelegate<JcrMessage>- Returns:
- true if the folder exists, otherwise false
-
expunge
public void expunge(javax.mail.Message[] deleted)
Permanently delete the specified messages from this delegate.- Specified by:
expungein interfaceFolderDelegate<JcrMessage>- Parameters:
deleted- an array of deleted messages to expunge
-
getFolder
public FolderDelegate<JcrMessage> getFolder(String name)
Returns a child folder delegate with the specified name.- Specified by:
getFolderin interfaceFolderDelegate<JcrMessage>- Parameters:
name- a folder name- Returns:
- the folder delegate with the specified name, or null if the folder doesn't exist
-
getFullName
public String getFullName()
- Specified by:
getFullNamein interfaceFolderDelegate<JcrMessage>- Returns:
- the full name of the folder.
-
getLastModified
public long getLastModified() throws UnsupportedOperationExceptionReturns the last modification timestamp of this folder.- Specified by:
getLastModifiedin interfaceFolderDelegate<JcrMessage>- Returns:
- a timestamp as a long value
- Throws:
UnsupportedOperationException- if this method is not supported by the folder implementation
-
getLastUid
public long getLastUid() throws UnsupportedOperationExceptionRetrieves the last allocated message UID for the folder.- Specified by:
getLastUidin interfaceFolderDelegate<JcrMessage>- Returns:
- the latest UID for the folder
- Throws:
UnsupportedOperationException- if this method is not supported by the folder implementation
-
getMessage
public JcrMessage getMessage(int messageNumber)
Returns message delegate corresponding to the specified message id. If no delegate exists a new Message delegate is created.- Specified by:
getMessagein interfaceFolderDelegate<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
-
getMessageAsStream
public InputStream getMessageAsStream(int index)
Returns an input stream from which to read the specified message.- Specified by:
getMessageAsStreamin interfaceFolderDelegate<JcrMessage>- Parameters:
index- the index of the message to return- Returns:
- an input stream for the specified message
-
getMessageCount
public int getMessageCount()
Returns the number of messages in the folder delegate.- Specified by:
getMessageCountin interfaceFolderDelegate<JcrMessage>- Returns:
- the total message count
-
getDeletedMessageCount
public int getDeletedMessageCount() throws UnsupportedOperationExceptionOptional support for more efficient implementation.- Specified by:
getDeletedMessageCountin interfaceFolderDelegate<JcrMessage>- Returns:
- the total deleted message count
- Throws:
UnsupportedOperationException- if this method is not supported by the folder implementation
-
getParent
public FolderDelegate<JcrMessage> getParent()
- Specified by:
getParentin interfaceFolderDelegate<JcrMessage>- Returns:
- the parent folder delegate of this delegate.
-
getSeparator
public char getSeparator()
- Specified by:
getSeparatorin interfaceFolderDelegate<JcrMessage>- Returns:
- the folder separator for this delegate type.
-
getType
public int getType()
- Specified by:
getTypein interfaceFolderDelegate<JcrMessage>- Returns:
- the type of folder this delegate represents.
- See Also:
Folder.HOLDS_FOLDERS,Folder.HOLDS_MESSAGES
-
getUidValidity
public long getUidValidity() throws UnsupportedOperationExceptionReturns the UID validity associated with the metadata. If no UID validity exist a new value is initialised.- Specified by:
getUidValidityin interfaceFolderDelegate<JcrMessage>- Returns:
- a long representation of the UID validity
- Throws:
UnsupportedOperationException- if this method is not supported by the folder implementation
-
list
public FolderDelegate<JcrMessage>[] list(String pattern)
Returns a list of child folder delegates matching the specified pattern.- Specified by:
listin interfaceFolderDelegate<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:
openin interfaceFolderDelegate<JcrMessage>- Parameters:
mode- the mode to open the folder- See Also:
Folder.READ_ONLY,Folder.READ_WRITE
-
renameTo
public boolean renameTo(String name)
Rename the folder delegate.- Specified by:
renameToin interfaceFolderDelegate<JcrMessage>- Parameters:
name- the new folder name- Returns:
- true if the folder is renamed, otherwise false
-
getFolderName
public final String getFolderName()
- Specified by:
getFolderNamein interfaceFolderDelegate<JcrMessage>- Returns:
- the folderName
-
-