KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > datatypes > processors > xml > FieldSetString


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.xml;
11 import org.mmbase.datatypes.processors.Processor;
12 import org.mmbase.bridge.*;
13 import org.mmbase.util.logging.*;
14 import org.mmbase.util.*;
15
16 /**
17  * This class implements the `get' for XML field with specialization 'field'. They look like ASCII,
18  * if accessed by setString, getString.
19  *
20  * This can be used if the XML features of a certain field are only used in certain extensions only,
21  * but must look like String in the base class. So, it allows you to have the db-type XML without
22  * noticing it too much.
23  *
24  * @author Michiel Meeuwissen
25  * @version $Id: FieldSetString.java,v 1.2 2005/12/10 14:33:36 michiel Exp $
26  * @since MMBase-1.8
27  */

28
29 public class FieldSetString implements Processor {
30     private static final Logger log = Logging.getLoggerInstance(FieldSetString.class);
31     private static final long serialVersionUID = 1L;
32
33     protected static final String JavaDoc PREF = "<field><![CDATA[";
34     protected static final String JavaDoc POST = "]]></field>";
35     public Object JavaDoc process(Node node, Field field, Object JavaDoc value) {
36         if (value instanceof org.w3c.dom.Document JavaDoc) return value;
37         log.debug("Getting " + field + " from " + node + " as a String");
38         return Casting.toXML(PREF + Casting.toString(value) + POST);
39     }
40
41 }
42
Popular Tags