1 10 11 package org.mule.transformers.simple; 12 13 import org.apache.commons.lang.ArrayUtils; 14 import org.mule.transformers.AbstractTransformer; 15 import org.mule.umo.transformer.TransformerException; 16 import org.mule.util.StringUtils; 17 18 24 public class HexStringToByteArray extends AbstractTransformer 25 { 26 27 30 private static final long serialVersionUID = 8266145248111508046L; 31 32 public HexStringToByteArray() 33 { 34 registerSourceType(String .class); 35 setReturnClass(byte[].class); 36 } 37 38 protected Object doTransform(Object src, String encoding) throws TransformerException 39 { 40 if (src == null) 41 { 42 return ArrayUtils.EMPTY_BYTE_ARRAY; 43 } 44 45 try 46 { 47 return StringUtils.hexStringToByteArray((String )src); 48 } 49 catch (Exception ex) 50 { 51 throw new TransformerException(this, ex); 52 } 53 } 54 55 } 56 | Popular Tags |