1
2
3
4
5
6
7
8
9
10
11 package org.mule.transformers.simple;
12
13 import org.mule.umo.transformer.TransformerException;
14
15 import java.io.ObjectStreamConstants;
16
17
18
19
20
21
22
23 public class ByteArrayToObject extends ByteArrayToSerializable
24 {
25
26
27 public Object doTransform(Object src, String encoding) throws TransformerException
28 {
29 byte[] bytes = (byte[]) src;
30
31 if (bytes[0] == (byte) ((ObjectStreamConstants.STREAM_MAGIC >>> 8) & 0xFF))
32 {
33 return super.doTransform(src, encoding);
34 }
35 else
36 {
37 try
38 {
39 return new String(bytes, encoding);
40 }
41 catch (Exception e)
42 {
43 throw new TransformerException(this, e);
44 }
45 }
46 }
47
48 }