org.apache.jsieve
Class SieveFactory

java.lang.Object
  extended by org.apache.jsieve.SieveFactory

public class SieveFactory
extends java.lang.Object

SieveFactory is the primary invocation point for all Sieve operations. These are...

parse(InputStream)
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(MailAdapter, Node)
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(MailAdapter, InputStream)
A concatenation of parse and evaluate. Useful for testing, but generally the parse result should be stored for reuse in subsequent evaluations.

Thread Safety

An instance can be safely accessed concurrently by multiple threads provided that the managers used to construct the instance (when SieveFactory(CommandManager, ComparatorManager, TestManager, Log) is called) are thread safe.


Constructor Summary
SieveFactory(CommandManager commandManager, ComparatorManager comparatorManager, TestManager testManager, org.apache.commons.logging.Log log)
          Constructor for SieveFactory.
 
Method Summary
 void evaluate(MailAdapter mail, org.apache.jsieve.parser.generated.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.
 void interpret(MailAdapter mail, java.io.InputStream inputStream)
          Method interpret parses a Sieve script and then evaluates the result against a mail.
 org.apache.jsieve.parser.generated.Node parse(java.io.InputStream inputStream)
          Method parse parses a Sieve script into a hierarchy of parsed nodes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SieveFactory

public SieveFactory(CommandManager commandManager,
                    ComparatorManager comparatorManager,
                    TestManager testManager,
                    org.apache.commons.logging.Log log)
Constructor for SieveFactory.

Method Detail

parse

public org.apache.jsieve.parser.generated.Node parse(java.io.InputStream inputStream)
                                              throws org.apache.jsieve.parser.generated.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:
org.apache.jsieve.parser.generated.ParseException

evaluate

public void evaluate(MailAdapter mail,
                     org.apache.jsieve.parser.generated.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 org.apache.jsieve.parser.generated.ParseException,
                      SieveException
Method interpret parses a Sieve script and then evaluates the result against a mail.

Parameters:
mail -
inputStream -
Throws:
org.apache.jsieve.parser.generated.ParseException
SieveException


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