KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.mmbase.util.logging.Logger;
14 import org.mmbase.util.logging.Logging;
15
16 /**
17  * If you use this processor for a field, then setting it to an empty value will be ignored (the
18  * previous value will remain intact).
19  *
20  * @author Michiel Meeuwissen
21  * @version $Id: IgnoreEmptyProcessor.java,v 1.1 2006/07/06 14:58:03 michiel Exp $
22  * @since MMBase-1.8.1
23  */

24
25 public class IgnoreEmptyProcessor implements Processor {
26     private static final Logger log = Logging.getLoggerInstance(IgnoreEmptyProcessor.class);
27     private static final long serialVersionUID = 1L;
28
29     public final Object JavaDoc process(Node node, Field field, Object JavaDoc value) {
30         Object JavaDoc prevValue = node.getValue(field.getName());
31         if (value == null || "".equals(value)) {
32             return prevValue;
33         }
34         return value;
35     }
36
37     public String JavaDoc toString() {
38         return "IGNORE";
39     }
40 }
41
42
43
Popular Tags