org.apache.jsieve.util.check
Class ScriptCheckMailAdapter

java.lang.Object
  extended by org.apache.jsieve.util.check.ScriptCheckMailAdapter
All Implemented Interfaces:
MailAdapter

public class ScriptCheckMailAdapter
extends java.lang.Object
implements MailAdapter

Checks script execution for an email. The wrapped email is set by called setMail(javax.mail.Message). Actions are recorded on executedActions and can be retrieved by getExecutedActions().


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.jsieve.mail.MailAdapter
MailAdapter.Address
 
Constructor Summary
ScriptCheckMailAdapter()
           
 
Method Summary
 void addAction(Action action)
          Method addAction adds an Action to the List of Actions to be performed by the receiver.
 void executeActions()
          Method executeActions.
 java.util.List<Action> getActions()
          Method getActions answers the List of Actions accumulated by the receiver.
 java.lang.String getContentType()
          Method getContentType returns string/mime representation of the message type.
 java.util.List<Action> getExecutedActions()
          Gets the actions accumulated when executedActions was last called.
 java.util.List<java.lang.String> getHeader(java.lang.String name)
          Method getHeader answers a List of all of the headers in the receiver whose name is equal to the passed name.
 java.util.List<java.lang.String> getHeaderNames()
          Method getHeaderNames answers a List of all of the headers in the receiver.
 javax.mail.Message getMail()
          Gets the wrapped email.
 java.util.List<java.lang.String> getMatchingHeader(java.lang.String name)
           Method getMatchingHeader answers a List of all of the headers in the receiver with the passed name.
 int getSize()
          Method getSize answers the receiver's message size in octets.
 boolean isInBodyText(java.lang.String phraseCaseInsensitive)
           
 MailAdapter.Address[] parseAddresses(java.lang.String headerName)
           
 MailAdapter.Address[] parseAddresses(java.lang.String headerName, javax.mail.Message message)
          Parses the value from the given message into addresses.
 void reset()
          Resets executed and accumlated actions.
 void setContext(SieveContext context)
           
 void setMail(javax.mail.Message mail)
          Sets the wrapped email and reset()s the adapter ready for another execution.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScriptCheckMailAdapter

public ScriptCheckMailAdapter()
Method Detail

getMail

public javax.mail.Message getMail()
Gets the wrapped email.

Returns:
Message, possibly null

setMail

public void setMail(javax.mail.Message mail)
Sets the wrapped email and reset()s the adapter ready for another execution.

Parameters:
mail - Message, possibly null

addAction

public void addAction(Action action)
Method addAction adds an Action to the List of Actions to be performed by the receiver.

Specified by:
addAction in interface MailAdapter
Parameters:
action -

executeActions

public void executeActions()
                    throws SieveException
Method executeActions. Applies the Actions accumulated by the receiver.

Specified by:
executeActions in interface MailAdapter
Throws:
SieveException

getExecutedActions

public java.util.List<Action> getExecutedActions()
Gets the actions accumulated when executedActions was last called.

Returns:
List of Actions, not null. This list is a modifiable copy

getActions

public java.util.List<Action> getActions()
Method getActions answers the List of Actions accumulated by the receiver. Implementations may elect to supply an unmodifiable collection.

Specified by:
getActions in interface MailAdapter
Returns:
List of Action's, not null, possibly unmodifiable

reset

public void reset()
Resets executed and accumlated actions. An instance may be safely reused to check a script once this method has been called.


getHeader

public java.util.List<java.lang.String> getHeader(java.lang.String name)
                                           throws SieveMailException
Method getHeader answers a List of all of the headers in the receiver whose name is equal to the passed name. If no headers are found an empty List is returned.

Specified by:
getHeader in interface MailAdapter
Parameters:
name -
Returns:
List not null, possibly empty
Throws:
SieveMailException

getHeaderNames

public java.util.List<java.lang.String> getHeaderNames()
                                                throws SieveMailException
Method getHeaderNames answers a List of all of the headers in the receiver. No duplicates are allowed.

Specified by:
getHeaderNames in interface MailAdapter
Returns:
List, not null possible empty, possible unmodifiable
Throws:
SieveMailException

getMatchingHeader

public java.util.List<java.lang.String> getMatchingHeader(java.lang.String name)
                                                   throws SieveMailException

Method getMatchingHeader answers a List of all of the headers in the receiver with the passed name. If no headers are found an empty List is returned.

This method differs from getHeader(String) in that it ignores case and the whitespace prefixes and suffixes of a header name when performing the match, as required by RFC 3028. Thus "From", "from ", " From" and " from " are considered equal.

Specified by:
getMatchingHeader in interface MailAdapter
Parameters:
name -
Returns:
List, not null possibly empty
Throws:
SieveMailException

getSize

public int getSize()
            throws SieveMailException
Method getSize answers the receiver's message size in octets.

Specified by:
getSize in interface MailAdapter
Returns:
int
Throws:
SieveMailException

getContentType

public java.lang.String getContentType()
                                throws SieveMailException
Method getContentType returns string/mime representation of the message type.

Specified by:
getContentType in interface MailAdapter
Returns:
String
Throws:
SieveMailException

parseAddresses

public MailAdapter.Address[] parseAddresses(java.lang.String headerName)
                                     throws SieveMailException
Specified by:
parseAddresses in interface MailAdapter
Throws:
SieveMailException

parseAddresses

public MailAdapter.Address[] parseAddresses(java.lang.String headerName,
                                            javax.mail.Message message)
                                     throws SieveMailException
Parses the value from the given message into addresses.

Parameters:
headerName - header name, to be matched case insensitively
message - Message, not null
Returns:
Address array, not null possibly empty
Throws:
SieveMailException

isInBodyText

public boolean isInBodyText(java.lang.String phraseCaseInsensitive)
                     throws SieveMailException
Specified by:
isInBodyText in interface MailAdapter
Throws:
SieveMailException

setContext

public void setContext(SieveContext context)
Specified by:
setContext in interface MailAdapter


Copyright © 2004-2009 The Apache Software Foundation. All Rights Reserved.