You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by rd...@apache.org on 2007/03/31 14:04:50 UTC

svn commit: r524412 - in /james/jsieve/trunk/src: main/java/org/apache/jsieve/ main/java/org/apache/jsieve/commands/ main/java/org/apache/jsieve/commands/extensions/ main/java/org/apache/jsieve/commands/optional/ main/java/org/apache/jsieve/parser/ mai...

Author: rdonkin
Date: Sat Mar 31 05:04:48 2007
New Revision: 524412

URL: http://svn.apache.org/viewvc?view=rev&rev=524412
Log:
Added contextual information about position within the script being execute to exceptions. Note that this changes key interfaces in a way that is not backwards compatible.

Added:
    james/jsieve/trunk/src/main/java/org/apache/jsieve/BaseSieveContext.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/ScriptCoordinate.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/SieveContext.java
Modified:
    james/jsieve/trunk/src/main/java/org/apache/jsieve/Block.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/Command.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/Commands.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/SieveParserVisitorImpl.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/Test.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/TestList.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/AbstractActionCommand.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/AbstractCommand.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/AbstractConditionalCommand.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/AbstractPrologCommand.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/ConditionManager.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/Discard.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/Else.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/Elsif.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/ExecutableCommand.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/If.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/Keep.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/Redirect.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/Require.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/Stop.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/extensions/Log.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/optional/FileInto.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/optional/Reject.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/parser/SieveNode.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/samples/james/Actions.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/AbstractTest.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/Address.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/AllOf.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/AnyOf.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/ExecutableTest.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/Exists.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/False.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/Header.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/Not.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/Size.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/True.java
    james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/commands/ThrowTestException.java

Added: james/jsieve/trunk/src/main/java/org/apache/jsieve/BaseSieveContext.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/BaseSieveContext.java?view=auto&rev=524412
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/BaseSieveContext.java (added)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/BaseSieveContext.java Sat Mar 31 05:04:48 2007
@@ -0,0 +1,46 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.jsieve;
+
+/**
+ * Bean based implementation of context. 
+ *
+ */
+public class BaseSieveContext extends SieveContext {
+
+    private ScriptCoordinate coordinate;
+    
+    /**
+     * Gets the script position of the current operation.
+     * @return <code>ScriptCoordinate</code>, not null
+     */
+    public ScriptCoordinate getCoordinate() {
+        return coordinate;
+    }
+    
+    /**
+     * Sets the script position of the current operation.
+     * @param coordinate <code>ScriptCoordinate</code>, not null
+     */
+    public void setCoordinate(ScriptCoordinate coordinate) {
+        this.coordinate = coordinate;
+    }
+
+}

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/Block.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/Block.java?view=diff&rev=524412&r1=524411&r2=524412
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/Block.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/Block.java Sat Mar 31 05:04:48 2007
@@ -79,4 +79,9 @@
         return getChildren().execute(mail); 
     }
 
+    public String toString() {
+        return "BLOCK: " + getChildren();
+    }
+
+    
 }

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/Command.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/Command.java?view=diff&rev=524412&r1=524411&r2=524412
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/Command.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/Command.java Sat Mar 31 05:04:48 2007
@@ -41,7 +41,7 @@
         return CommandManager.getInstance().newInstance(getName()).execute(
             mail,
             getArguments(),
-            getBlock());
+            getBlock(), context);
     }
 
 
@@ -52,7 +52,9 @@
     private Arguments fieldArguments;
  
     // The Block for this Command   
-    private Block fieldBlock;    
+    private Block fieldBlock;  
+    
+    private SieveContext context;
     
     /**
      * Constructor for Test.
@@ -68,9 +70,10 @@
      * @param arguments
      * @param block
      */
-    public Command(String name, Arguments arguments, Block block)
+    public Command(String name, Arguments arguments, Block block, SieveContext context)
     {
         this();
+        this.context = context;
         setName(name);
         setArguments(arguments);
         setBlock(block);        

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/Commands.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/Commands.java?view=diff&rev=524412&r1=524411&r2=524412
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/Commands.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/Commands.java Sat Mar 31 05:04:48 2007
@@ -26,7 +26,6 @@
 import org.apache.jsieve.mail.*;
 
 /**
-/**
  * <p>A parsed representation of the RFC3028 BNF...</p>
  * 
  * <code>commands = *command</code>
@@ -85,5 +84,11 @@
             ((Executable)commandsIter.next()).execute(mail);
         return null; 
     }
+
+    public String toString() {
+        return "COMMANDS: " + fieldChildren;
+    }
+    
+    
 
 }

Added: james/jsieve/trunk/src/main/java/org/apache/jsieve/ScriptCoordinate.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/ScriptCoordinate.java?view=auto&rev=524412
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/ScriptCoordinate.java (added)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/ScriptCoordinate.java Sat Mar 31 05:04:48 2007
@@ -0,0 +1,130 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.jsieve;
+
+import org.apache.commons.logging.Log;
+
+/**
+ * Specifies the positional extent of an element 
+ * within the script being executed. 
+ * In other words, this gives the line and column at which
+ * the elment starts and at which it ends.
+ */
+public final class ScriptCoordinate {
+
+    private final int startLineNumber;
+    private final int startColumnNumber;
+    private final int endLineNumber;
+    private final int endColumnNumber;
+    
+    public ScriptCoordinate(final int startLineNumber, final int startColumnNumber, 
+            final int endLineNumber, final int endColumnNumber) {
+        super();
+        this.startLineNumber = startLineNumber;
+        this.startColumnNumber = startColumnNumber;
+        this.endLineNumber = endLineNumber;
+        this.endColumnNumber = endColumnNumber;
+    }
+    
+    /**
+     * Gets the number of the column where the elements ends.
+     * @return column number
+     */
+    public int getEndColumnNumber() {
+        return endColumnNumber;
+    }
+    
+    /**
+     * Gets the number of the line where the element ends.
+     * @return line number
+     */
+    public int getEndLineNumber() {
+        return endLineNumber;
+    }
+    
+    /**
+     * Gets the number of the column where the element start.
+     * @return column number
+     */
+    public int getStartColumnNumber() {
+        return startColumnNumber;
+    }
+    
+    /**
+     * Gets the number of the line where the element starts.
+     * @return line number
+     */
+    public int getStartLineNumber() {
+        return startLineNumber;
+    }
+    
+    /**
+     * Creates a syntax exception based on the given message
+     * containing details of the script position.
+     * The message should end with a full stop.
+     * @param message <code>CharSequence</code> containing the base message,
+     * not null
+     * @return <code>SyntaxException</code> with details of the script position
+     * appended to the message, not null
+     */
+    public SyntaxException syntaxException(CharSequence message) {
+        final Log logger = Logger.getLog();
+        if (logger.isWarnEnabled()) {
+            logger.warn(message);
+        }
+        logDiagnosticsInfo(logger);
+        final String fullMessage = addStartLineAndColumn(message);
+        final SyntaxException result = new SyntaxException(fullMessage);
+        return result;
+    }
+    
+    /**
+     * Appends a standard position phrase to the given message.
+     * This message should end with a full stop.
+     * @param message <code>CharSequence</code> message, not null
+     * @return <code>String</code> containing the original message
+     * with positional phrase appended, not null
+     */
+    public String addStartLineAndColumn(CharSequence message) {
+        final StringBuffer buffer;
+        if (message instanceof StringBuffer) {
+            buffer = (StringBuffer) message;
+        } else {
+            buffer = new StringBuffer(message);
+        }
+        buffer.append(" Line ");
+        buffer.append(startLineNumber);
+        buffer.append(" column ");
+        buffer.append(startColumnNumber);
+        buffer.append(".");
+        return buffer.toString();
+    }
+    
+    /**
+     * Logs diagnotic information about the script coordinate.
+     * @param logger <code>Log</code>, not null
+     */
+    public void logDiagnosticsInfo(Log logger) {
+        if (logger.isInfoEnabled()) {
+            logger.info("Expression starts line " + startLineNumber + " column " + startColumnNumber);
+            logger.info("Expression ends line " + endLineNumber + " column " + endColumnNumber);
+        }
+    }
+}

Added: james/jsieve/trunk/src/main/java/org/apache/jsieve/SieveContext.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/SieveContext.java?view=auto&rev=524412
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/SieveContext.java (added)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/SieveContext.java Sat Mar 31 05:04:48 2007
@@ -0,0 +1,33 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.jsieve;
+
+/**
+ * Context for sieve operations.
+ *
+ */
+public abstract class SieveContext {
+
+    /**
+     * Gets the script position of the current operation.
+     * @return <code>ScriptCoordinate</code>, not null
+     */
+    public abstract ScriptCoordinate getCoordinate();
+}

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/SieveParserVisitorImpl.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/SieveParserVisitorImpl.java?view=diff&rev=524412&r1=524411&r2=524412
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/SieveParserVisitorImpl.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/SieveParserVisitorImpl.java Sat Mar 31 05:04:48 2007
@@ -42,10 +42,15 @@
  * 
  * <p>See https://javacc.dev.java.net/doc/JJTree.html for indepth information about 
  * Visitor support.</p>
+ * 
+ * <p><strong>Note</strong> that this class is not thread safe. It's use should
+ * be restricted to a single thread for the duration of a visit.
+ * </p> 
  */
 public class SieveParserVisitorImpl implements SieveParserVisitor
 {
-
+    private BaseSieveContext context = new BaseSieveContext();
+    
     /**
      * Constructor for NodeVisitor.
      */
@@ -156,7 +161,8 @@
                 block = (Block) next;
         }
 
-        Command command = new Command(node.getName(), arguments, block);
+        context.setCoordinate(node.getCoordinate());
+        Command command = new Command(node.getName(), arguments, block, context);
         ((List) data).add(command);
         return data;
     }
@@ -251,7 +257,8 @@
                 arguments = (Arguments) next;
         }
 
-        Test test = new Test(node.getName(), arguments);
+        context.setCoordinate(node.getCoordinate());
+        Test test = new Test(node.getName(), arguments, context);
         ((List) data).add(test);
         return data;
     }

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/Test.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/Test.java?view=diff&rev=524412&r1=524411&r2=524412
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/Test.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/Test.java Sat Mar 31 05:04:48 2007
@@ -31,6 +31,8 @@
  */
 public class Test implements Executable
 {
+    private SieveContext context;
+    
     // The name of this Test
     private String fieldName;
     
@@ -48,7 +50,7 @@
         return new Boolean(
             TestManager.getInstance().newInstance(getName()).execute(
                 mail,
-                getArguments()));
+                getArguments(), context));
     }
 
     /**
@@ -64,9 +66,10 @@
      * @param name
      * @param arguments
      */
-    public Test(String name, Arguments arguments)
+    public Test(String name, Arguments arguments, SieveContext context)
     {
         this();
+        this.context = context;
         setName(name);
         setArguments(arguments);
     }    

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/TestList.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/TestList.java?view=diff&rev=524412&r1=524411&r2=524412
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/TestList.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/TestList.java Sat Mar 31 05:04:48 2007
@@ -102,4 +102,9 @@
         fieldTests = children;
     }
 
+    public String toString() {
+        return "TEST LIST: " + fieldTests;
+    }
+
+    
 }

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/AbstractActionCommand.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/AbstractActionCommand.java?view=diff&rev=524412&r1=524411&r2=524412
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/AbstractActionCommand.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/AbstractActionCommand.java Sat Mar 31 05:04:48 2007
@@ -21,6 +21,7 @@
 package org.apache.jsieve.commands;
 
 import org.apache.jsieve.CommandException;
+import org.apache.jsieve.SieveContext;
 
 /**
  * Abstract class AbstractActionCommand defines the common state validation and state
@@ -56,7 +57,7 @@
      * 
      * <p>Also, @see org.apache.jsieve.commands.AbstractCommand#validateState()
      */
-    protected void validateState() throws CommandException
+    protected void validateState(SieveContext context) throws CommandException
     {
         if (CommandStateManager.getInstance().isRejected())
             throw new CommandException("Cannot perform Actions on a rejected message.");

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/AbstractCommand.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/AbstractCommand.java?view=diff&rev=524412&r1=524411&r2=524412
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/AbstractCommand.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/AbstractCommand.java Sat Mar 31 05:04:48 2007
@@ -23,8 +23,8 @@
 import org.apache.jsieve.Arguments;
 import org.apache.jsieve.Block;
 import org.apache.jsieve.CommandException;
+import org.apache.jsieve.SieveContext;
 import org.apache.jsieve.SieveException;
-import org.apache.jsieve.SyntaxException;
 import org.apache.jsieve.mail.MailAdapter;
 
 /**
@@ -46,10 +46,11 @@
      * Framework method validateState is invoked before a Sieve Command is 
      * executed to validate its state. Subclass methods are expected to override
      * or extend this method to perform their own validation as appropriate.
-     * 
+     * @param context <code>SieveContext</code> giving contextual information,
+     * not null
      * @throws CommandException
      */
-    protected void validateState()
+    protected void validateState(SieveContext context)
             throws CommandException
     {
     }
@@ -69,12 +70,14 @@
      * or extend this method to perform their own validation as appropriate.
      * 
      * @param arguments
+     * @param context <code>SieveContext</code> giving contextual information,
+     * not null
      * @throws SieveException
      */
-    protected void validateArguments(Arguments arguments) throws SieveException
+    protected void validateArguments(Arguments arguments, SieveContext context) throws SieveException
     {
         if (!arguments.getArgumentList().isEmpty())
-            throw new SyntaxException("Found unexpected arguments");
+            throw context.getCoordinate().syntaxException("Found unexpected arguments");
     }
     
     /**
@@ -83,13 +86,15 @@
      * or extend this method to perform their own validation as appropriate.
      * 
      * @param block
+     * @param context <code>ScriptCoordinate</code> giving positional information,
+     * not null
      * @throws SieveException
      */
-    protected void validateBlock(Block block)
+    protected void validateBlock(Block block, SieveContext context)
             throws SieveException
     {           
         if (null != block)
-            throw new SyntaxException("Found unexpected Block");         
+            throw context.getCoordinate().syntaxException("Found unexpected Block. Missing ';'?");         
     }        
     
     /**
@@ -100,13 +105,13 @@
      * 
      * <p>Also, @see org.apache.jsieve.Executable#execute()</p>
      */
-    public Object execute(MailAdapter mail, Arguments arguments, Block block)
+    public Object execute(MailAdapter mail, Arguments arguments, Block block, SieveContext context)
         throws SieveException
     {
-        validateState();
-        validateArguments(arguments);        
-        validateBlock(block);         
-        Object result = executeBasic( mail, arguments, block);
+        validateState(context);
+        validateArguments(arguments, context);        
+        validateBlock(block, context);         
+        Object result = executeBasic( mail, arguments, block, context);
         updateState();
         return result;
     } 
@@ -116,10 +121,12 @@
      * @param mail
      * @param arguments
      * @param block
+     * @param context <code>SieveContext</code> giving contextual information,
+     * not null
      * @return Object
      * @throws SieveException
      */
-    abstract protected Object executeBasic(MailAdapter mail, Arguments arguments, Block block)
+    abstract protected Object executeBasic(MailAdapter mail, Arguments arguments, Block block, SieveContext context)
         throws SieveException;           
 
 }

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/AbstractConditionalCommand.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/AbstractConditionalCommand.java?view=diff&rev=524412&r1=524411&r2=524412
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/AbstractConditionalCommand.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/AbstractConditionalCommand.java Sat Mar 31 05:04:48 2007
@@ -21,8 +21,8 @@
 package org.apache.jsieve.commands;
 
 import org.apache.jsieve.Block;
+import org.apache.jsieve.SieveContext;
 import org.apache.jsieve.SieveException;
-import org.apache.jsieve.SyntaxException;
 import org.apache.jsieve.mail.MailAdapter;
 
 /**
@@ -64,13 +64,13 @@
     }
     
     /**
-     * @see org.apache.jsieve.commands.AbstractCommand#validateBlock(Block)
+     * @see org.apache.jsieve.commands.AbstractCommand#validateBlock(Block, SieveContext)
      */
-    protected void validateBlock(Block block)
+    protected void validateBlock(Block block, SieveContext context)
             throws SieveException
     {           
         if (null == block)
-            throw new SyntaxException("Expecting a Block.");         
+            throw context.getCoordinate().syntaxException("Expecting a Block.");         
     }        
     
 

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/AbstractPrologCommand.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/AbstractPrologCommand.java?view=diff&rev=524412&r1=524411&r2=524412
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/AbstractPrologCommand.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/AbstractPrologCommand.java Sat Mar 31 05:04:48 2007
@@ -21,6 +21,7 @@
 package org.apache.jsieve.commands;
 
 import org.apache.jsieve.CommandException;
+import org.apache.jsieve.SieveContext;
 
 /**
  * <p>Abstract class AbstractPrologCommand defines the common state validation behavior
@@ -44,10 +45,10 @@
      * 
      * <p>Also, @see org.apache.jsieve.commands.AbstractCommand#validateState()</p>
      */
-    protected void validateState()
+    protected void validateState(SieveContext context)
             throws CommandException
     {
-        super.validateState();
+        super.validateState(context);
         
         if (!(CommandStateManager.getInstance().isInProlog()))
             throw new CommandException("Invalid state for a prolog command.");     

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/ConditionManager.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/ConditionManager.java?view=diff&rev=524412&r1=524411&r2=524412
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/ConditionManager.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/ConditionManager.java Sat Mar 31 05:04:48 2007
@@ -31,12 +31,12 @@
      */     
     static private ThreadLocal fieldInstance;
     
-    /*
+    /**
      * Is an Else Condition allowed
      */ 
     private boolean fieldElseAllowed;
     
-    /*
+    /**
      * The result of the last Test
      */ 
     private boolean fieldTestResult;    

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/Discard.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/Discard.java?view=diff&rev=524412&r1=524411&r2=524412
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/Discard.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/Discard.java Sat Mar 31 05:04:48 2007
@@ -22,6 +22,7 @@
 
 import org.apache.jsieve.Arguments;
 import org.apache.jsieve.Block;
+import org.apache.jsieve.SieveContext;
 import org.apache.jsieve.SieveException;
 import org.apache.jsieve.mail.MailAdapter;
 
@@ -43,10 +44,10 @@
      * <p>Discard silently discards a Mail by cancelling the implicit keep as 
      * specified in RFC 3028, Section 4.5.</p>
      *<p>
-     * @see org.apache.jsieve.commands.AbstractCommand#executeBasic(MailAdapter, Arguments, Block)
+     * @see org.apache.jsieve.commands.AbstractCommand#executeBasic(MailAdapter, Arguments, Block, SieveContext)
      * </p>
      */  
-    protected Object executeBasic(MailAdapter mail, Arguments arguments, Block block)
+    protected Object executeBasic(MailAdapter mail, Arguments arguments, Block block, SieveContext context)
         throws SieveException
     {                
 //        mail.addAction(new ActionDiscard());

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/Else.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/Else.java?view=diff&rev=524412&r1=524411&r2=524412
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/Else.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/Else.java Sat Mar 31 05:04:48 2007
@@ -23,6 +23,7 @@
 import org.apache.jsieve.Arguments;
 import org.apache.jsieve.Block;
 import org.apache.jsieve.CommandException;
+import org.apache.jsieve.SieveContext;
 import org.apache.jsieve.SieveException;
 import org.apache.jsieve.mail.MailAdapter;
 
@@ -43,13 +44,13 @@
     /**
      * <p>Conditionally eexecute a Block if an Else Condition is runnable.</p> 
      * <p>Also,
-     * @see org.apache.jsieve.commands.AbstractCommand#executeBasic(MailAdapter, Arguments, Block)
+     * @see org.apache.jsieve.commands.AbstractCommand#executeBasic(MailAdapter, Arguments, Block, SieveContext)
      * </p>
      */
     protected Object executeBasic(
         MailAdapter mail,
         Arguments arguments,
-        Block block)
+        Block block, SieveContext context)
         throws SieveException
     {
         // Check Syntax

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/Elsif.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/Elsif.java?view=diff&rev=524412&r1=524411&r2=524412
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/Elsif.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/Elsif.java Sat Mar 31 05:04:48 2007
@@ -23,8 +23,8 @@
 import org.apache.jsieve.Arguments;
 import org.apache.jsieve.Block;
 import org.apache.jsieve.CommandException;
+import org.apache.jsieve.SieveContext;
 import org.apache.jsieve.SieveException;
-import org.apache.jsieve.SyntaxException;
 import org.apache.jsieve.TestList;
 import org.apache.jsieve.mail.MailAdapter;
 
@@ -46,10 +46,10 @@
      * <p>Conditionally eexecute a Block if an Elsif Condition is allowed and
      * runnable.</p> 
      * <p>Also,
-     * @see org.apache.jsieve.commands.AbstractCommand#executeBasic(MailAdapter, Arguments, Block)
+     * @see org.apache.jsieve.commands.AbstractCommand#executeBasic(MailAdapter, Arguments, Block, SieveContext)
      * </p>
      */
-    protected Object executeBasic(MailAdapter mail, Arguments arguments, Block block)
+    protected Object executeBasic(MailAdapter mail, Arguments arguments, Block block, SieveContext context)
         throws SieveException
     {
         // Check Syntax
@@ -76,13 +76,13 @@
     }
     
     /**
-     * @see org.apache.jsieve.commands.AbstractCommand#validateArguments(Arguments)
+     * @see org.apache.jsieve.commands.AbstractCommand#validateArguments(Arguments, SieveContext)
      */
-    protected void validateArguments(Arguments arguments) throws SieveException
+    protected void validateArguments(Arguments arguments, SieveContext context) throws SieveException
     {
         TestList testList = arguments.getTestList();
         if (null == testList || testList.getTests().isEmpty())
-            throw new SyntaxException("Expecting a Test");
+            throw context.getCoordinate().syntaxException("Expecting a Test");
     }
     
 

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/ExecutableCommand.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/ExecutableCommand.java?view=diff&rev=524412&r1=524411&r2=524412
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/ExecutableCommand.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/ExecutableCommand.java Sat Mar 31 05:04:48 2007
@@ -22,6 +22,7 @@
 
 import org.apache.jsieve.Arguments;
 import org.apache.jsieve.Block;
+import org.apache.jsieve.SieveContext;
 import org.apache.jsieve.SieveException;
 import org.apache.jsieve.mail.MailAdapter;
 
@@ -35,9 +36,12 @@
      * @param mail - The mail against which the Command is executed.
      * @param arguments - The Command arguments
      * @param block - An optional Block to be evaluated
+     * @param context <code>SieveContext</code> containing contextual information,
+     * not null
      * @return Object - The result of evaluating the Command
      * @throws SieveException
      */
-    public Object execute(MailAdapter mail, Arguments arguments, Block block) throws SieveException;
+    public Object execute(MailAdapter mail, Arguments arguments, Block block, 
+            SieveContext context) throws SieveException;
 
 }

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/If.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/If.java?view=diff&rev=524412&r1=524411&r2=524412
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/If.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/If.java Sat Mar 31 05:04:48 2007
@@ -23,8 +23,8 @@
 import org.apache.jsieve.Arguments;
 import org.apache.jsieve.Block;
 import org.apache.jsieve.CommandException;
+import org.apache.jsieve.SieveContext;
 import org.apache.jsieve.SieveException;
-import org.apache.jsieve.SyntaxException;
 import org.apache.jsieve.TestList;
 import org.apache.jsieve.mail.MailAdapter;
 
@@ -46,10 +46,10 @@
      * <p>Conditionally eexecute a Block if an If Condition is allowed and
      * runnable.</p> 
      * <p>Also,
-     * @see org.apache.jsieve.commands.AbstractCommand#executeBasic(MailAdapter, Arguments, Block)
+     * @see org.apache.jsieve.commands.AbstractCommand#executeBasic(MailAdapter, Arguments, Block, SieveContext)
      * </p>
      */
-    protected Object executeBasic(MailAdapter mail, Arguments arguments, Block block) throws SieveException
+    protected Object executeBasic(MailAdapter mail, Arguments arguments, Block block, SieveContext context) throws SieveException
     {
         // Check Syntax
         if (!ConditionManager.getInstance().isIfAllowed())
@@ -75,13 +75,13 @@
     }
     
     /**
-     * @see org.apache.jsieve.commands.AbstractCommand#validateArguments(Arguments)
+     * @see org.apache.jsieve.commands.AbstractCommand#validateArguments(Arguments, SieveContext)
      */
-    protected void validateArguments(Arguments arguments) throws SieveException
+    protected void validateArguments(Arguments arguments, SieveContext context) throws SieveException
     {
         TestList testList = arguments.getTestList();
         if (null == testList || testList.getTests().isEmpty())
-            throw new SyntaxException("Expecting a Test");
+            throw context.getCoordinate().syntaxException("Expecting a Test");
     }
     
 

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/Keep.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/Keep.java?view=diff&rev=524412&r1=524411&r2=524412
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/Keep.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/Keep.java Sat Mar 31 05:04:48 2007
@@ -22,6 +22,7 @@
 
 import org.apache.jsieve.Arguments;
 import org.apache.jsieve.Block;
+import org.apache.jsieve.SieveContext;
 import org.apache.jsieve.SieveException;
 import org.apache.jsieve.mail.ActionKeep;
 import org.apache.jsieve.mail.MailAdapter;
@@ -43,10 +44,10 @@
     /**
      * <p>Add an ActionKeep to the List of Actions to be performed.</p>
      * <p>Also,
-     * @see org.apache.jsieve.commands.AbstractCommand#executeBasic(MailAdapter, Arguments, Block)
+     * @see org.apache.jsieve.commands.AbstractCommand#executeBasic(MailAdapter, Arguments, Block, SieveContext)
      * </p>
      */ 
-    protected Object executeBasic(MailAdapter mail, Arguments arguments, Block block)
+    protected Object executeBasic(MailAdapter mail, Arguments arguments, Block block, SieveContext context)
         throws SieveException
     {                 
         mail.addAction(new ActionKeep());

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/Redirect.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/Redirect.java?view=diff&rev=524412&r1=524411&r2=524412
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/Redirect.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/Redirect.java Sat Mar 31 05:04:48 2007
@@ -24,9 +24,9 @@
 
 import org.apache.jsieve.Arguments;
 import org.apache.jsieve.Block;
+import org.apache.jsieve.SieveContext;
 import org.apache.jsieve.SieveException;
 import org.apache.jsieve.StringListArgument;
-import org.apache.jsieve.SyntaxException;
 import org.apache.jsieve.mail.ActionRedirect;
 import org.apache.jsieve.mail.MailAdapter;
 
@@ -48,13 +48,13 @@
      * <p>Add an ActionRedirect to the List of Actions to be performed passing the
      * sole StringList argument as the recipient.</p>
      * <p>Also,
-     * @see org.apache.jsieve.commands.AbstractCommand#executeBasic(MailAdapter, Arguments, Block)
+     * @see org.apache.jsieve.commands.AbstractCommand#executeBasic(MailAdapter, Arguments, Block, SieveContext)
      * </p>
      */  
     protected Object executeBasic(
         MailAdapter mail,
         Arguments arguments,
-        Block block)
+        Block block, SieveContext context)
         throws SieveException
     {
         String recipient =
@@ -69,21 +69,21 @@
     }
 
     /**
-     * @see org.apache.jsieve.commands.AbstractCommand#validateArguments(Arguments)
+     * @see org.apache.jsieve.commands.AbstractCommand#validateArguments(Arguments, SieveContext)
      */
-    protected void validateArguments(Arguments arguments) throws SieveException
+    protected void validateArguments(Arguments arguments, SieveContext context) throws SieveException
     {
         List args = arguments.getArgumentList();
         if (args.size() != 1)
-            throw new SyntaxException(
+            throw context.getCoordinate().syntaxException(
                 "Exactly 1 argument permitted. Found " + args.size());
 
         Object argument = args.get(0);
         if (!(argument instanceof StringListArgument))
-            throw new SyntaxException("Expecting a string-list");
+            throw context.getCoordinate().syntaxException("Expecting a string-list");
 
         if (1 != ((StringListArgument) argument).getList().size())
-            throw new SyntaxException("Expecting exactly one argument");
+            throw context.getCoordinate().syntaxException("Expecting exactly one argument");
     }
 
 }

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/Require.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/Require.java?view=diff&rev=524412&r1=524411&r2=524412
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/Require.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/Require.java Sat Mar 31 05:04:48 2007
@@ -28,9 +28,9 @@
 import org.apache.jsieve.CommandManager;
 import org.apache.jsieve.FeatureException;
 import org.apache.jsieve.LookupException;
+import org.apache.jsieve.SieveContext;
 import org.apache.jsieve.SieveException;
 import org.apache.jsieve.StringListArgument;
-import org.apache.jsieve.SyntaxException;
 import org.apache.jsieve.TestManager;
 import org.apache.jsieve.mail.MailAdapter;
 
@@ -52,13 +52,13 @@
     /**
      * <p>Ensure the required feature is configured.</p>
      * <p>Also,
-     * @see org.apache.jsieve.commands.AbstractCommand#executeBasic(MailAdapter, Arguments, Block)
+     * @see org.apache.jsieve.commands.AbstractCommand#executeBasic(MailAdapter, Arguments, Block, SieveContext)
      * </p>
      */ 
     protected Object executeBasic(
         MailAdapter mail,
         Arguments arguments,
-        Block block)
+        Block block, SieveContext context)
         throws SieveException
     {
         Iterator stringsIter =
@@ -129,18 +129,18 @@
     }
     
     /**
-     * @see org.apache.jsieve.commands.AbstractCommand#validateArguments(Arguments)
+     * @see org.apache.jsieve.commands.AbstractCommand#validateArguments(Arguments, SieveContext)
      */
-    protected void validateArguments(Arguments arguments) throws SieveException
+    protected void validateArguments(Arguments arguments, SieveContext context) throws SieveException
     {
         List args = arguments.getArgumentList();
         if (args.size() != 1)
-            throw new SyntaxException(
+            throw context.getCoordinate().syntaxException(
                 "Exactly 1 argument permitted. Found " + args.size());
 
         Object argument = args.get(0);
         if (!(argument instanceof StringListArgument))
-            throw new SyntaxException("Expecting a string-list");
+            throw context.getCoordinate().syntaxException("Expecting a string-list");
     }
     
 }

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/Stop.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/Stop.java?view=diff&rev=524412&r1=524411&r2=524412
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/Stop.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/Stop.java Sat Mar 31 05:04:48 2007
@@ -22,6 +22,7 @@
 
 import org.apache.jsieve.Arguments;
 import org.apache.jsieve.Block;
+import org.apache.jsieve.SieveContext;
 import org.apache.jsieve.SieveException;
 import org.apache.jsieve.StopException;
 import org.apache.jsieve.mail.MailAdapter;
@@ -44,10 +45,10 @@
     /**
      * <p>Throws a StopException.</p>
      * <p>Also,
-     * @see org.apache.jsieve.commands.AbstractCommand#executeBasic(MailAdapter, Arguments, Block)
+     * @see org.apache.jsieve.commands.AbstractCommand#executeBasic(MailAdapter, Arguments, Block, SieveContext)
      * </p>
      */ 
-    protected Object executeBasic(MailAdapter mail, Arguments arguments, Block block)
+    protected Object executeBasic(MailAdapter mail, Arguments arguments, Block block, SieveContext context)
         throws SieveException
     {
         throw new StopException("Stop requested");

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/extensions/Log.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/extensions/Log.java?view=diff&rev=524412&r1=524411&r2=524412
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/extensions/Log.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/extensions/Log.java Sat Mar 31 05:04:48 2007
@@ -26,6 +26,7 @@
 import org.apache.jsieve.Arguments;
 import org.apache.jsieve.Block;
 import org.apache.jsieve.Logger;
+import org.apache.jsieve.SieveContext;
 import org.apache.jsieve.SieveException;
 import org.apache.jsieve.StringListArgument;
 import org.apache.jsieve.SyntaxException;
@@ -50,12 +51,12 @@
     }
 
     /**
-     * @see org.apache.jsieve.commands.AbstractCommand#executeBasic(MailAdapter, Arguments, Block)
+     * @see org.apache.jsieve.commands.AbstractCommand#executeBasic(MailAdapter, Arguments, Block, SieveContext)
      */
     protected Object executeBasic(
         MailAdapter mail,
         Arguments arguments,
-        Block block)
+        Block block, SieveContext context)
         throws SieveException
     {
         String logLevel = null;
@@ -84,7 +85,7 @@
                         || tag.equals(TRACE_TAG)))
                     logLevel = tag;
                 else
-                    throw new SyntaxException("Found unexpected TagArgument");
+                    throw context.getCoordinate().syntaxException("Found unexpected TagArgument");
             }
             else
             {
@@ -106,13 +107,13 @@
             }
         }
         if (null == message)
-            throw new SyntaxException("Expecting a String");
+            throw context.getCoordinate().syntaxException("Expecting a String");
 
         // Everthing else is an error
         if (argumentsIter.hasNext())
-            throw new SyntaxException("Found unexpected arguments");
+            throw context.getCoordinate().syntaxException("Found unexpected arguments");
 
-        log(null == logLevel ? ":info" : logLevel, message);
+        log(null == logLevel ? ":info" : logLevel, message, context);
 
         return null;
     }
@@ -123,7 +124,7 @@
      * @param message
      * @throws SyntaxException
      */
-    protected void log(String logLevel, String message) throws SyntaxException
+    protected void log(String logLevel, String message, SieveContext context) throws SyntaxException
     {
         if (logLevel.equals(INFO_TAG))
             logInfo(message);
@@ -138,7 +139,7 @@
         else if (logLevel.equals(TRACE_TAG))
             logTrace(message);
         else
-            throw new SyntaxException("Unsupported logging level: " + logLevel);
+            throw context.getCoordinate().syntaxException("Unsupported logging level: " + logLevel);
     }
 
     
@@ -209,9 +210,9 @@
     }    
 
     /**
-     * @see org.apache.jsieve.commands.AbstractCommand#validateArguments(Arguments)
+     * @see org.apache.jsieve.commands.AbstractCommand#validateArguments(Arguments, SieveContext)
      */
-    protected void validateArguments(Arguments arguments) throws SieveException
+    protected void validateArguments(Arguments arguments, SieveContext context) throws SieveException
     {
         // Validation is performed in executeBasic()
     }

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/optional/FileInto.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/optional/FileInto.java?view=diff&rev=524412&r1=524411&r2=524412
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/optional/FileInto.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/optional/FileInto.java Sat Mar 31 05:04:48 2007
@@ -25,9 +25,9 @@
 
 import org.apache.jsieve.Arguments;
 import org.apache.jsieve.Block;
+import org.apache.jsieve.SieveContext;
 import org.apache.jsieve.SieveException;
 import org.apache.jsieve.StringListArgument;
-import org.apache.jsieve.SyntaxException;
 import org.apache.jsieve.commands.AbstractActionCommand;
 import org.apache.jsieve.mail.Action;
 import org.apache.jsieve.mail.ActionFileInto;
@@ -56,13 +56,13 @@
      * Command is silently ignored. 
      * </p>
      * <p>Also,
-     * @see org.apache.jsieve.commands.AbstractCommand#executeBasic(MailAdapter, Arguments, Block)
+     * @see org.apache.jsieve.commands.AbstractCommand#executeBasic(MailAdapter, Arguments, Block, SieveContext)
      * </p>
      */
     protected Object executeBasic(
         MailAdapter mail,
         Arguments arguments,
-        Block block)
+        Block block, SieveContext context)
         throws SieveException
     {
         String destination =
@@ -92,21 +92,21 @@
     }
     
     /**
-     * @see org.apache.jsieve.commands.AbstractCommand#validateArguments(Arguments)
+     * @see org.apache.jsieve.commands.AbstractCommand#validateArguments(Arguments, SieveContext)
      */
-    protected void validateArguments(Arguments arguments) throws SieveException
+    protected void validateArguments(Arguments arguments, SieveContext context) throws SieveException
     {
         List args = arguments.getArgumentList();
         if (args.size() != 1)
-            throw new SyntaxException(
+            throw context.getCoordinate().syntaxException(
                 "Exactly 1 argument permitted. Found " + args.size());
 
         Object argument = args.get(0);
         if (!(argument instanceof StringListArgument))
-            throw new SyntaxException("Expecting a string-list");
+            throw context.getCoordinate().syntaxException("Expecting a string-list");
 
         if (1 != ((StringListArgument) argument).getList().size())
-            throw new SyntaxException("Expecting exactly one argument");
+            throw context.getCoordinate().syntaxException("Expecting exactly one argument");
     }
     
 

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/optional/Reject.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/optional/Reject.java?view=diff&rev=524412&r1=524411&r2=524412
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/optional/Reject.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/optional/Reject.java Sat Mar 31 05:04:48 2007
@@ -25,9 +25,9 @@
 import org.apache.jsieve.Arguments;
 import org.apache.jsieve.Block;
 import org.apache.jsieve.CommandException;
+import org.apache.jsieve.SieveContext;
 import org.apache.jsieve.SieveException;
 import org.apache.jsieve.StringListArgument;
-import org.apache.jsieve.SyntaxException;
 import org.apache.jsieve.commands.AbstractActionCommand;
 import org.apache.jsieve.commands.CommandStateManager;
 import org.apache.jsieve.mail.ActionReject;
@@ -59,10 +59,10 @@
     /**
      * <p>Add an ActionReject to the List of Actions to be performed.</p>
      * <p>Also,
-     * @see org.apache.jsieve.commands.AbstractCommand#executeBasic(MailAdapter, Arguments, Block)
+     * @see org.apache.jsieve.commands.AbstractCommand#executeBasic(MailAdapter, Arguments, Block, SieveContext)
      * </p>
      */  
-    protected Object executeBasic(MailAdapter mail, Arguments arguments, Block block)
+    protected Object executeBasic(MailAdapter mail, Arguments arguments, Block block, SieveContext context)
         throws SieveException
     {
         String message =
@@ -76,11 +76,11 @@
     }
     
     /**
-     * @see org.apache.jsieve.commands.AbstractCommand#validateState()
+     * @see org.apache.jsieve.commands.AbstractCommand#validateState(SieveContext)
      */
-    protected void validateState() throws CommandException
+    protected void validateState(SieveContext context) throws CommandException
     {
-        super.validateState();
+        super.validateState(context);
 
         if (CommandStateManager.getInstance().isHasActions())
             throw new CommandException("The \"reject\" command is not allowed with other Action Commands");
@@ -96,21 +96,21 @@
     } 
     
     /**
-     * @see org.apache.jsieve.commands.AbstractCommand#validateArguments(Arguments)
+     * @see org.apache.jsieve.commands.AbstractCommand#validateArguments(Arguments, SieveContext)
      */
-    protected void validateArguments(Arguments arguments) throws SieveException
+    protected void validateArguments(Arguments arguments, SieveContext context) throws SieveException
     {
         List args = arguments.getArgumentList();
         if (args.size() != 1)
-            throw new SyntaxException(
+            throw context.getCoordinate().syntaxException(
                 "Exactly 1 argument permitted. Found " + args.size());
 
         Object argument = args.get(0);
         if (!(argument instanceof StringListArgument))
-            throw new SyntaxException("Expecting a string-list");
+            throw context.getCoordinate().syntaxException("Expecting a string-list");
 
         if (1 != ((StringListArgument) argument).getList().size())
-            throw new SyntaxException("Expecting exactly one argument");
+            throw context.getCoordinate().syntaxException("Expecting exactly one argument");
     }  
 
 }

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/parser/SieveNode.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/parser/SieveNode.java?view=diff&rev=524412&r1=524411&r2=524412
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/parser/SieveNode.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/parser/SieveNode.java Sat Mar 31 05:04:48 2007
@@ -20,6 +20,9 @@
 
 package org.apache.jsieve.parser;
 
+import org.apache.jsieve.ScriptCoordinate;
+import org.apache.jsieve.parser.generated.Token;
+
 /**
  * Class SieveNode defines aspects all jjTree parse nodes may require.
  * 
@@ -36,6 +39,9 @@
         super();
     }
 
+    private Token firstToken;
+    private Token lastToken;
+    
     /**
      * The name associated to this node or null 
      */     
@@ -81,4 +87,49 @@
         fieldValue = value;
     }
 
+    /**
+     * Gets the first token comprising this node.
+     * @return <code>Token</code>, not null
+     */
+    public Token getFirstToken() {
+        return firstToken;
+    }
+    
+    /**
+     * Sets the first token comprising this node.
+     * @param firstToken <code>Token</code>, not null
+     */
+    public void setFirstToken(Token firstToken) {
+        this.firstToken = firstToken;
+    }
+
+    /**
+     * Gets the last token comprising this node.
+     * @return <code>Token</code>, not null
+     */
+    public Token getLastToken() {
+        return lastToken;
+    }
+
+    /**
+     * Sets the last token comprising this node.
+     * @param lastToken <code>Token</code>, not null
+     */
+    public void setLastToken(Token lastToken) {
+        this.lastToken = lastToken;
+    }
+    
+    /**
+     * Gets the position of this node in the script.
+     * @return <code>ScriptCoordinate</code> containing the position of this node, 
+     * not null
+     */
+    public ScriptCoordinate getCoordinate() {
+        final int lastColumn = lastToken.endColumn;
+        final int lastList = lastToken.endLine;
+        final int firstColumn = firstToken.beginColumn;
+        final int firstLine = firstToken.beginLine;
+        final ScriptCoordinate scriptCoordinate = new ScriptCoordinate(firstLine, firstColumn, lastList, lastColumn);
+        return scriptCoordinate;
+    }
 }

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/samples/james/Actions.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/samples/james/Actions.java?view=diff&rev=524412&r1=524411&r2=524412
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/samples/james/Actions.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/samples/james/Actions.java Sat Mar 31 05:04:48 2007
@@ -298,10 +298,10 @@
     protected static MailAddress getSoleRecipient(Mail aMail)
             throws MessagingException
     {
-    	  if (aMail.getRecipients() == null) {
+          if (aMail.getRecipients() == null) {
           throw new MessagingException("Invalid number of recipients - 0"
               + ". Exactly 1 recipient is expected.");
-    	  } else if (1 != aMail.getRecipients().size())
+          } else if (1 != aMail.getRecipients().size())
             throw new MessagingException("Invalid number of recipients - "
                     + new Integer(aMail.getRecipients().size()).toString()
                     + ". Exactly 1 recipient is expected.");

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/AbstractTest.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/AbstractTest.java?view=diff&rev=524412&r1=524411&r2=524412
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/AbstractTest.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/AbstractTest.java Sat Mar 31 05:04:48 2007
@@ -20,7 +20,10 @@
 
 package org.apache.jsieve.tests;
 
+import org.apache.commons.logging.Log;
 import org.apache.jsieve.Arguments;
+import org.apache.jsieve.Logger;
+import org.apache.jsieve.SieveContext;
 import org.apache.jsieve.SieveException;
 import org.apache.jsieve.SyntaxException;
 import org.apache.jsieve.mail.MailAdapter;
@@ -54,21 +57,23 @@
      * 
      * <p>Also, @see org.apache.jsieve.tests.ExecutableTest#execute(MailAdapter, Arguments)
      */
-    public boolean execute(MailAdapter mail, Arguments arguments)
+    public boolean execute(MailAdapter mail, Arguments arguments, SieveContext context)
         throws SieveException
     {
-        validateArguments(arguments);
-        return executeBasic(mail, arguments);
+        validateArguments(arguments, context);
+        return executeBasic(mail, arguments, context);
     }
     
     /**
      * Abstract method executeBasic invokes a Sieve Test.
      * @param mail
      * @param arguments
+     * @param context <code>SieveContext</code> giving contextual information,
+     * not null
      * @return boolean
      * @throws SieveException
      */
-    protected abstract boolean executeBasic(MailAdapter mail, Arguments arguments)
+    protected abstract boolean executeBasic(MailAdapter mail, Arguments arguments, SieveContext context)
         throws SieveException;
         
     /**
@@ -76,16 +81,21 @@
      * executed to validate its arguments. Subclass methods are expected to override
      * or extend this method to perform their own validation as appropriate.
      * @param arguments
+     * @param context <code>SieveContext</code> giving comntextual information,
+     * not null
      * @throws SieveException
      */
-    protected void validateArguments(Arguments arguments) throws SieveException
+    protected void validateArguments(Arguments arguments, SieveContext context) throws SieveException
     {
-        if (!arguments.getArgumentList().isEmpty())
-            throw new SyntaxException("Found unexpected arguments");
+        if (!arguments.getArgumentList().isEmpty()) {
+            final Log logger = Logger.getLog();
+            if (logger.isWarnEnabled()) {
+                logger.warn("Unexpected arguments for " + getClass().getName());
+            }
+            context.getCoordinate().logDiagnosticsInfo(logger);
+            logger.debug(arguments);
+            final String message = context.getCoordinate().addStartLineAndColumn("Found unexpected arguments.");
+            throw new SyntaxException(message);
+        }
     }
-    
-
-        
-   
-
 }

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/Address.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/Address.java?view=diff&rev=524412&r1=524411&r2=524412
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/Address.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/Address.java Sat Mar 31 05:04:48 2007
@@ -29,6 +29,7 @@
 
 import org.apache.jsieve.Arguments;
 import org.apache.jsieve.InternetAddressException;
+import org.apache.jsieve.SieveContext;
 import org.apache.jsieve.SieveException;
 import org.apache.jsieve.StringListArgument;
 import org.apache.jsieve.SyntaxException;
@@ -63,9 +64,9 @@
      * order of the optional parts is different, so I am assuming that the order of
      * the optional parts is optional too!</p>
      * 
-     * @see org.apache.jsieve.tests.AbstractTest#executeBasic(MailAdapter, Arguments)
+     * @see org.apache.jsieve.tests.AbstractTest#executeBasic(MailAdapter, Arguments, SieveContext)
      */
-    protected boolean executeBasic(MailAdapter mail, Arguments arguments)
+    protected boolean executeBasic(MailAdapter mail, Arguments arguments, SieveContext context)
         throws SieveException
     {
         String addressPart = null;
@@ -118,7 +119,7 @@
                             || tag.equals(MATCHES_TAG)))
                     matchType = tag;
                 else
-                    throw new SyntaxException("Found unexpected TagArgument");
+                    throw context.getCoordinate().syntaxException("Found unexpected TagArgument");
             }
             else
             {
@@ -136,7 +137,7 @@
                 headerNames = ((StringListArgument) argument).getList();
         }
         if (null == headerNames)
-            throw new SyntaxException("Expecting a StringList of header names");
+            throw context.getCoordinate().syntaxException("Expecting a StringList of header names");
 
         // The next argument MUST be a string-list of keys
         if (argumentsIter.hasNext())
@@ -146,10 +147,10 @@
                 keys = ((StringListArgument) argument).getList();
         }
         else if (null == keys)
-            throw new SyntaxException("Expecting a StringList of keys");
+            throw context.getCoordinate().syntaxException("Expecting a StringList of keys");
 
         if (argumentsIter.hasNext())
-            throw new SyntaxException("Found unexpected arguments");
+            throw context.getCoordinate().syntaxException("Found unexpected arguments");
 
         return match(
             mail,
@@ -362,12 +363,12 @@
     }
 
     /**
-     * @see org.apache.jsieve.tests.AbstractTest#validateArguments(Arguments)
+     * @see org.apache.jsieve.tests.AbstractTest#validateArguments(Arguments, ScriptContext)
      */
-    protected void validateArguments(Arguments arguments) throws SieveException
+    protected void validateArguments(Arguments arguments, SieveContext context) throws SieveException
     {
         if (arguments.hasTests())
-            throw new SyntaxException("Found unexpected tests");
+            throw context.getCoordinate().syntaxException("Found unexpected tests");
     }
 
 }

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/AllOf.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/AllOf.java?view=diff&rev=524412&r1=524411&r2=524412
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/AllOf.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/AllOf.java Sat Mar 31 05:04:48 2007
@@ -23,6 +23,7 @@
 import java.util.Iterator;
 
 import org.apache.jsieve.Arguments;
+import org.apache.jsieve.SieveContext;
 import org.apache.jsieve.SieveException;
 import org.apache.jsieve.Test;
 import org.apache.jsieve.mail.MailAdapter;
@@ -42,9 +43,9 @@
     }
 
     /**
-     * @see org.apache.jsieve.tests.AbstractTest#executeBasic(MailAdapter, Arguments)
+     * @see org.apache.jsieve.tests.AbstractTest#executeBasic(MailAdapter, Arguments, SieveContext)
      */
-    protected boolean executeBasic(MailAdapter mail, Arguments arguments) throws SieveException
+    protected boolean executeBasic(MailAdapter mail, Arguments arguments, SieveContext context) throws SieveException
     {
         boolean result = true;
         Iterator testsIter = arguments.getTestList().getTests().iterator();

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/AnyOf.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/AnyOf.java?view=diff&rev=524412&r1=524411&r2=524412
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/AnyOf.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/AnyOf.java Sat Mar 31 05:04:48 2007
@@ -23,6 +23,7 @@
 import java.util.Iterator;
 
 import org.apache.jsieve.Arguments;
+import org.apache.jsieve.SieveContext;
 import org.apache.jsieve.SieveException;
 import org.apache.jsieve.Test;
 import org.apache.jsieve.mail.MailAdapter;
@@ -42,9 +43,9 @@
     }
 
     /**
-     * @see org.apache.jsieve.tests.AbstractTest#executeBasic(MailAdapter, Arguments)
+     * @see org.apache.jsieve.tests.AbstractTest#executeBasic(MailAdapter, Arguments, SieveContext)
      */
-    protected boolean executeBasic(MailAdapter mail, Arguments arguments) throws SieveException
+    protected boolean executeBasic(MailAdapter mail, Arguments arguments, SieveContext context) throws SieveException
     {
         boolean result = false;
         Iterator testsIter = arguments.getTestList().getTests().iterator();

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/ExecutableTest.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/ExecutableTest.java?view=diff&rev=524412&r1=524411&r2=524412
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/ExecutableTest.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/ExecutableTest.java Sat Mar 31 05:04:48 2007
@@ -21,6 +21,7 @@
 package org.apache.jsieve.tests;
 
 import org.apache.jsieve.Arguments;
+import org.apache.jsieve.SieveContext;
 import org.apache.jsieve.SieveException;
 import org.apache.jsieve.mail.MailAdapter;
 
@@ -34,9 +35,11 @@
      * was passed. 
      * @param mail
      * @param arguments
+     * @param context <code>SieveContext</code> giving contextual information,
+     * not null
      * @return boolean
      * @throws SieveException
      */
-    public boolean execute(MailAdapter mail, Arguments arguments) throws SieveException;
+    public boolean execute(MailAdapter mail, Arguments arguments, SieveContext context) throws SieveException;
 
 }

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/Exists.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/Exists.java?view=diff&rev=524412&r1=524411&r2=524412
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/Exists.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/Exists.java Sat Mar 31 05:04:48 2007
@@ -24,9 +24,9 @@
 import java.util.List;
 
 import org.apache.jsieve.Arguments;
+import org.apache.jsieve.SieveContext;
 import org.apache.jsieve.SieveException;
 import org.apache.jsieve.StringListArgument;
-import org.apache.jsieve.SyntaxException;
 import org.apache.jsieve.mail.MailAdapter;
 
 /**
@@ -44,9 +44,9 @@
     }
 
     /**
-     * @see org.apache.jsieve.tests.AbstractTest#executeBasic(MailAdapter, Arguments)
+     * @see org.apache.jsieve.tests.AbstractTest#executeBasic(MailAdapter, Arguments, SieveContext)
      */
-    protected boolean executeBasic(MailAdapter mail, Arguments arguments)
+    protected boolean executeBasic(MailAdapter mail, Arguments arguments, SieveContext context)
         throws SieveException
     {
 
@@ -65,19 +65,19 @@
     }
 
     /**
-     * @see org.apache.jsieve.tests.AbstractTest#validateArguments(Arguments)
+     * @see org.apache.jsieve.tests.AbstractTest#validateArguments(Arguments, ScriptContext)
      */
-    protected void validateArguments(Arguments arguments) throws SieveException
+    protected void validateArguments(Arguments arguments, SieveContext context) throws SieveException
     {
         List argumentsList = arguments.getArgumentList();
         if (1 != argumentsList.size())
-            throw new SyntaxException("Expecting exactly one argument");
+            throw context.getCoordinate().syntaxException("Expecting exactly one argument");
             
         if (!(argumentsList.get(0) instanceof StringListArgument))
-            throw new SyntaxException("Expecting a StringList");        
+            throw context.getCoordinate().syntaxException("Expecting a StringList");        
                
         if (arguments.hasTests())
-            throw new SyntaxException("Found unexpected tests");
+            throw context.getCoordinate().syntaxException("Found unexpected tests");
     }
 
 }

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/False.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/False.java?view=diff&rev=524412&r1=524411&r2=524412
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/False.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/False.java Sat Mar 31 05:04:48 2007
@@ -21,6 +21,7 @@
 package org.apache.jsieve.tests;
 
 import org.apache.jsieve.Arguments;
+import org.apache.jsieve.SieveContext;
 import org.apache.jsieve.mail.MailAdapter;
 
 /**
@@ -38,9 +39,9 @@
     }
 
     /**
-     * @see org.apache.jsieve.tests.AbstractTest#executeBasic(MailAdapter, Arguments)
+     * @see org.apache.jsieve.tests.AbstractTest#executeBasic(MailAdapter, Arguments, SieveContext)
      */
-    protected boolean executeBasic(MailAdapter mail, Arguments arguments)
+    protected boolean executeBasic(MailAdapter mail, Arguments arguments, SieveContext context)
     {
         return false;
     }

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/Header.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/Header.java?view=diff&rev=524412&r1=524411&r2=524412
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/Header.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/Header.java Sat Mar 31 05:04:48 2007
@@ -20,14 +20,15 @@
 
 package org.apache.jsieve.tests;
 
+import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.ListIterator;
 
 import org.apache.jsieve.Arguments;
+import org.apache.jsieve.SieveContext;
 import org.apache.jsieve.SieveException;
 import org.apache.jsieve.StringListArgument;
-import org.apache.jsieve.SyntaxException;
 import org.apache.jsieve.TagArgument;
 import org.apache.jsieve.comparators.ComparatorNames;
 import org.apache.jsieve.comparators.ComparatorUtils;
@@ -59,9 +60,9 @@
      * order of the optional parts is different, so I guess that the order is
      * optional too!</p>
      * 
-     * @see org.apache.jsieve.tests.AbstractTest#executeBasic(MailAdapter, Arguments)
+     * @see org.apache.jsieve.tests.AbstractTest#executeBasic(MailAdapter, Arguments, SieveContext)
      */
-    protected boolean executeBasic(MailAdapter mail, Arguments arguments)
+    protected boolean executeBasic(MailAdapter mail, Arguments arguments, SieveContext context)
         throws SieveException
     {
         String comparator = null;
@@ -91,11 +92,11 @@
                             List stringList =
                                 ((StringListArgument) argument).getList();
                             if (stringList.size() != 1)
-                                throw new SyntaxException("Expecting exactly one String");
+                                throw context.getCoordinate().syntaxException("Expecting exactly one String");
                             comparator = (String) stringList.get(0);
                         }
                         else
-                            throw new SyntaxException("Expecting a StringList");
+                            throw context.getCoordinate().syntaxException("Expecting a StringList");
                     }
                 }
                 // [MATCH-TYPE]?
@@ -106,7 +107,7 @@
                             || tag.equals(MATCHES_TAG)))
                     matchType = tag;
                 else
-                    throw new SyntaxException(
+                    throw context.getCoordinate().syntaxException(
                         "Found unexpected TagArgument: \"" + tag + "\"");
             }
             else
@@ -125,7 +126,7 @@
                 headerNames = ((StringListArgument) argument).getList();
         }
         if (null == headerNames)
-            throw new SyntaxException("Expecting a StringListof header names");
+            throw context.getCoordinate().syntaxException("Expecting a StringListof header names");
 
         // The next argument MUST be a string-list of keys
         if (argumentsIter.hasNext())
@@ -135,10 +136,10 @@
                 keys = ((StringListArgument) argument).getList();
         }
         if (null == keys)
-            throw new SyntaxException("Expecting a StringList of keys");
+            throw context.getCoordinate().syntaxException("Expecting a StringList of keys");
 
         if (argumentsIter.hasNext())
-            throw new SyntaxException("Found unexpected arguments");
+            throw context.getCoordinate().syntaxException("Found unexpected arguments");
 
         return match(
             mail,
@@ -203,10 +204,13 @@
         // else 
         //     not matched
         if (headerValues.isEmpty())
-            if (matchType.equals(CONTAINS_TAG))
+            if (matchType.equals(CONTAINS_TAG)) {
+                // header values may be immutable
+                headerValues = new ArrayList(headerValues);
                 headerValues.add("");
-            else
+            } else {
                 return false;
+            }
         // Iterate over the header values looking for a match
         boolean isMatched = false;
         Iterator headerValuesIter = headerValues.iterator();
@@ -254,12 +258,12 @@
     }
 
     /**
-     * @see org.apache.jsieve.tests.AbstractTest#validateArguments(Arguments)
+     * @see org.apache.jsieve.tests.AbstractTest#validateArguments(Arguments, ScriptContext)
      */
-    protected void validateArguments(Arguments arguments) throws SieveException
+    protected void validateArguments(Arguments arguments, SieveContext context) throws SieveException
     {
         if (arguments.hasTests())
-            throw new SyntaxException("Found unexpected tests");
+            throw context.getCoordinate().syntaxException("Found unexpected tests");
     }
 
 }

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/Not.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/Not.java?view=diff&rev=524412&r1=524411&r2=524412
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/Not.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/Not.java Sat Mar 31 05:04:48 2007
@@ -24,8 +24,8 @@
 import java.util.List;
 
 import org.apache.jsieve.Arguments;
+import org.apache.jsieve.SieveContext;
 import org.apache.jsieve.SieveException;
-import org.apache.jsieve.SyntaxException;
 import org.apache.jsieve.Test;
 import org.apache.jsieve.mail.MailAdapter;
 
@@ -44,14 +44,14 @@
     }
 
     /**
-     * @see org.apache.jsieve.tests.AbstractTest#executeBasic(MailAdapter, Arguments)
+     * @see org.apache.jsieve.tests.AbstractTest#executeBasic(MailAdapter, Arguments, SieveContext)
      */
-    protected boolean executeBasic(MailAdapter mail, Arguments arguments) throws SieveException
+    protected boolean executeBasic(MailAdapter mail, Arguments arguments, SieveContext context) throws SieveException
     {
         boolean result = true;
         List tests = arguments.getTestList().getTests();
         if (tests.size() != 1)
-            throw new SyntaxException(
+            throw context.getCoordinate().syntaxException(
                 "Exactly 1 test permitted. Found " + tests.size());
         Iterator testsIter = tests.iterator();
         while (testsIter.hasNext())

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/Size.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/Size.java?view=diff&rev=524412&r1=524411&r2=524412
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/Size.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/Size.java Sat Mar 31 05:04:48 2007
@@ -24,6 +24,7 @@
 
 import org.apache.jsieve.Arguments;
 import org.apache.jsieve.NumberArgument;
+import org.apache.jsieve.SieveContext;
 import org.apache.jsieve.SieveException;
 import org.apache.jsieve.SyntaxException;
 import org.apache.jsieve.TagArgument;
@@ -45,13 +46,13 @@
     }
 
     /**
-     * @see org.apache.jsieve.tests.AbstractTest#executeBasic(MailAdapter, Arguments)
+     * @see org.apache.jsieve.tests.AbstractTest#executeBasic(MailAdapter, Arguments, SieveContext)
      * <p>From RFC 3028, Section 5.9... </p>
      * <code>  
      *    Syntax: size &lt;&quote;:over"&quote; / &quote;:under&quote;&gt; &lt;limit: number&gt;
      * </code>
      */
-    protected boolean executeBasic(MailAdapter mail, Arguments arguments)
+    protected boolean executeBasic(MailAdapter mail, Arguments arguments, SieveContext context)
         throws SyntaxException, SieveMailException
     {
         String comparator = null;
@@ -68,12 +69,12 @@
                 if (tag.equals(":under") || tag.equals(":over"))
                     comparator = tag;
                 else
-                    throw new SyntaxException(
+                    throw context.getCoordinate().syntaxException(
                         "Found unexpected TagArgument: \"" + tag + "\"");
             }
         }
         if (null == comparator)
-            throw new SyntaxException("Expecting a Tag");
+            throw context.getCoordinate().syntaxException("Expecting a Tag");
 
         // Second argument MUST be a number
         if (argumentsIter.hasNext())
@@ -83,11 +84,11 @@
                 size = ((NumberArgument) argument).getInteger();
         }
         if (null == size)
-            throw new SyntaxException("Expecting a Number");
+            throw context.getCoordinate().syntaxException("Expecting a Number");
 
         // There MUST NOT be any further arguments
         if (argumentsIter.hasNext())
-            throw new SyntaxException("Found unexpected argument(s)");               
+            throw context.getCoordinate().syntaxException("Found unexpected argument(s)");               
 
         return test(mail, comparator, size.intValue());
     }
@@ -141,9 +142,9 @@
 
 
     /**
-     * @see org.apache.jsieve.tests.AbstractTest#validateArguments(Arguments)
+     * @see org.apache.jsieve.tests.AbstractTest#validateArguments(Arguments, ScriptContext)
      */
-    protected void validateArguments(Arguments arguments) throws SieveException
+    protected void validateArguments(Arguments arguments, SieveContext context) throws SieveException
     {
         // All done in executeBasic()
     }

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/True.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/True.java?view=diff&rev=524412&r1=524411&r2=524412
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/True.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/tests/True.java Sat Mar 31 05:04:48 2007
@@ -21,6 +21,7 @@
 package org.apache.jsieve.tests;
 
 import org.apache.jsieve.Arguments;
+import org.apache.jsieve.SieveContext;
 import org.apache.jsieve.mail.MailAdapter;
 
 /**
@@ -38,9 +39,9 @@
     }
 
     /**
-     * @see org.apache.jsieve.tests.AbstractTest#executeBasic(MailAdapter, Arguments)
+     * @see org.apache.jsieve.tests.AbstractTest#executeBasic(MailAdapter, Arguments, SieveContext)
      */
-    protected boolean executeBasic(MailAdapter mail, Arguments arguments)
+    protected boolean executeBasic(MailAdapter mail, Arguments arguments, SieveContext context)
     {
         return true;
     }

Modified: james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/commands/ThrowTestException.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/commands/ThrowTestException.java?view=diff&rev=524412&r1=524411&r2=524412
==============================================================================
--- james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/commands/ThrowTestException.java (original)
+++ james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/commands/ThrowTestException.java Sat Mar 31 05:04:48 2007
@@ -22,6 +22,7 @@
 
 import org.apache.jsieve.Arguments;
 import org.apache.jsieve.Block;
+import org.apache.jsieve.SieveContext;
 import org.apache.jsieve.SieveException;
 import org.apache.jsieve.commands.ExecutableCommand;
 import org.apache.jsieve.mail.MailAdapter;
@@ -84,9 +85,9 @@
     }
 
     /**
-     * @see org.apache.jsieve.commands.ExecutableCommand#execute(MailAdapter, Arguments, Block)
+     * @see org.apache.jsieve.commands.ExecutableCommand#execute(MailAdapter, Arguments, Block, SieveContext)
      */
-    public Object execute(MailAdapter mail, Arguments arguments, Block block)
+    public Object execute(MailAdapter mail, Arguments arguments, Block block, SieveContext context)
         throws SieveException
     {
         throw new TestException();



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org