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