Coverage Report - org.mule.module.xml.transformer.DomDocumentToXml
 
Classes in this File Line Coverage Branch Coverage Complexity
DomDocumentToXml
0%
0/13
0%
0/2
0
 
 1  
 /*
 2  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 3  
  * The software in this package is published under the terms of the CPAL v1.0
 4  
  * license, a copy of which has been included with this distribution in the
 5  
  * LICENSE.txt file.
 6  
  */
 7  
 package org.mule.module.xml.transformer;
 8  
 
 9  
 import org.mule.api.MuleMessage;
 10  
 import org.mule.api.transformer.DiscoverableTransformer;
 11  
 import org.mule.api.transformer.TransformerException;
 12  
 import org.mule.transformer.types.DataTypeFactory;
 13  
 
 14  
 /**
 15  
  * <code>DomDocumentToXml</code> Transform a org.w3c.dom.Document to XML String
 16  
  */
 17  
 public class DomDocumentToXml extends AbstractXmlTransformer implements DiscoverableTransformer
 18  
 {
 19  0
     private int priorityWeighting = DiscoverableTransformer.DEFAULT_PRIORITY_WEIGHTING;
 20  
 
 21  
     public DomDocumentToXml()
 22  0
     {
 23  0
         setReturnDataType(DataTypeFactory.XML_STRING);
 24  0
     }
 25  
 
 26  
     @Override
 27  
     public Object transformMessage(MuleMessage message, String encoding) throws TransformerException
 28  
     {
 29  0
         Object src = message.getPayload();
 30  
         try
 31  
         {
 32  
             // We now offer XML in byte OR String form.
 33  
             // String remains the default like before.
 34  0
             if (byte[].class.equals(returnType))
 35  
             {
 36  0
                 return convertToBytes(src, encoding);
 37  
             }
 38  
             else
 39  
             {
 40  0
                 return convertToText(src, encoding);
 41  
             }
 42  
         }
 43  0
         catch (Exception e)
 44  
         {
 45  0
             throw new TransformerException(this, e);
 46  
         }
 47  
     }
 48  
 
 49  
     public int getPriorityWeighting()
 50  
     {
 51  0
         return priorityWeighting;
 52  
     }
 53  
 
 54  
     public void setPriorityWeighting(int priorityWeighting)
 55  
     {
 56  0
         this.priorityWeighting = priorityWeighting;
 57  0
     }
 58  
 }