KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > transformers > xml > DomDocumentToXml


1 /*
2  * $Id: DomDocumentToXml.java 3937 2006-11-20 16:04:25Z lajos $
3  * --------------------------------------------------------------------------------------
4  * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
5  *
6  * The software in this package is published under the terms of the MuleSource MPL
7  * license, a copy of which has been included with this distribution in the
8  * LICENSE.txt file.
9  */

10
11 package org.mule.transformers.xml;
12
13 import org.mule.umo.transformer.TransformerException;
14
15 /**
16  * <code>DomDocumentToXml</code> Transform a org.w3c.dom.Document to XML String
17  */

18 public class DomDocumentToXml extends AbstractXmlTransformer
19 {
20     /**
21      * Serial version
22      */

23     private static final long serialVersionUID = -6452312203102491187L;
24
25     public DomDocumentToXml()
26     {
27         setReturnClass(String JavaDoc.class);
28     }
29
30     public Object JavaDoc doTransform(Object JavaDoc src, String JavaDoc encoding) throws TransformerException
31     {
32         try
33         {
34             // We now offer XML in byte OR String form.
35
// String remains the default like before.
36
if (byte[].class.equals(returnClass))
37                 return convertToBytes(src, encoding);
38             else
39                 return convertToText(src);
40         }
41         catch (Exception JavaDoc e)
42         {
43             throw new TransformerException(this, e);
44         }
45     }
46
47 }
48
Popular Tags