KickJava   Java API By Example, From Geeks To Geeks.

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


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 package org.mmbase.datatypes.processors;
10
11 import org.mmbase.bridge.*;
12 import org.mmbase.util.transformers.*;
13 import org.mmbase.util.functions.*;
14 import java.io.StringWriter JavaDoc;
15
16 /**
17  * This factory creates processors which don't actually change the value, but only have a
18  * side-effect, namely updating another field with the current time. The other field is on default
19  * 'lastmodified', but it also the only parameter of this processor factory.
20  *
21  * @author Michiel Meeuwissen
22  * @version $Id: LastModifiedProcessorFactory.java,v 1.2 2006/04/18 14:17:24 michiel Exp $
23  * @since MMBase-1.8
24  */

25
26 public class LastModifiedProcessorFactory implements ParameterizedProcessorFactory, java.io.Serializable JavaDoc {
27
28     private static final long serialVersionUID = 1L;
29
30     protected static final Parameter[] PARAMS = new Parameter[] {
31         new Parameter("field", String JavaDoc.class, "lastmodified")
32     };
33
34     /**
35      * Creates a parameterized processor.
36      */

37     public Processor createProcessor(Parameters parameters) {
38         final String JavaDoc destField = (String JavaDoc) parameters.get("field");
39         return new Processor() {
40             private static final long serialVersionUID = 1L;
41
42             public Object JavaDoc process(Node node, Field field, Object JavaDoc value) {
43                 node.setDateValue(destField, new java.util.Date JavaDoc());
44                 return value;
45             }
46         };
47     }
48
49     /**
50      * Create empty <code>Parameters</code> object for use with {@link #createProcessor}.
51      */

52     public Parameters createParameters() {
53         return new Parameters(PARAMS);
54     }
55
56 }
57
Popular Tags