com.sun.slamd.scripting.mail
Class IMAPConnectionVariable

java.lang.Object
  extended bycom.sun.slamd.scripting.engine.Variable
      extended bycom.sun.slamd.scripting.mail.IMAPConnectionVariable
All Implemented Interfaces:
Argument

public class IMAPConnectionVariable
extends Variable

This class defines a variable that maintains a connection to an IMAPv4rev1 mail server and allows for interaction with that server. An IMAP connection has the the following methods:


Field Summary
static java.lang.String AUTHENTICATE_METHOD_NAME
          The name of the method that performs an IMAP authentication.
static int AUTHENTICATE_METHOD_NUMBER
          The method number for the "authenticate" method.
static java.lang.String CAPABILITY_METHOD_NAME
          The name of the method that retrieves the capability list from the IMAP server.
static int CAPABILITY_METHOD_NUMBER
          The method number for the "capability" method.
static int CONNECT_1_METHOD_NUMBER
          The method number for the first "connect" method.
static int CONNECT_2_METHOD_NUMBER
          The method number for the second "connect" method.
static java.lang.String CONNECT_METHOD_NAME
          The name of the method that establishes a connection to the IMAP server.
static java.lang.String COPY_METHOD_NAME
          The name of the method that can be used to copy a message into another folder.
static int COPY_METHOD_NUMBER
          The method number for the "copy" method.
static java.lang.String COUNT_MESSAGES_METHOD_NAME
          The name of the method that can be used to retrieve the number of messages in the current folder.
static int COUNT_MESSAGES_METHOD_NUMBER
          The method number for the "countMessages" method.
static java.lang.String COUNT_UNREAD_MESSAGES_METHOD_NAME
          The name of the method that can be used to retrieve the number of unread messages in the current folder.
static int COUNT_UNREAD_MESSAGES_METHOD_NUMBER
          The method number for the "countUnreadMessages" method.
static java.lang.String CREATE_FOLDER_METHOD_NAME
          The name of the method that can be used to create a new mailbox folder.
static int CREATE_FOLDER_METHOD_NUMBER
          The method number for the "createFolder" method.
static java.lang.String DELETE_FOLDER_METHOD_NAME
          The name of the method that can be used to delete a mailbox folder.
static int DELETE_FOLDER_METHOD_NUMBER
          The method number for the "deleteFolder" method.
static java.lang.String DELETE_METHOD_NAME
          The name of the method that can be used to delete a message from the IMAP server.
static int DELETE_METHOD_NUMBER
          The method number for the "delete" method.
static java.lang.String DISCONNECT_METHOD_NAME
          The name of the method that can be used to disconnect from the IMAP server.
static int DISCONNECT_METHOD_NUMBER
          The method number for the "disconnect" method.
static java.lang.String EOL
          The end of line character as required by RFC 3501.
static java.lang.String EXPUNGE_METHOD_NAME
          The name of the method that can be used to expunge deleted messages from the mailbox.
static int EXPUNGE_METHOD_NUMBER
          The method number for the "expunge" method.
static java.lang.String GET_FAILURE_REASON_METHOD_NAME
          The name of the method that can be used to determine the reason for the last failure.
static int GET_FAILURE_REASON_METHOD_NUMBER
          The method number for the "getFailureReason" method.
static Method[] IMAP_CONNECTION_VARIABLE_METHODS
          The set of methods associated with IMAP connection variables.
static java.lang.String IMAP_CONNECTION_VARIABLE_TYPE
          The name that will be used for the data type of IMAP connection variables.
static java.lang.String LIST_FOLDERS_METHOD_NAME
          The name of the method that can be used to retrieve a list of the folders in a user's mailbox.
static int LIST_FOLDERS_METHOD_NUMBER
          The method number for the "listFolders" method.
static java.lang.String LIST_MESSAGES_METHOD_NAME
          The name of the method that can be used to retrieve a list of the messages in the current folder of a user's mailbox.
static int LIST_MESSAGES_METHOD_NUMBER
          The method number for the "listMessages" method.
static java.lang.String LIST_NEW_MESSAGES_METHOD_NAME
          The name of the method that can be used to retrieve a list of the new (unread) messages in the current folder of a user's mailbox.
static int LIST_NEW_MESSAGES_METHOD_NUMBER
          The method number for the "listNewMessages" method.
static java.lang.String MOVE_METHOD_NAME
          The name of the method that can be used to move a message from the current folder to another folder in a user's mailbox.
static int MOVE_METHOD_NUMBER
          The method number for the "move" method.
static java.lang.String NOOP_METHOD_NAME
          The name of the method that sends a "NOOP" to the server.
static int NOOP_METHOD_NUMBER
          The method number for the "noop" method.
static java.lang.String RETRIEVE_METHOD_NAME
          The name of the method that can be used to retrieve a specified message from the current folder of a user's mailbox.
static int RETRIEVE_METHOD_NUMBER
          The method number for the "retrieve" method.
static java.lang.String SELECT_FOLDER_METHOD_NAME
          The name of the method that can be used to change the current folder for the user.
static int SELECT_FOLDER_METHOD_NUMBER
          The method number for the "selectFolder" method.
static java.lang.String SEND_COMMAND_METHOD_NAME
          The name of the method that can be used to send a raw IMAP command to the server.
static int SEND_COMMAND_METHOD_NUMBER
          The method number for the "sendCommand" method.
 
Constructor Summary
IMAPConnectionVariable()
          Creates a new variable with no name, to be used only when creating a variable with Class.newInstance(), and only when setName() is called after that to set the name.
 
Method Summary
 void assign(Argument argument)
          Assigns the value of the provided argument to this variable.
 Variable executeMethod(int lineNumber, int methodNumber, Argument[] arguments)
          Executes the specified method, using the provided variables as arguments to the method, and makes the return value available to the caller.
 int getMethodNumber(java.lang.String methodName, java.lang.String[] argumentTypes)
          Retrieves the method number for the method that has the specified name and argument types, or -1 if there is no such method.
 Method[] getMethods()
          Retrieves a list of all methods defined for this variable.
 java.lang.String getReturnTypeForMethod(java.lang.String methodName, java.lang.String[] argumentTypes)
          Retrieves the return type for the method with the specified name and argument types.
 java.lang.String getValueAsString()
          Retrieves a string representation of the value of this argument.
 java.lang.String getVariableTypeName()
          Retrieves the name of the variable type for this variable.
 boolean hasMethod(java.lang.String methodName)
          Indicates whether this variable type has a method with the specified name.
 
Methods inherited from class com.sun.slamd.scripting.engine.Variable
getArgumentAsString, getArgumentType, getArgumentValue, getName, getStatTrackers, isValidIdentifier, setName, startStatTrackers, stopStatTrackers
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IMAP_CONNECTION_VARIABLE_TYPE

public static final java.lang.String IMAP_CONNECTION_VARIABLE_TYPE
The name that will be used for the data type of IMAP connection variables.

See Also:
Constant Field Values

AUTHENTICATE_METHOD_NAME

public static final java.lang.String AUTHENTICATE_METHOD_NAME
The name of the method that performs an IMAP authentication.

See Also:
Constant Field Values

AUTHENTICATE_METHOD_NUMBER

public static final int AUTHENTICATE_METHOD_NUMBER
The method number for the "authenticate" method.

See Also:
Constant Field Values

CAPABILITY_METHOD_NAME

public static final java.lang.String CAPABILITY_METHOD_NAME
The name of the method that retrieves the capability list from the IMAP server.

See Also:
Constant Field Values

CAPABILITY_METHOD_NUMBER

public static final int CAPABILITY_METHOD_NUMBER
The method number for the "capability" method.

See Also:
Constant Field Values

CONNECT_METHOD_NAME

public static final java.lang.String CONNECT_METHOD_NAME
The name of the method that establishes a connection to the IMAP server.

See Also:
Constant Field Values

CONNECT_1_METHOD_NUMBER

public static final int CONNECT_1_METHOD_NUMBER
The method number for the first "connect" method.

See Also:
Constant Field Values

CONNECT_2_METHOD_NUMBER

public static final int CONNECT_2_METHOD_NUMBER
The method number for the second "connect" method.

See Also:
Constant Field Values

COPY_METHOD_NAME

public static final java.lang.String COPY_METHOD_NAME
The name of the method that can be used to copy a message into another folder.

See Also:
Constant Field Values

COPY_METHOD_NUMBER

public static final int COPY_METHOD_NUMBER
The method number for the "copy" method.

See Also:
Constant Field Values

COUNT_MESSAGES_METHOD_NAME

public static final java.lang.String COUNT_MESSAGES_METHOD_NAME
The name of the method that can be used to retrieve the number of messages in the current folder.

See Also:
Constant Field Values

COUNT_MESSAGES_METHOD_NUMBER

public static final int COUNT_MESSAGES_METHOD_NUMBER
The method number for the "countMessages" method.

See Also:
Constant Field Values

COUNT_UNREAD_MESSAGES_METHOD_NAME

public static final java.lang.String COUNT_UNREAD_MESSAGES_METHOD_NAME
The name of the method that can be used to retrieve the number of unread messages in the current folder.

See Also:
Constant Field Values

COUNT_UNREAD_MESSAGES_METHOD_NUMBER

public static final int COUNT_UNREAD_MESSAGES_METHOD_NUMBER
The method number for the "countUnreadMessages" method.

See Also:
Constant Field Values

CREATE_FOLDER_METHOD_NAME

public static final java.lang.String CREATE_FOLDER_METHOD_NAME
The name of the method that can be used to create a new mailbox folder.

See Also:
Constant Field Values

CREATE_FOLDER_METHOD_NUMBER

public static final int CREATE_FOLDER_METHOD_NUMBER
The method number for the "createFolder" method.

See Also:
Constant Field Values

DELETE_METHOD_NAME

public static final java.lang.String DELETE_METHOD_NAME
The name of the method that can be used to delete a message from the IMAP server.

See Also:
Constant Field Values

DELETE_METHOD_NUMBER

public static final int DELETE_METHOD_NUMBER
The method number for the "delete" method.

See Also:
Constant Field Values

DELETE_FOLDER_METHOD_NAME

public static final java.lang.String DELETE_FOLDER_METHOD_NAME
The name of the method that can be used to delete a mailbox folder.

See Also:
Constant Field Values

DELETE_FOLDER_METHOD_NUMBER

public static final int DELETE_FOLDER_METHOD_NUMBER
The method number for the "deleteFolder" method.

See Also:
Constant Field Values

DISCONNECT_METHOD_NAME

public static final java.lang.String DISCONNECT_METHOD_NAME
The name of the method that can be used to disconnect from the IMAP server.

See Also:
Constant Field Values

DISCONNECT_METHOD_NUMBER

public static final int DISCONNECT_METHOD_NUMBER
The method number for the "disconnect" method.

See Also:
Constant Field Values

EXPUNGE_METHOD_NAME

public static final java.lang.String EXPUNGE_METHOD_NAME
The name of the method that can be used to expunge deleted messages from the mailbox.

See Also:
Constant Field Values

EXPUNGE_METHOD_NUMBER

public static final int EXPUNGE_METHOD_NUMBER
The method number for the "expunge" method.

See Also:
Constant Field Values

GET_FAILURE_REASON_METHOD_NAME

public static final java.lang.String GET_FAILURE_REASON_METHOD_NAME
The name of the method that can be used to determine the reason for the last failure.

See Also:
Constant Field Values

GET_FAILURE_REASON_METHOD_NUMBER

public static final int GET_FAILURE_REASON_METHOD_NUMBER
The method number for the "getFailureReason" method.

See Also:
Constant Field Values

LIST_FOLDERS_METHOD_NAME

public static final java.lang.String LIST_FOLDERS_METHOD_NAME
The name of the method that can be used to retrieve a list of the folders in a user's mailbox.

See Also:
Constant Field Values

LIST_FOLDERS_METHOD_NUMBER

public static final int LIST_FOLDERS_METHOD_NUMBER
The method number for the "listFolders" method.

See Also:
Constant Field Values

LIST_MESSAGES_METHOD_NAME

public static final java.lang.String LIST_MESSAGES_METHOD_NAME
The name of the method that can be used to retrieve a list of the messages in the current folder of a user's mailbox.

See Also:
Constant Field Values

LIST_MESSAGES_METHOD_NUMBER

public static final int LIST_MESSAGES_METHOD_NUMBER
The method number for the "listMessages" method.

See Also:
Constant Field Values

LIST_NEW_MESSAGES_METHOD_NAME

public static final java.lang.String LIST_NEW_MESSAGES_METHOD_NAME
The name of the method that can be used to retrieve a list of the new (unread) messages in the current folder of a user's mailbox.

See Also:
Constant Field Values

LIST_NEW_MESSAGES_METHOD_NUMBER

public static final int LIST_NEW_MESSAGES_METHOD_NUMBER
The method number for the "listNewMessages" method.

See Also:
Constant Field Values

MOVE_METHOD_NAME

public static final java.lang.String MOVE_METHOD_NAME
The name of the method that can be used to move a message from the current folder to another folder in a user's mailbox.

See Also:
Constant Field Values

MOVE_METHOD_NUMBER

public static final int MOVE_METHOD_NUMBER
The method number for the "move" method.

See Also:
Constant Field Values

NOOP_METHOD_NAME

public static final java.lang.String NOOP_METHOD_NAME
The name of the method that sends a "NOOP" to the server.

See Also:
Constant Field Values

NOOP_METHOD_NUMBER

public static final int NOOP_METHOD_NUMBER
The method number for the "noop" method.

See Also:
Constant Field Values

RETRIEVE_METHOD_NAME

public static final java.lang.String RETRIEVE_METHOD_NAME
The name of the method that can be used to retrieve a specified message from the current folder of a user's mailbox.

See Also:
Constant Field Values

RETRIEVE_METHOD_NUMBER

public static final int RETRIEVE_METHOD_NUMBER
The method number for the "retrieve" method.

See Also:
Constant Field Values

SELECT_FOLDER_METHOD_NAME

public static final java.lang.String SELECT_FOLDER_METHOD_NAME
The name of the method that can be used to change the current folder for the user.

See Also:
Constant Field Values

SELECT_FOLDER_METHOD_NUMBER

public static final int SELECT_FOLDER_METHOD_NUMBER
The method number for the "selectFolder" method.

See Also:
Constant Field Values

SEND_COMMAND_METHOD_NAME

public static final java.lang.String SEND_COMMAND_METHOD_NAME
The name of the method that can be used to send a raw IMAP command to the server.

See Also:
Constant Field Values

SEND_COMMAND_METHOD_NUMBER

public static final int SEND_COMMAND_METHOD_NUMBER
The method number for the "sendCommand" method.

See Also:
Constant Field Values

IMAP_CONNECTION_VARIABLE_METHODS

public static final Method[] IMAP_CONNECTION_VARIABLE_METHODS
The set of methods associated with IMAP connection variables.


EOL

public static final java.lang.String EOL
The end of line character as required by RFC 3501.

See Also:
Constant Field Values
Constructor Detail

IMAPConnectionVariable

public IMAPConnectionVariable()
                       throws ScriptException
Creates a new variable with no name, to be used only when creating a variable with Class.newInstance(), and only when setName() is called after that to set the name.

Throws:
ScriptException - If a problem occurs while initializing the new variable.
Method Detail

getVariableTypeName

public java.lang.String getVariableTypeName()
Retrieves the name of the variable type for this variable.

Specified by:
getVariableTypeName in class Variable
Returns:
The name of the variable type for this variable.

getMethods

public Method[] getMethods()
Retrieves a list of all methods defined for this variable.

Specified by:
getMethods in class Variable
Returns:
A list of all methods defined for this variable.

hasMethod

public boolean hasMethod(java.lang.String methodName)
Indicates whether this variable type has a method with the specified name.

Specified by:
hasMethod in class Variable
Parameters:
methodName - The name of the method.
Returns:
true if this variable has a method with the specified name, or false if it does not.

getMethodNumber

public int getMethodNumber(java.lang.String methodName,
                           java.lang.String[] argumentTypes)
Retrieves the method number for the method that has the specified name and argument types, or -1 if there is no such method.

Specified by:
getMethodNumber in class Variable
Parameters:
methodName - The name of the method.
argumentTypes - The list of argument types for the method.
Returns:
The method number for the method that has the specified name and argument types.

getReturnTypeForMethod

public java.lang.String getReturnTypeForMethod(java.lang.String methodName,
                                               java.lang.String[] argumentTypes)
Retrieves the return type for the method with the specified name and argument types.

Specified by:
getReturnTypeForMethod in class Variable
Parameters:
methodName - The name of the method.
argumentTypes - The set of argument types for the method.
Returns:
The return type for the method, or null if there is no such method defined.

executeMethod

public Variable executeMethod(int lineNumber,
                              int methodNumber,
                              Argument[] arguments)
                       throws ScriptException
Executes the specified method, using the provided variables as arguments to the method, and makes the return value available to the caller.

Specified by:
executeMethod in class Variable
Parameters:
lineNumber - The line number of the script in which the method call occurs.
methodNumber - The method number of the method to execute.
arguments - The set of arguments to use for the method.
Returns:
The value returned from the method, or null if it does not return a value.
Throws:
ScriptException - If the specified method does not exist, or if a problem occurs while attempting to execute it.

assign

public void assign(Argument argument)
            throws ScriptException
Assigns the value of the provided argument to this variable. The value of the provided argument must be of the same type as this variable.

Specified by:
assign in class Variable
Parameters:
argument - The argument whose value should be assigned to this variable.
Throws:
ScriptException - If a problem occurs while performing the assignment.

getValueAsString

public java.lang.String getValueAsString()
Retrieves a string representation of the value of this argument.

Returns:
A string representation of the value of this argument.