org.apache.jsieve
Class SieveFactory

java.lang.Object
  extended byorg.apache.jsieve.SieveFactory

public class SieveFactory
extends java.lang.Object

Singleton class SieveFactory is the primary invocation point for all Sieve operations. Theses are...

parse
Parse a Sieve script into a hierarchy of parsed nodes. A succesful parse means the script is lexically and gramatically valid according to RFC 3028, section 8. The result is the start node of the parsed Sieve script. The start node is resuable. Typically it is stored for reuse in all subsequent evaluations of the script.
evaluate
Evaluate an RFC 822 compliant mail message wrapped in a MailAdapter against the parse result referenced by the start node from the Parse operation above. As evaluation proceeds a List of Actions is added to the MailAdapter. At the end of evaluation, each Action in the List is executed in the order they were added.
interpret/dt>
A concatenation of parse and evaluate. Useful for testing, but generally the parse result should be stored for reuse in subsequent evaluations.


Constructor Summary
SieveFactory()
          Constructor for SieveFactory.
 
Method Summary
static SieveFactory computeInstance()
          Computes an instance of the receiver.
 void evaluate(MailAdapter mail, Node startNode)
           Method evaluate evaluates an RFC 822 compliant mail message wrapped in a MailAdapter by visting each node of the parsed script beginning at the passed start node.
static SieveFactory getInstance()
          Returns the instance of the receiver, lazily initialised if required.
 void interpret(MailAdapter mail, java.io.InputStream inputStream)
          Method interpret parses a Sieve script and then evaluates the result against a mail.
 Node parse(java.io.InputStream inputStream)
          Method parse parses a Sieve script into a hierarchy of parsed nodes.
protected static void setInstance(SieveFactory instance)
          Sets the instance of the receiver.
protected static void updateInstance()
          Updates the instance of the receiver.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SieveFactory

public SieveFactory()
Constructor for SieveFactory.

Method Detail

parse

public Node parse(java.io.InputStream inputStream)
           throws ParseException
Method parse parses a Sieve script into a hierarchy of parsed nodes. A successful parse means the script is lexically and grammatically valid according to RFC 3028, section 8. The result is the start node of the parsed Sieve script. The start node is reusable. Typically it is stored for reuse in subsequent evaluations of the script.

Parameters:
inputStream -
Returns:
Node
Throws:
ParseException

evaluate

public void evaluate(MailAdapter mail,
                     Node startNode)
              throws SieveException

Method evaluate evaluates an RFC 822 compliant mail message wrapped in a MailAdapter by visting each node of the parsed script beginning at the passed start node. As evaluation proceeds a List of Actions is added to the MailAdapter.

At the start of evaluation an 'implicitKeep' state is set. This can be cancelled by a Command during evaluation. If 'implicitKeep' is still set at the end of evaluation, a Keep Action is added to the List of Actions. Finally, each Action in the List is executed in the order they were added.

Parameters:
mail -
startNode -
Throws:
SieveException

interpret

public void interpret(MailAdapter mail,
                      java.io.InputStream inputStream)
               throws ParseException,
                      SieveException
Method interpret parses a Sieve script and then evaluates the result against a mail.

Parameters:
mail -
inputStream -
Throws:
ParseException
SieveException

getInstance

public static SieveFactory getInstance()
Returns the instance of the receiver, lazily initialised if required.

Returns:
SieveFactory

computeInstance

public static SieveFactory computeInstance()
Computes an instance of the receiver.

Returns:
SieveFactory

setInstance

protected static void setInstance(SieveFactory instance)
Sets the instance of the receiver.

Parameters:
instance - The instance to set

updateInstance

protected static void updateInstance()
Updates the instance of the receiver.



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