01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.cocoon.mail.command;
18:
19: import java.util.ArrayList;
20: import java.util.Iterator;
21: import java.util.List;
22: import javax.mail.MessagingException;
23: import org.apache.avalon.framework.logger.AbstractLogEnabled;
24:
25: /**
26: * An abstract MailCommand template
27: *
28: * @author Bernhard Huber
29: * @since 23 October 2002
30: * @version $Id: AbstractMailCommand.java 468424 2006-10-27 15:44:53Z vgritsenko $
31: */
32: public abstract class AbstractMailCommand extends AbstractLogEnabled
33: implements MailCommand {
34:
35: /**
36: * List of result objects
37: */
38: private List result;
39:
40: /**
41: * Constructor for the AbstractMailCommand object
42: */
43: public AbstractMailCommand() {
44: result = new ArrayList();
45: }
46:
47: /**
48: * Gets the results attribute of the AbstractMailCommand object
49: *
50: *@return The results value
51: */
52: public List getResults() {
53: return result;
54: }
55:
56: /**
57: * Adds a result to the Result attribute of the AbstractMailCommand object
58: *
59: *@param o The result to be added to the Result attribute
60: */
61: public void addResult(Object o) {
62: result.add(o);
63: }
64:
65: /**
66: * Adds a list of results to the Results attribute of the AbstractMailCommand object
67: *
68: *@param list The list of results to be added to the Results attribute
69: */
70: public void addResults(List list) {
71: result.addAll(list);
72: }
73:
74: /**
75: * Return an iterator over the results
76: *
77: *@return result iterator
78: */
79: public Iterator iterator() {
80: return result.iterator();
81: }
82:
83: /**
84: * Execute this command
85: *
86: *@exception MessagingException thrown if executing of this MailCommand fails
87: */
88: public abstract void execute() throws MessagingException;
89: }
|