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 java.util.List;
23
24 import org.apache.jsieve.exception.SieveException;
25 import org.apache.jsieve.mail.MailAdapter;
26
27 /**
28 * <p>
29 * A parsed representation of the RFC3028 BNF...
30 * </p>
31 *
32 * <code>commands = *command</code>
33 *
34 */
35 public class Commands implements Executable {
36 /**
37 * A List of children of the receiver
38 */
39 private List<Command> fieldChildren;
40
41 /**
42 * Constructor for Commands.
43 */
44 private Commands() {
45 super();
46 }
47
48 /**
49 * Constructor for Commands.
50 *
51 * @param commands
52 */
53 public Commands(List<Command> commands) {
54 this();
55 setChildren(commands);
56 }
57
58 /**
59 * Returns the commands.
60 *
61 * @return List
62 */
63 public List<Command> getChildren() {
64 return fieldChildren;
65 }
66
67 /**
68 * Sets the commands.
69 *
70 * @param commands
71 * The commands to set
72 */
73 protected void setChildren(List<Command> commands) {
74 fieldChildren = commands;
75 }
76
77 /**
78 * @see org.apache.jsieve.Executable#execute(MailAdapter, SieveContext)
79 */
80 public Object execute(MailAdapter mail, SieveContext context)
81 throws SieveException {
82 for (Command command:fieldChildren) {
83 command.execute(mail, context);
84 };
85 return null;
86 }
87
88 public String toString() {
89 return "COMMANDS: " + fieldChildren;
90 }
91
92 }