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  
  * $Id: DomDocumentToXml.java 19191 2010-08-25 21:05:23Z tcarlson $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.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.MuleMessage;
 14  
 import org.mule.api.transformer.DiscoverableTransformer;
 15  
 import org.mule.api.transformer.TransformerException;
 16  
 import org.mule.transformer.types.DataTypeFactory;
 17  
 
 18  
 /**
 19  
  * <code>DomDocumentToXml</code> Transform a org.w3c.dom.Document to XML String
 20  
  */
 21  
 public class DomDocumentToXml extends AbstractXmlTransformer implements DiscoverableTransformer
 22  
 {
 23  0
     private int priorityWeighting = DiscoverableTransformer.DEFAULT_PRIORITY_WEIGHTING;
 24  
 
 25  
     public DomDocumentToXml()
 26  0
     {
 27  0
         setReturnDataType(DataTypeFactory.XML_STRING);
 28  0
     }
 29  
 
 30  
     @Override
 31  
     public Object transformMessage(MuleMessage message, String encoding) throws TransformerException
 32  
     {
 33  0
         Object src = message.getPayload();
 34  
         try
 35  
         {
 36  
             // We now offer XML in byte OR String form.
 37  
             // String remains the default like before.
 38  0
             if (byte[].class.equals(returnType))
 39  
             {
 40  0
                 return convertToBytes(src, encoding);
 41  
             }
 42  
             else
 43  
             {
 44  0
                 return convertToText(src, encoding);
 45  
             }
 46  
         }
 47  0
         catch (Exception e)
 48  
         {
 49  0
             throw new TransformerException(this, e);
 50  
         }
 51  
     }
 52  
 
 53  
     public int getPriorityWeighting()
 54  
     {
 55  0
         return priorityWeighting;
 56  
     }
 57  
 
 58  
     public void setPriorityWeighting(int priorityWeighting)
 59  
     {
 60  0
         this.priorityWeighting = priorityWeighting;
 61  0
     }
 62  
 }