01: /*
02:
03: This software is OSI Certified Open Source Software.
04: OSI Certified is a certification mark of the Open Source Initiative.
05:
06: The license (Mozilla version 1.0) can be read at the MMBase site.
07: See http://www.MMBase.org/license
08: */
09: package org.mmbase.datatypes.processors;
10:
11: import org.mmbase.bridge.*;
12: import org.mmbase.util.functions.*;
13:
14: /**
15: * This factory creates processors which don't actually change the value, but only have a
16: * side-effect, namely updating another field with the current time. The other field is on default
17: * 'lastmodified', but it also the only parameter of this processor factory.
18: *
19: * @author Michiel Meeuwissen
20: * @version $Id: LastModifiedProcessorFactory.java,v 1.3 2006/10/14 14:35:39 nklasens Exp $
21: * @since MMBase-1.8
22: */
23:
24: public class LastModifiedProcessorFactory implements
25: ParameterizedProcessorFactory, java.io.Serializable {
26:
27: private static final long serialVersionUID = 1L;
28:
29: protected static final Parameter[] PARAMS = new Parameter[] { new Parameter<String>(
30: "field", String.class, "lastmodified") };
31:
32: /**
33: * Creates a parameterized processor.
34: */
35: public Processor createProcessor(Parameters parameters) {
36: final String destField = (String) parameters.get("field");
37: return new Processor() {
38: private static final long serialVersionUID = 1L;
39:
40: public Object process(Node node, Field field, Object value) {
41: node.setDateValue(destField, new java.util.Date());
42: return value;
43: }
44: };
45: }
46:
47: /**
48: * Create empty <code>Parameters</code> object for use with {@link #createProcessor}.
49: */
50: public Parameters createParameters() {
51: return new Parameters(PARAMS);
52: }
53:
54: }
|