Coverage Report - org.mule.module.xml.transformer.DomDocumentToXml
 
Classes in this File Line Coverage Branch Coverage Complexity
DomDocumentToXml
58%
7/12
50%
1/2
2.25
 
 1  
 /*
 2  
  * $Id: DomDocumentToXml.java 11236 2008-03-06 23:48:23Z tcarlson $
 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.module.xml.transformer;
 12  
 
 13  
 import org.mule.api.transformer.DiscoverableTransformer;
 14  
 import org.mule.api.transformer.TransformerException;
 15  
 
 16  
 /** <code>DomDocumentToXml</code> Transform a org.w3c.dom.Document to XML String */
 17  
 public class DomDocumentToXml extends AbstractXmlTransformer implements DiscoverableTransformer
 18  
 {
 19  292
     private int priorityWeighting = DiscoverableTransformer.DEFAULT_PRIORITY_WEIGHTING;
 20  
 
 21  
     public DomDocumentToXml()
 22  292
     {
 23  292
         setReturnClass(String.class);
 24  292
     }
 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  
             {
 34  0
                 return convertToBytes(src, encoding);
 35  
             }
 36  
             else
 37  
             {
 38  12
                 return convertToText(src, encoding);
 39  
             }
 40  
         }
 41  0
         catch (Exception e)
 42  
         {
 43  0
             throw new TransformerException(this, e);
 44  
         }
 45  
     }
 46  
 
 47  
     public int getPriorityWeighting()
 48  
     {
 49  2
         return priorityWeighting;
 50  
     }
 51  
 
 52  
     public void setPriorityWeighting(int priorityWeighting)
 53  
     {
 54  0
         this.priorityWeighting = priorityWeighting;
 55  0
     }
 56  
 }