01: package de.schlund.pfixcore.oxm.impl.serializers;
02:
03: import de.schlund.pfixcore.oxm.impl.ComplexTypeSerializer;
04: import de.schlund.pfixcore.oxm.impl.SerializationContext;
05: import de.schlund.pfixcore.oxm.impl.SerializationException;
06: import de.schlund.pfixcore.oxm.impl.XMLWriter;
07:
08: /**
09: * CDataSerializer
10: *
11: * Writes a string as character data section
12: * to the document.
13: *
14: * @author Stephan Schmidt <schst@stubbles.net>
15: */
16: public class CDataSerializer implements ComplexTypeSerializer {
17:
18: public CDataSerializer() {
19: }
20:
21: public void serialize(Object obj, SerializationContext context,
22: XMLWriter writer) throws SerializationException {
23: if (!(obj instanceof String)) {
24: throw new SerializationException("Type not supported: "
25: + obj.getClass().getName());
26: }
27: String cdata = (String) obj;
28: writer.writeCDataSection(cdata);
29: }
30: }
|