KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portal > common > command > filter > CompositeFilter


1 /*****************************************
2  * *
3  * JBoss Portal: The OpenSource Portal *
4  * *
5  * Forums JBoss Portlet *
6  * *
7  * Distributable under LGPL license. *
8  * See terms of license at gnu.org. *
9  * *
10  *****************************************/

11 package org.jboss.portal.common.command.filter;
12
13 import org.jboss.portal.common.command.Command;
14 import org.jboss.portal.common.command.CompositeCommand;
15 import org.jboss.portal.common.command.CommandException;
16 import org.jboss.portal.common.command.result.CompositeResult;
17 import org.jboss.portal.common.command.result.Result;
18
19 import java.util.Iterator JavaDoc;
20
21 /**
22  * @author <a HREF="mailto:julien@jboss.org">Julien Viet</a>
23  * @version $Revision: 1.1 $
24  */

25 public class CompositeFilter extends AbstractCommandFilter
26 {
27    public Result filter(Command cmd) throws CommandException
28    {
29       if (cmd instanceof CompositeCommand)
30       {
31          CompositeResult result = new CompositeResult();
32          Iterator JavaDoc iterator = ((CompositeCommand)cmd).iterator();
33          while (iterator.hasNext())
34          {
35             result.addResult(getNext().filter((Command)iterator.next()));
36          }
37          return result;
38       }
39       else
40       {
41          return getNext().filter(cmd);
42       }
43    }
44 }
45
Popular Tags