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