View Javadoc

1   /****************************************************************
2    * Licensed to the Apache Software Foundation (ASF) under one   *
3    * or more contributor license agreements.  See the NOTICE file *
4    * distributed with this work for additional information        *
5    * regarding copyright ownership.  The ASF licenses this file   *
6    * to you under the Apache License, Version 2.0 (the            *
7    * "License"); you may not use this file except in compliance   *
8    * with the License.  You may obtain a copy of the License at   *
9    *                                                              *
10   *   http://www.apache.org/licenses/LICENSE-2.0                 *
11   *                                                              *
12   * Unless required by applicable law or agreed to in writing,   *
13   * software distributed under the License is distributed on an  *
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
15   * KIND, either express or implied.  See the License for the    *
16   * specific language governing permissions and limitations      *
17   * under the License.                                           *
18   ****************************************************************/
19  
20  package org.apache.jsieve;
21  
22  import org.apache.commons.logging.Log;
23  
24  /**
25   * Bean based implementation of context.
26   * 
27   */
28  public class BaseSieveContext extends SieveContext {
29  
30      private ScriptCoordinate coordinate;
31  
32      private ConditionManager conditionManager;
33  
34      private final CommandStateManager commandStateManager;
35  
36      private final CommandManager commandManager;
37  
38      private final ComparatorManager comparatorManager;
39  
40      private final TestManager testManager;
41  
42      private final Log log;
43  
44      public BaseSieveContext(final CommandManager commandManager,
45              final ComparatorManager comparatorManager,
46              final TestManager testManager, final Log log) {
47          this.commandStateManager = new CommandStateManager();
48          this.conditionManager = new ConditionManager();
49          this.testManager = testManager;
50          this.commandManager = commandManager;
51          this.comparatorManager = comparatorManager;
52          this.log = log;
53      }
54  
55      /**
56       * Gets the script position of the current operation.
57       * 
58       * @return <code>ScriptCoordinate</code>, not null
59       */
60      @Override
61      public ScriptCoordinate getCoordinate() {
62          return coordinate;
63      }
64  
65      /**
66       * Sets the script position of the current operation.
67       * 
68       * @param coordinate
69       *            <code>ScriptCoordinate</code>, not null
70       */
71      @Override
72      public void setCoordinate(ScriptCoordinate coordinate) {
73          this.coordinate = coordinate;
74          if (coordinate != null) {
75              coordinate.setLog(getLog());
76          }
77      }
78  
79      /**
80       * @see SieveContext#getCommandStateManager()
81       */
82      @Override
83      public CommandStateManager getCommandStateManager() {
84          return commandStateManager;
85      }
86  
87      /**
88       * @see SieveContext#getConditionManager()
89       */
90      @Override
91      public ConditionManager getConditionManager() {
92          return conditionManager;
93      }
94  
95      /**
96       * @see SieveContext#setConditionManager(ConditionManager)
97       */
98      @Override
99      public void setConditionManager(ConditionManager conditionManager) {
100         this.conditionManager = conditionManager;
101     }
102 
103     /**
104      * @see SieveContext#getLog()
105      */
106     @Override
107     public Log getLog() {
108         return log;
109     }
110 
111     /**
112      * @see SieveContext#getComparatorManager()
113      */
114     @Override
115     public ComparatorManager getComparatorManager() {
116         return comparatorManager;
117     }
118 
119     /**
120      * @see SieveContext#getCommandManager()
121      */
122     @Override
123     public CommandManager getCommandManager() {
124         return commandManager;
125     }
126 
127     /**
128      * @see SieveContext#getTestManager()
129      */
130     @Override
131     public TestManager getTestManager() {
132         return testManager;
133     }
134     
135     
136 }