com.openexchange.mail
Class MailPath

java.lang.Object
  extended by com.openexchange.mail.MailPath
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

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

MailPath - Represents a message's unique path inside a mailbox, that is the account ID followed by the folder fullname followed by the value of SEPERATOR followed by mail's unique ID:
Example: default1/INBOX.Subfolder/1234

Author:
Thorben Betten
See Also:
Serialized Form

Field Summary
static java.util.Comparator<MailPath> COMPARATOR
          Gets an appropriate instance of Comparator to sort instances of MailPath
static MailPath NULL
          A null MailPath
static char SEPERATOR
          The '/' character which separates folder's fullname from mail's ID in a mail path
 
Constructor Summary
MailPath()
          Default constructor
MailPath(int accountId, java.lang.String folder, java.lang.String uid)
          Initializes a new MailPath
MailPath(java.lang.String mailPathStr)
          Initializes a new MailPath
 
Method Summary
 java.lang.Object clone()
           
 boolean equals(java.lang.Object obj)
           
 int getAccountId()
          Gets the account ID.
 java.lang.String getFolder()
          Gets the folder fullname
 java.lang.String getFolderArgument()
          Gets the folder argument; default3/INBOX.
 java.lang.String getMailID()
          Gets the mail ID.
static java.lang.String getMailPath(int accountId, java.lang.String folder, java.lang.String mailId)
          Gets the mail path corresponding to given folder fullname and message UID
static MailPath[] getMailPaths(java.lang.String mailPaths)
          Returns the mail paths for given comma-separated mail IDs each conform to pattern <folder-path><value-of-SEPERATOR ><mail-ID>
static MailPath[] getMailPaths(java.lang.String[] mailPaths)
          Returns the mail paths for given mail IDs each conform to pattern <folder-path><value-of-SEPERATOR ><mail-ID>
 java.lang.String getStr()
          Gets this mail path's string representation.
static java.lang.String[] getUIDs(MailPath[] mailPaths)
          Extracts the IDs from given mail paths
 int hashCode()
           
 MailPath setMailIdentifierString(java.lang.String mailPathStr)
          Sets this mail path's folder fullname and mail's unique ID (for re-usage).
 java.lang.String toString()
          Gets this mail path's string representation following pattern:
"default" + <account-id> + <default-separator> + <folder-fullname> + "/" + <mail-id> default2/INBOX/Subfolder/453"
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

COMPARATOR

public static final java.util.Comparator<MailPath> COMPARATOR
Gets an appropriate instance of Comparator to sort instances of MailPath


NULL

public static final MailPath NULL
A null MailPath


SEPERATOR

public static final char SEPERATOR
The '/' character which separates folder's fullname from mail's ID in a mail path

See Also:
Constant Field Values
Constructor Detail

MailPath

public MailPath()
Default constructor


MailPath

public MailPath(java.lang.String mailPathStr)
         throws MailException
Initializes a new MailPath

Parameters:
mailPathStr - The mail path's string representation
Throws:
MailException - If mail path's string representation does not match expected pattern

MailPath

public MailPath(int accountId,
                java.lang.String folder,
                java.lang.String uid)
Initializes a new MailPath

Parameters:
accountId - The account ID
folder - Folder fullname
uid - The mail's unique ID
Method Detail

getMailPath

public static java.lang.String getMailPath(int accountId,
                                           java.lang.String folder,
                                           java.lang.String mailId)
Gets the mail path corresponding to given folder fullname and message UID

Parameters:
accountId - The account ID
folder - The folder fullname
mailId - The mail ID
Returns:
The mail path as String

getMailPaths

public static MailPath[] getMailPaths(java.lang.String mailPaths)
                               throws MailException
Returns the mail paths for given comma-separated mail IDs each conform to pattern <folder-path><value-of-SEPERATOR ><mail-ID>

Parameters:
mailPaths - The comma-separated mail IDs
Returns:
The corresponding mail paths
Throws:
MailException - If mail paths cannot be generated

getMailPaths

public static MailPath[] getMailPaths(java.lang.String[] mailPaths)
                               throws MailException
Returns the mail paths for given mail IDs each conform to pattern <folder-path><value-of-SEPERATOR ><mail-ID>

Parameters:
mailPaths - The mail IDs
Returns:
The corresponding mail paths
Throws:
MailException - If mail paths cannot be generated

getUIDs

public static java.lang.String[] getUIDs(MailPath[] mailPaths)
Extracts the IDs from given mail paths

Parameters:
mailPaths - The mail IDs
Returns:
The extracted IDs

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

clone

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

getAccountId

public int getAccountId()
Gets the account ID.

Returns:
The account ID

getFolder

public java.lang.String getFolder()
Gets the folder fullname

Returns:
The folder fullname

getFolderArgument

public java.lang.String getFolderArgument()
Gets the folder argument; default3/INBOX.

Returns:
The folder argument

getStr

public java.lang.String getStr()
Gets this mail path's string representation.

Returns:
This mail path's string representation
See Also:
toString()

getMailID

public java.lang.String getMailID()
Gets the mail ID.

Returns:
The mail ID

setMailIdentifierString

public MailPath setMailIdentifierString(java.lang.String mailPathStr)
                                 throws MailException
Sets this mail path's folder fullname and mail's unique ID (for re-usage).

Parameters:
mailPathStr - The mail paths string representation
Returns:
The mail path itself
Throws:
MailException - If mail path's string representation does not match expected pattern

toString

public java.lang.String toString()
Gets this mail path's string representation following pattern:
"default" + <account-id> + <default-separator> + <folder-fullname> + "/" + <mail-id>
 default2/INBOX/Subfolder/453"
 

Overrides:
toString in class java.lang.Object