KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > datatypes > processors > ChainedProcessor


1 /*
2
3 This software is OSI Certified Open Source Software.
4 OSI Certified is a certification mark of the Open Source Initiative.
5
6 The license (Mozilla version 1.0) can be read at the MMBase site.
7 See http://www.MMBase.org/license
8
9 */

10 package org.mmbase.datatypes.processors;
11
12 import org.mmbase.bridge.*;
13 import java.util.*;
14
15 /**
16  * Chains a bunch of other processors into one new processor.
17  *
18  * @author Michiel Meeuwissen
19  * @version $Id: ChainedProcessor.java,v 1.3 2005/12/10 14:33:36 michiel Exp $
20  * @since MMBase-1.7
21  */

22
23 public class ChainedProcessor implements Processor {
24
25     private static final long serialVersionUID = 1L;
26
27     private List processors = new ArrayList();
28
29     public ChainedProcessor add(Processor proc) {
30         processors.add(proc);
31         return this;
32     }
33
34     public Object JavaDoc process(Node node, Field field, Object JavaDoc value) {
35
36         Iterator i = processors.iterator();
37         while (i.hasNext()) {
38             Processor proc = (Processor) i.next();
39             value = proc.process(node, field, value);
40         }
41         return value;
42     }
43
44     public String JavaDoc toString() {
45         return "chained" + processors;
46     }
47
48
49
50 }
51
Popular Tags