1
2
3
4
5
6
7
8
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
17 public class DomDocumentToXml extends AbstractXmlTransformer implements DiscoverableTransformer
18 {
19 private int priorityWeighting = DiscoverableTransformer.DEFAULT_PRIORITY_WEIGHTING;
20
21 public DomDocumentToXml()
22 {
23 setReturnClass(String.class);
24 }
25
26 public Object doTransform(Object src, String encoding) throws TransformerException
27 {
28 try
29 {
30
31
32 if (byte[].class.equals(returnClass))
33 {
34 return convertToBytes(src, encoding);
35 }
36 else
37 {
38 return convertToText(src, encoding);
39 }
40 }
41 catch (Exception e)
42 {
43 throw new TransformerException(this, e);
44 }
45 }
46
47 public int getPriorityWeighting()
48 {
49 return priorityWeighting;
50 }
51
52 public void setPriorityWeighting(int priorityWeighting)
53 {
54 this.priorityWeighting = priorityWeighting;
55 }
56 }