com.openexchange.mail.dataobjects
Class MailFolder

java.lang.Object
  extended by com.openexchange.mail.dataobjects.MailFolder
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
ReadOnlyMailFolder

public class MailFolder
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

MailFolder - a data container object for a mail folder

Author:
Thorben Betten
See Also:
Serialized Form

Nested Class Summary
static class MailFolder.DefaultFolderType
          The default folder type.
 
Field Summary
static java.lang.String DEFAULT_FOLDER_ID
          Virtual fullname of mailbox's root folder
static java.lang.String DEFAULT_FOLDER_NAME
          Virtual name of mailbox's root folder
 
Constructor Summary
MailFolder()
          Initializes a new MailFolder
 
Method Summary
 void addPermission(MailPermission permission)
          Adds a permission.
 void addPermissions(java.util.Collection<? extends MailPermission> permissions)
          Adds a collection of permissions.
 void addPermissions(MailPermission[] permissions)
          Adds an array of permissions.
 java.lang.Object clone()
           
 boolean containsDefaultFolder()
          Checks if default-folder flag was set through setDefaultFolder(boolean).
 boolean containsDefaultFolderType()
          Checks if default folder type was set through setDefaultFolderType(DefaultFolderType).
 boolean containsDeletedMessageCount()
          Checks if the number of messages was set through setDeletedMessageCount(int).
 boolean containsExists()
          Checks if folder existence status was set through setExists(boolean).
 boolean containsFullname()
          Checks if fullname is set through setFullname(String).
 boolean containsHoldsFolders()
          Checks if the holds-folder flag was set through setHoldsFolders(boolean).
 boolean containsHoldsMessages()
          Checks if he holds-messages flag was set through setHoldsMessages(boolean).
 boolean containsMessageCount()
          Checks if number of messages was set through setMessageCount(int).
 boolean containsName()
          Checks if name was set through setName(String).
 boolean containsNewMessageCount()
          Checks if the number of new messages was set through setNewMessageCount(int).
 boolean containsOwnPermission()
          Checks if own permission was set through setOwnPermission(MailPermission).
 boolean containsParentFullname()
          Checks if parent fullname was set through setParentFullname(String).
 boolean containsPermissions()
          Checks if permissions were set through addPermission(MailPermission), addPermissions(Collection), or addPermissions(MailPermission[]).
 boolean containsRootFolder()
          Checks if root-folder flag was set through setRootFolder(boolean).
 boolean containsSeparator()
          Checks if seperator character was set through setSeparator(char).
 boolean containsShared()
          Checks if the shared flag was set.
 boolean containsSubfolders()
          Checks if has-subfolders flag was set through setSubfolders(boolean).
 boolean containsSubscribed()
          Checks if subscribed status was set through setSubscribed(boolean).
 boolean containsSubscribedSubfolders()
          Checks if the has-subscribed-subfolders flag was set through setSubscribedSubfolders(boolean).
 boolean containsSupportsUserFlags()
          Checks if the supports-user-flags flag was set through setSupportsUserFlags(boolean).
 boolean containsUnreadMessageCount()
          Checks if the number of unread messages was set through setUnreadMessageCount(int).
 boolean exists()
          Checks if this folder exists.
 MailFolder.DefaultFolderType getDefaultFolderType()
          Gets the default folder type.
 int getDeletedMessageCount()
          Gets the number of messages marked for deletion in this folder
 java.lang.String getFullname()
          Gets the fullname.
 int getMessageCount()
          Gets the number of messages.
 java.lang.String getName()
          Gets the name.
 int getNewMessageCount()
          Gets the number of new messages (since last time this folder was accessed).
 MailPermission getOwnPermission()
          Gets the permission for currently logged-in user accessing this folder The returned permission should reflect user's permission regardless if mailing system supports permissions or not.
 java.lang.String getParentFullname()
          Gets the parent fullname.
 MailPermission[] getPermissions()
           
 char getSeparator()
          Gets the separator character.
 int getUnreadMessageCount()
          Gets the number of unread messages.
 boolean hasSubfolders()
          Checks if this mail folder has subfolders.
 boolean hasSubscribedSubfolders()
          Checks if this mail folder has subscribed subfolders.
 boolean isConfirmedHam()
          Checks if this mail folder denotes the CONFIRMED_HAM folder.
 boolean isConfirmedSpam()
          Checks if this mail folder denotes the CONFIRMED_SPAM folder.
 boolean isDefaultFolder()
          Checks if this folder denotes a default folder (Drafts, Sent, Trash, etc.)
 boolean isDrafts()
          Checks if this mail folder denotes the DRAFTS folder.
 boolean isHoldsFolders()
          Checks if this folder is able to hold folders.
 boolean isHoldsMessages()
          Checks if this folder is able to hold messages.
 boolean isInbox()
          Checks if this mail folder denotes the INBOX folder.
 boolean isRootFolder()
          Checks if this folder denotes the root folder
 boolean isSent()
          Checks if this mail folder denotes the SENT folder.
 boolean isShared()
          Checks if this folder is shared.
 boolean isSpam()
          Checks if this mail folder denotes the SPAM folder.
 boolean isSubscribed()
          Returns whether the denoted mail folder is subscribed or not.
 boolean isSupportsUserFlags()
          Checks if this folder supports user flags.
 boolean isTrash()
          Checks if this mail folder denotes the TRASH folder.
 void removeDefaultFolder()
          Removes the default folder flag.
 void removeDefaultFolderType()
          Removes the default folder type.
 void removeDeletedMessageCount()
          Removes the number of messages marked for deletion in this folder.
 void removeExists()
          Removes exists status.
 void removeFullname()
          Removes the fullname.
 void removeHoldsFolders()
          Removes the holds-folders flag
 void removeHoldsMessages()
          Removes the holds-messages flag
 void removeMessageCount()
          Removes the message-count.
 void removeName()
          Removes the name.
 void removeNewMessageCount()
          Removes the new-message-count.
 void removeOwnPermission()
          Removes the own permission.
 void removeParentFullname()
          Removes the parent fullname.
 void removePermissions()
          Removes the permissions.
 void removeRootFolder()
          Removes the root folder flag.
 void removeSeparator()
          Removes the separator character.
 void removeShared()
          Removes the supports-user-flags flag.
 void removeSubfolders()
          Removes the has-subfolders flag.
 void removeSubscribed()
          Removes the subscription status.
 void removeSubscribedSubfolders()
          Removes has-subscribed-subfolders flag.
 void removeSupportsUserFlags()
          Removes the supports-user-flags flag.
 void removeUnreadMessageCount()
          Removes the unread-message-count.
 void setDefaultFolder(boolean defaultFolder)
          Sets the default folder flag.
 void setDefaultFolderType(MailFolder.DefaultFolderType defaulFolderType)
          Sets default folder type.
 void setDeletedMessageCount(int deletedMessageCount)
          Sets the number of messages marked for deletion in this folder.
 void setExists(boolean exists)
          Sets the exists status.
 void setFullname(java.lang.String fullname)
          Sets this mail folder's fullname.
 void setHoldsFolders(boolean holdsFolders)
          Sets if this folder holds folders.
 void setHoldsMessages(boolean holdsMessages)
          Sets if this folder holds messages.
 void setMessageCount(int messageCount)
          Sets the number of messages.
 void setName(java.lang.String name)
          Sets this mail folder's name.
 void setNewMessageCount(int newMessageCount)
          Sets the number of new messages.
 void setOwnPermission(MailPermission ownPermission)
          Sets own permission.
 void setParentFullname(java.lang.String parentFullname)
          Sets the parent fullname.
 void setRootFolder(boolean rootFolder)
          Sets the root folder flag.
 void setSeparator(char separator)
          Sets the separator character.
 void setShared(boolean shared)
          Sets the shared flag.
 void setSubfolders(boolean hasSubfolders)
          Sets if this mail folder has subfolders.
 void setSubscribed(boolean subscribed)
          Sets the subscription status for this mail folder.
 void setSubscribedSubfolders(boolean hasSubscribedSubfolders)
          Sets if this mail folder has subscribed subfolders.
 void setSupportsUserFlags(boolean supportsUserFlags)
          Sets the supports-user-flags flag.
 void setUnreadMessageCount(int unreadMessageCount)
          Sets the number of unread messages.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_FOLDER_NAME

public static final java.lang.String DEFAULT_FOLDER_NAME
Virtual name of mailbox's root folder

See Also:
Constant Field Values

DEFAULT_FOLDER_ID

public static final java.lang.String DEFAULT_FOLDER_ID
Virtual fullname of mailbox's root folder

See Also:
Constant Field Values
Constructor Detail

MailFolder

public MailFolder()
Initializes a new MailFolder

Method Detail

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

getFullname

public java.lang.String getFullname()
Gets the fullname.

Returns:
The fullname (DEFAULT_FOLDER_ID if this mail folder denotes the root folder)

containsFullname

public boolean containsFullname()
Checks if fullname is set through setFullname(String).

Returns:
true if fullname is set; otherwise false

removeFullname

public void removeFullname()
Removes the fullname.


setFullname

public void setFullname(java.lang.String fullname)
Sets this mail folder's fullname.

If this mail folder denotes the root folder, DEFAULT_FOLDER_ID is supposed to be set as fullname.

Parameters:
fullname - the fullname to set

hasSubfolders

public boolean hasSubfolders()
Checks if this mail folder has subfolders.

Returns:
true if this mail folder has subfolders; otherwise false

containsSubfolders

public boolean containsSubfolders()
Checks if has-subfolders flag was set through setSubfolders(boolean).

Returns:
true if has-subfolders flag is set; otherwise false

removeSubfolders

public void removeSubfolders()
Removes the has-subfolders flag.


setSubfolders

public void setSubfolders(boolean hasSubfolders)
Sets if this mail folder has subfolders.

Parameters:
hasSubfolders - the has-subfolders flag to set

hasSubscribedSubfolders

public boolean hasSubscribedSubfolders()
Checks if this mail folder has subscribed subfolders.

Returns:
true if this mail folder has subscribed subfolders; otherwise false

containsSubscribedSubfolders

public boolean containsSubscribedSubfolders()
Checks if the has-subscribed-subfolders flag was set through setSubscribedSubfolders(boolean).

Returns:
true if the has-subscribed-subfolders flag was set; otherwise false

removeSubscribedSubfolders

public void removeSubscribedSubfolders()
Removes has-subscribed-subfolders flag.


setSubscribedSubfolders

public void setSubscribedSubfolders(boolean hasSubscribedSubfolders)
Sets if this mail folder has subscribed subfolders.

Parameters:
hasSubscribedSubfolders - the has-subscribed-subfolders flag to set

getDefaultFolderType

public MailFolder.DefaultFolderType getDefaultFolderType()
Gets the default folder type.

Returns:
The default folder type

isInbox

public boolean isInbox()
Checks if this mail folder denotes the INBOX folder.

Returns:
true if this mail folder denotes the INBOX folder; otherwise false

isDrafts

public boolean isDrafts()
Checks if this mail folder denotes the DRAFTS folder.

Returns:
true if this mail folder denotes the DRAFTS folder; otherwise false

isSent

public boolean isSent()
Checks if this mail folder denotes the SENT folder.

Returns:
true if this mail folder denotes the SENT folder; otherwise false

isSpam

public boolean isSpam()
Checks if this mail folder denotes the SPAM folder.

Returns:
true if this mail folder denotes the SPAM folder; otherwise false

isTrash

public boolean isTrash()
Checks if this mail folder denotes the TRASH folder.

Returns:
true if this mail folder denotes the TRASH folder; otherwise false

isConfirmedSpam

public boolean isConfirmedSpam()
Checks if this mail folder denotes the CONFIRMED_SPAM folder.

Returns:
true if this mail folder denotes the CONFIRMED_SPAM folder; otherwise false

isConfirmedHam

public boolean isConfirmedHam()
Checks if this mail folder denotes the CONFIRMED_HAM folder.

Returns:
true if this mail folder denotes the CONFIRMED_HAM folder; otherwise false

containsDefaultFolderType

public boolean containsDefaultFolderType()
Checks if default folder type was set through setDefaultFolderType(DefaultFolderType).

Returns:
true if default folder type is set; otherwise false

removeDefaultFolderType

public void removeDefaultFolderType()
Removes the default folder type.


setDefaultFolderType

public void setDefaultFolderType(MailFolder.DefaultFolderType defaulFolderType)
Sets default folder type.

Parameters:
name - the name to set

getName

public java.lang.String getName()
Gets the name.

Returns:
The name

containsName

public boolean containsName()
Checks if name was set through setName(String).

Returns:
true if name is set; otherwise false

removeName

public void removeName()
Removes the name.


setName

public void setName(java.lang.String name)
Sets this mail folder's name.

If this mail folder denotes the root folder, DEFAULT_FOLDER_NAME is supposed to be set as name.

Parameters:
name - the name to set

isSubscribed

public boolean isSubscribed()
Returns whether the denoted mail folder is subscribed or not.

If mailing system does not support subscription, true is supposed to be returned.

Returns:
Whether the denoted mail folder is subscribed or not

containsSubscribed

public boolean containsSubscribed()
Checks if subscribed status was set through setSubscribed(boolean).

Returns:
true if subscribed is set; otherwise false

removeSubscribed

public void removeSubscribed()
Removes the subscription status.


setSubscribed

public void setSubscribed(boolean subscribed)
Sets the subscription status for this mail folder.

If mailing system does not support subscription, true is supposed to be set as subscription status.

Parameters:
subscribed - the subscription status to set

getDeletedMessageCount

public int getDeletedMessageCount()
Gets the number of messages marked for deletion in this folder

Returns:
The number of messages marked for deletion in this folder or -1 if this mail folder does not hold messages
See Also:
isHoldsMessages()

containsDeletedMessageCount

public boolean containsDeletedMessageCount()
Checks if the number of messages was set through setDeletedMessageCount(int).

Returns:
true if deletedMessageCount is set; otherwise false

removeDeletedMessageCount

public void removeDeletedMessageCount()
Removes the number of messages marked for deletion in this folder.


setDeletedMessageCount

public void setDeletedMessageCount(int deletedMessageCount)
Sets the number of messages marked for deletion in this folder.

Parameters:
deletedMessageCount - The number of messages marked for deletion or -1 if this mail folder does not hold messages

exists

public boolean exists()
Checks if this folder exists.

Returns:
true if folder exists in mailbox; otherwise false

containsExists

public boolean containsExists()
Checks if folder existence status was set through setExists(boolean).

Returns:
true if exists status is set; otherwise false

removeExists

public void removeExists()
Removes exists status.


setExists

public void setExists(boolean exists)
Sets the exists status.

Parameters:
exists - true if folder exists in mailbox; otherwise false

getMessageCount

public int getMessageCount()
Gets the number of messages.

Returns:
The number of messages or -1 if this mail folder does not hold messages
See Also:
isHoldsMessages()

containsMessageCount

public boolean containsMessageCount()
Checks if number of messages was set through setMessageCount(int).

Returns:
true if messageCount is set; otherwise false

removeMessageCount

public void removeMessageCount()
Removes the message-count.


setMessageCount

public void setMessageCount(int messageCount)
Sets the number of messages.

Parameters:
messageCount - The number of messages or -1 if this mail folder does not hold messages

getNewMessageCount

public int getNewMessageCount()
Gets the number of new messages (since last time this folder was accessed).

Returns:
The number of new messages or -1 if this mail folder does not hold messages.
See Also:
isHoldsMessages()

containsNewMessageCount

public boolean containsNewMessageCount()
Checks if the number of new messages was set through setNewMessageCount(int).

Returns:
true if newMessageCount is set; otherwise false

removeNewMessageCount

public void removeNewMessageCount()
Removes the new-message-count.


setNewMessageCount

public void setNewMessageCount(int newMessageCount)
Sets the number of new messages.

Parameters:
newMessageCount - The number of new messages or -1 if this mail folder does not hold messages

getUnreadMessageCount

public int getUnreadMessageCount()
Gets the number of unread messages.

Returns:
The number of unread messages or -1 if this mail folder does not hold messages
See Also:
isHoldsMessages()

containsUnreadMessageCount

public boolean containsUnreadMessageCount()
Checks if the number of unread messages was set through setUnreadMessageCount(int).

Returns:
true if unreadMessageCount is set; otherwise false

removeUnreadMessageCount

public void removeUnreadMessageCount()
Removes the unread-message-count.


setUnreadMessageCount

public void setUnreadMessageCount(int unreadMessageCount)
Sets the number of unread messages.

Parameters:
unreadMessageCount - The number of unread messages or -1 if this mail folder does not hold messages

getSeparator

public char getSeparator()
Gets the separator character.

Returns:
The separator character.
See Also:
MailConfig#getDefaultSeparator()

containsSeparator

public boolean containsSeparator()
Checks if seperator character was set through setSeparator(char).

Returns:
true if separator is set; otherwise false

removeSeparator

public void removeSeparator()
Removes the separator character.


setSeparator

public void setSeparator(char separator)
Sets the separator character.

If mailing system does not support a separator character, MailConfig#getDefaultSeparator() should to be used.

Parameters:
separator - the separator to set

getParentFullname

public java.lang.String getParentFullname()
Gets the parent fullname.

Returns:
The parent fullname or null if this mail folder denotes the root folder

containsParentFullname

public boolean containsParentFullname()
Checks if parent fullname was set through setParentFullname(String).

Returns:
true if parentFullname is set; otherwise false

removeParentFullname

public void removeParentFullname()
Removes the parent fullname.


setParentFullname

public void setParentFullname(java.lang.String parentFullname)
Sets the parent fullname.

If this mail folder denotes the root folder, null is supposed to be set.

Parameters:
parentFullname - the parent fullname to set

isHoldsMessages

public boolean isHoldsMessages()
Checks if this folder is able to hold messages.

Returns:
true if this folder is able to hold messages; otherwise false

containsHoldsMessages

public boolean containsHoldsMessages()
Checks if he holds-messages flag was set through setHoldsMessages(boolean).

Returns:
true if the holds-messages flag is set; otherwise false

removeHoldsMessages

public void removeHoldsMessages()
Removes the holds-messages flag


setHoldsMessages

public void setHoldsMessages(boolean holdsMessages)
Sets if this folder holds messages.

Parameters:
holdsMessages - true if folder holds messages; otherwise false

isHoldsFolders

public boolean isHoldsFolders()
Checks if this folder is able to hold folders.

Returns:
true if this folder is able to hold folders; otherwise false

containsHoldsFolders

public boolean containsHoldsFolders()
Checks if the holds-folder flag was set through setHoldsFolders(boolean).

Returns:
true if this folder has the holds-folder flag set; otherwise false

removeHoldsFolders

public void removeHoldsFolders()
Removes the holds-folders flag


setHoldsFolders

public void setHoldsFolders(boolean holdsFolders)
Sets if this folder holds folders.

Parameters:
holdsFolders - true if folder holds folders; otherwise false

getOwnPermission

public MailPermission getOwnPermission()
Gets the permission for currently logged-in user accessing this folder

The returned permission should reflect user's permission regardless if mailing system supports permissions or not. An instance of DefaultMailPermission is supposed to be returned on missing permissions support except for the root folder. The root folder should indicate no object permissions in any case, but the folder permission varies if mailing system allows subfolder creation below root folder or not. The returned permission must reflect the allowed behavior.

Returns:
The own permission

containsOwnPermission

public boolean containsOwnPermission()
Checks if own permission was set through setOwnPermission(MailPermission).

Returns:
true if own permission is set; otherwise false

removeOwnPermission

public void removeOwnPermission()
Removes the own permission.


setOwnPermission

public void setOwnPermission(MailPermission ownPermission)
Sets own permission.

Apply an instance of DefaultMailPermission if mailing system does not support permissions, except if this mail folder denotes the root folder, then apply null or altered instance of DefaultMailPermission with no object permissions but properly reflects folder permission as described in getOwnPermission().

Please note that even if the mail system does not support permissions the entity must be set on the DefaultMailPermission object. Please use OCLPermission.setEntity(int) for this.

Parameters:
ownPermission - The own permission to set

isRootFolder

public boolean isRootFolder()
Checks if this folder denotes the root folder

Returns:
true if this folder denotes the root folder; otherwise false

containsRootFolder

public boolean containsRootFolder()
Checks if root-folder flag was set through setRootFolder(boolean).

Returns:
true if root-folder flag is set; otherwise false

removeRootFolder

public void removeRootFolder()
Removes the root folder flag.


setRootFolder

public void setRootFolder(boolean rootFolder)
Sets the root folder flag.

Parameters:
rootFolder - the root folder flag to set

isDefaultFolder

public boolean isDefaultFolder()
Checks if this folder denotes a default folder (Drafts, Sent, Trash, etc.)

Returns:
true if this folder denotes a default folder; otherwise false

containsDefaultFolder

public boolean containsDefaultFolder()
Checks if default-folder flag was set through setDefaultFolder(boolean).

Returns:
true if default-folder flag is set; otherwise false

removeDefaultFolder

public void removeDefaultFolder()
Removes the default folder flag.


setDefaultFolder

public void setDefaultFolder(boolean defaultFolder)
Sets the default folder flag.

Parameters:
defaultFolder - the default folder flag to set

addPermission

public void addPermission(MailPermission permission)
Adds a permission.

Parameters:
permission - The permission to add

addPermissions

public void addPermissions(MailPermission[] permissions)
Adds an array of permissions.

Parameters:
permissions - The array of permissions to add

addPermissions

public void addPermissions(java.util.Collection<? extends MailPermission> permissions)
Adds a collection of permissions.

Parameters:
permissions - The collection of permissions to add

containsPermissions

public boolean containsPermissions()
Checks if permissions were set through addPermission(MailPermission), addPermissions(Collection), or addPermissions(MailPermission[]).

Returns:
true if permissions are set; otherwise false

removePermissions

public void removePermissions()
Removes the permissions.


getPermissions

public MailPermission[] getPermissions()
Returns:
the permissions as array of MailPermission

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

isSupportsUserFlags

public boolean isSupportsUserFlags()
Checks if this folder supports user flags.

Returns:
true if this folder supports user flags; otherwise false

containsSupportsUserFlags

public boolean containsSupportsUserFlags()
Checks if the supports-user-flags flag was set through setSupportsUserFlags(boolean).

Returns:
true if supportsUserFlags is set; otherwise false

removeSupportsUserFlags

public void removeSupportsUserFlags()
Removes the supports-user-flags flag.


setSupportsUserFlags

public void setSupportsUserFlags(boolean supportsUserFlags)
Sets the supports-user-flags flag.

Parameters:
supportsUserFlags - the supports-user-flags flag to set

isShared

public boolean isShared()
Checks if this folder is shared.

Returns:
true if this folder is shared; otherwise false

containsShared

public boolean containsShared()
Checks if the shared flag was set.

Returns:
true if shared flag is set; otherwise false

removeShared

public void removeShared()
Removes the supports-user-flags flag.


setShared

public void setShared(boolean shared)
Sets the shared flag.

Parameters:
shared - The shared flag to set