1 10 11 package org.mule.transformers.simple; 12 13 import java.io.ObjectStreamConstants ; 14 15 import org.mule.umo.transformer.TransformerException; 16 17 25 public class ByteArrayToObject extends ByteArrayToSerializable 26 { 27 28 31 private static final long serialVersionUID = 2105641786358330597L; 32 33 public Object doTransform(Object src, String encoding) throws TransformerException 34 { 35 36 byte[] bytes = (byte[])src; 37 if (bytes[0] == (byte)((ObjectStreamConstants.STREAM_MAGIC >>> 8) & 0xFF)) 38 { 39 return super.doTransform(src, encoding); 40 } 41 else 42 { 43 try 44 { 45 return new String (bytes, encoding); 46 } 47 catch (Exception e) 48 { 49 throw new TransformerException(this, e); 50 } 51 } 52 } 53 54 } 55 | Popular Tags |