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 /**
23 * Thread singleton class CommandStateManager records the state of a Sieve
24 * evaluation.
25 */
26 public class CommandStateManager {
27
28 /**
29 * The evaluated script is processing Prolog Commands
30 */
31 private boolean fieldInProlog = true;
32
33 /**
34 * The evaluated script has rejected the mail
35 */
36 private boolean fieldRejected = false;
37
38 /**
39 * The evaluated script must keep the mail
40 */
41 private boolean fieldImplicitKeep = true;
42
43 /**
44 * The evaluation has processed Action Commands
45 */
46 private boolean fieldHasActions = false;
47
48 /**
49 * Constructor for CommandStateManager.
50 */
51 public CommandStateManager() {
52 super();
53 initialize();
54 }
55
56 /**
57 * Initialize the receiver.
58 */
59 protected void initialize() {
60 setInProlog(true);
61 setRejected(false);
62 setHasActions(false);
63 setImplicitKeep(true);
64 }
65
66 /**
67 * Returns the hasActions.
68 *
69 * @return boolean
70 */
71 public boolean isHasActions() {
72 return fieldHasActions;
73 }
74
75 /**
76 * Returns the inProlog.
77 *
78 * @return boolean
79 */
80 public boolean isInProlog() {
81 return fieldInProlog;
82 }
83
84 /**
85 * Returns the isRejected.
86 *
87 * @return boolean
88 */
89 public boolean isRejected() {
90 return fieldRejected;
91 }
92
93 /**
94 * Sets the hasActions.
95 *
96 * @param hasActions
97 * The hasActions to set
98 */
99 public void setHasActions(boolean hasActions) {
100 fieldHasActions = hasActions;
101 }
102
103 /**
104 * Sets the inProlog.
105 *
106 * @param inProlog
107 * The inProlog to set
108 */
109 public void setInProlog(boolean inProlog) {
110 fieldInProlog = inProlog;
111 }
112
113 /**
114 * Sets the isRejected.
115 *
116 * @param isRejected
117 * The isRejected to set
118 */
119 public void setRejected(boolean isRejected) {
120 fieldRejected = isRejected;
121 }
122
123 /**
124 * Returns the implicitKeep.
125 *
126 * @return boolean
127 */
128 public boolean isImplicitKeep() {
129 return fieldImplicitKeep;
130 }
131
132 /**
133 * Sets the implicitKeep.
134 *
135 * @param implicitKeep
136 * The implicitKeep to set
137 */
138 public void setImplicitKeep(boolean implicitKeep) {
139 fieldImplicitKeep = implicitKeep;
140 }
141
142 }