1 10 11 package org.mule.transformers.simple; 12 13 import org.mule.umo.UMOEventContext; 14 import org.mule.umo.transformer.TransformerException; 15 16 23 public class ObjectToByteArray extends SerializableToByteArray 24 { 25 26 29 private static final long serialVersionUID = 8111970112989435191L; 30 31 public ObjectToByteArray() 32 { 33 registerSourceType(Object .class); 34 } 35 36 public Object transform(Object src, String encoding, UMOEventContext context) throws TransformerException 37 { 38 if (src instanceof String ) 39 { 40 try 41 { 42 return src.toString().getBytes(encoding); 43 } 44 catch (Exception e) 45 { 46 throw new TransformerException(this, e); 47 } 48 } 49 else 50 { 51 return super.transform(src, encoding, context); 52 } 53 } 54 55 } 56 | Popular Tags |