Coverage Report - org.mule.transformers.xml.DomDocumentToXml
 
Classes in this File Line Coverage Branch Coverage Complexity
DomDocumentToXml
62%
5/8
83%
5/6
3.5
 
 1  
 /*
 2  
  * $Id: DomDocumentToXml.java 7963 2007-08-21 08:53:15Z dirk.olmes $
 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 CPAL v1.0
 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  
     public DomDocumentToXml()
 22  60
     {
 23  64
         setReturnClass(String.class);
 24  60
     }
 25  
 
 26  
     public Object doTransform(Object src, String encoding) throws TransformerException
 27  
     {
 28  
         try
 29  
         {
 30  
             // We now offer XML in byte OR String form.
 31  
             // String remains the default like before.
 32  12
             if (byte[].class.equals(returnClass))
 33  0
                 return convertToBytes(src, encoding);
 34  
             else
 35  12
                 return convertToText(src, encoding);
 36  
         }
 37  0
         catch (Exception e)
 38  
         {
 39  0
             throw new TransformerException(this, e);
 40  
         }
 41  
     }
 42  
 
 43  
 }