Rakesh API

org.rakeshv.mail
Class MailPreferences

java.lang.Object
  extended by org.rakeshv.mail.MailPreferences

public class MailPreferences
extends java.lang.Object

This class stores the mail account preferences for the user(s) currently logged on to the application. This class populates the class fields from the information stored in the underlying preferences XML file that conforms to the mail preferences XML schema using JDOM.

You can use the createMailPreferences( String ) method to create a default mail preferences file.

Modifiying the class fields do not modify the contents of the preferences file. Use saveMailPreferences() to write the modified XML data back to the preferences file.

Copyright 2003, Rakesh Vidyadharan

Version:
$Id: MailPreferences.java,v 1.9 2005/09/17 11:13:49 rakesh Exp $
Author:
Rakesh Vidyadharan

Field Summary
static boolean COPY_SENT_MESSAGES
          A flag that is used to indicate that messages being sent should be copied to the WebMailBean.sentFolderName.
private  boolean copySentMessages
          This field is used to indicate whether message being sent by the user are to be copied to the WebMailBean.sentFolderName folder or not.
private  int daysToKeepDeletedMessages
          This field is used to indicate the number of days until which deleted messages in the WebMailBean.trashFolderName folder should be kept.
static int DELETE_PERMANENTLY
          A constant that is used to indicate that message being deleted should be deleted permanently from the store.
private  int deleteAction
          This field is used to indicate the type of action the user desires when deleting a mail message.
static int DISPLAY_ALL_MESSAGES
          A constant that is used to indicate that all available messages for the chosen folder should be displayed on the page.
static boolean DO_NOT_COPY_SENT_MESSAGES
          A flag that is used to indicate that messages being sent should not be copied to the WebMailBean.sentFolderName.
private  org.jdom.Document document
          The JDOM XML document representation.
private  java.lang.String fileName
          The fully qualified name of the file that contains the mail preferences.
static int MARK_AS_DELETED
          A constant that is used to indicate that the message being deleted should be marked as deleted (while left in the current folder).
private  int messagesPerPage
          This field is used to store the user preference for the number of messages to be displayed on a page.
static int MOVE_TO_TRASH
          A constant that is used to indicate that messages being deleted should be moved to the WebMailBean.trashFolderName folder.
private  org.jdom.Namespace namespace
          The target namespace for the mail preferences XML data.
 
Constructor Summary
protected MailPreferences()
          Default constructor.
  MailPreferences(java.lang.String fileName)
          Just invoke MailPreferences( String, String ) with a value of null for the preferred SAX Parser to use.
  MailPreferences(java.lang.String fileName, java.lang.String saxParser)
          Load the specified address book XML file using the specified SAX Parser.
 
Method Summary
static MailPreferences createMailPreferences(java.lang.String file)
          Just invokes createMailPreferences( String, String ) with a null value for the default SAX Parser.
static MailPreferences createMailPreferences(java.lang.String file, java.lang.String saxParser)
          Create a new mail preferences file using the fully qualified file name specified, and using the specified SAX Parser to load the XML file that has been created.
 boolean getCopySentMessages()
          Return the value/reference of the copySentMessages.
 int getDaysToKeepDeletedMessages()
          Return the value/reference of the daysToKeepDeletedMessages.
 int getDeleteAction()
          Return the value/reference of the deleteAction.
 int getMessagesPerPage()
          Return the value/reference of the messagesPerPage.
private  void loadMailPreferences(java.lang.String saxParser)
          Load the address book XML file (fileName) using JDOM, and populate the instance variables.
 void saveMailPreferences()
          Write the JDOM tree back to the address book file.
 void setCopySentMessages(boolean copySentMessages)
          Set the value of copySentMessages.
 void setDaysToKeepDeletedMessages(int daysToKeepDeletedMessages)
          Set the value of daysToKeepDeletedMessages.
 void setDeleteAction(int deleteAction)
          Set the value of deleteAction.
 void setFileName(java.lang.String fileName)
          Set the value of fileName.
 void setMessagesPerPage(int messagesPerPage)
          Set the value of messagesPerPage.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MOVE_TO_TRASH

public static final int MOVE_TO_TRASH
A constant that is used to indicate that messages being deleted should be moved to the WebMailBean.trashFolderName folder. This constant is currently defined as 0.

See Also:
Constant Field Values

DELETE_PERMANENTLY

public static final int DELETE_PERMANENTLY
A constant that is used to indicate that message being deleted should be deleted permanently from the store. This constant is currently defined as 1.

See Also:
Constant Field Values

MARK_AS_DELETED

public static final int MARK_AS_DELETED
A constant that is used to indicate that the message being deleted should be marked as deleted (while left in the current folder). This constant is currently defined as 2.

See Also:
Constant Field Values

COPY_SENT_MESSAGES

public static final boolean COPY_SENT_MESSAGES
A flag that is used to indicate that messages being sent should be copied to the WebMailBean.sentFolderName. At present a value of true indicates that messages should be copied to the folder.

See Also:
Constant Field Values

DO_NOT_COPY_SENT_MESSAGES

public static final boolean DO_NOT_COPY_SENT_MESSAGES
A flag that is used to indicate that messages being sent should not be copied to the WebMailBean.sentFolderName. At present a value of true indicates that messages should not be copied to the folder.

See Also:
Constant Field Values

DISPLAY_ALL_MESSAGES

public static final int DISPLAY_ALL_MESSAGES
A constant that is used to indicate that all available messages for the chosen folder should be displayed on the page.

See Also:
Constant Field Values

fileName

private java.lang.String fileName
The fully qualified name of the file that contains the mail preferences.


deleteAction

private int deleteAction
This field is used to indicate the type of action the user desires when deleting a mail message. Valid values for this variable are defined by the fields MOVE_TO_TRASH, DELETE_PERMANENTLY, and MARK_AS_DELETED. Setting this field to other values will cause undefined behaviour. This field maps to the deleteAction element in the schema.


copySentMessages

private boolean copySentMessages
This field is used to indicate whether message being sent by the user are to be copied to the WebMailBean.sentFolderName folder or not. This field maps to the copySentMessages element in the schema.


daysToKeepDeletedMessages

private int daysToKeepDeletedMessages
This field is used to indicate the number of days until which deleted messages in the WebMailBean.trashFolderName folder should be kept. Message older than the configured number of days will be automatically deleted when the user logs out of the web-mail application. This value will by default be 30 days.


messagesPerPage

private int messagesPerPage
This field is used to store the user preference for the number of messages to be displayed on a page. This field maps to the messagesPerPage element. This field is set by default to DISPLAY_ALL_MESSAGES. This field maps to the messagesPerPage element in the schema.


document

private org.jdom.Document document
The JDOM XML document representation.


namespace

private org.jdom.Namespace namespace
The target namespace for the mail preferences XML data.

Constructor Detail

MailPreferences

protected MailPreferences()
Default constructor. Cannot be directly invoked.


MailPreferences

public MailPreferences(java.lang.String fileName)
                throws MailException
Just invoke MailPreferences( String, String ) with a value of null for the preferred SAX Parser to use.

Parameters:
fileName - - The fully qualified name of the address book XML file.
Throws:
MailException - - If any JDOM/IOExceptions are encountered while processing the address book XML file.

MailPreferences

public MailPreferences(java.lang.String fileName,
                       java.lang.String saxParser)
                throws MailException
Load the specified address book XML file using the specified SAX Parser.

Parameters:
fileName - - The fully qualified name of the address book XML file.
saxParser - - The full class name of the preferred SAX Parser to use.
Throws:
MailException - - If any JDOM/IOExceptions are encountered while processing the address book XML file.
See Also:
loadMailPreferences( String )
Method Detail

loadMailPreferences

private void loadMailPreferences(java.lang.String saxParser)
                          throws MailException
Load the address book XML file (fileName) using JDOM, and populate the instance variables.

Parameters:
saxParser - - The full class name of the SAX Parser to use. If this is null the default JAXP SAX Parser will be used.
Throws:
MailException - - If any JDOM/IOExceptions are encountered while processing the address book XML file.

createMailPreferences

public static MailPreferences createMailPreferences(java.lang.String file)
                                             throws MailException
Just invokes createMailPreferences( String, String ) with a null value for the default SAX Parser.

Parameters:
file - - The fully qualified name of the file ie. the full path and name of file to use as the address book.
Throws:
MailException - - If any exceptions are encountered while creating or writing to the specified file.

saveMailPreferences

public void saveMailPreferences()
                         throws MailException
Write the JDOM tree back to the address book file.

Throws:
MailException - - If any exceptions are encountered while serialising the JDOM tree to the mail preferences file.

createMailPreferences

public static MailPreferences createMailPreferences(java.lang.String file,
                                                    java.lang.String saxParser)
                                             throws MailException
Create a new mail preferences file using the fully qualified file name specified, and using the specified SAX Parser to load the XML file that has been created.

Parameters:
file - - The fully qualified name of the file ie. the full path and name of file to use as the address book.
saxParser - - The full class name of the preferred SAX Parser. If this is null the default JAXP SAX Parser will be used.
Throws:
MailException - - If any exceptions are encountered while creating or writing to the specified file.

setFileName

public final void setFileName(java.lang.String fileName)
Set the value of fileName.

Parameters:
fileName - - The value to set.

getDeleteAction

public final int getDeleteAction()
Return the value/reference of the deleteAction.

Returns:
int - The value/reference of deleteAction.

setDeleteAction

public final void setDeleteAction(int deleteAction)
Set the value of deleteAction. Also updates the underlying JDOM tree with the new value. Use saveMailPreferences() to actually write the modified XML data back to the mail preferences file.

Parameters:
deleteAction - - The value to set.

getCopySentMessages

public final boolean getCopySentMessages()
Return the value/reference of the copySentMessages.

Returns:
boolean - The value/reference of copySentMessages.

setCopySentMessages

public final void setCopySentMessages(boolean copySentMessages)
Set the value of copySentMessages. Also updates the underlying JDOM tree with the new value. Use saveMailPreferences(), to actually write the modified XML back to the mail preferences file.

Parameters:
copySentMessages - - The value to set.

getMessagesPerPage

public final int getMessagesPerPage()
Return the value/reference of the messagesPerPage.

Returns:
int - The value/reference of messagesPerPage.

setMessagesPerPage

public final void setMessagesPerPage(int messagesPerPage)
Set the value of messagesPerPage. Use DISPLAY_ALL_MESSAGES if you wish to display all the messages on one page. This method also updates the underlying JDOM tree with the new value. Use saveMailPreferences() to actually write the modified XML back to the mail preferences file.

Parameters:
messagesPerPage - - The value to set.

getDaysToKeepDeletedMessages

public final int getDaysToKeepDeletedMessages()
Return the value/reference of the daysToKeepDeletedMessages.

Returns:
int - The value/reference of daysToKeepDeletedMessages.

setDaysToKeepDeletedMessages

public final void setDaysToKeepDeletedMessages(int daysToKeepDeletedMessages)
Set the value of daysToKeepDeletedMessages. This method also updates the underlying JDOM tree with the new value. Use saveMailPreferences() to actually write the modified XML back to the mail preferences file.

Parameters:
daysToKeepDeletedMessages - - The value to set.

Rakesh API

Copyright © 2002-2005 - Rakesh Vidyadharan