1 10 11 package org.mule.transformers.simple; 12 13 import org.mule.transformers.AbstractTransformer; 14 import org.mule.umo.transformer.TransformerException; 15 import org.mule.util.StringUtils; 16 17 23 public class ByteArrayToHexString extends AbstractTransformer 24 { 25 26 29 private static final long serialVersionUID = -7444711426569720031L; 30 31 private volatile boolean upperCase = false; 32 33 public ByteArrayToHexString() 34 { 35 registerSourceType(byte[].class); 36 setReturnClass(String .class); 37 } 38 39 public boolean getUpperCase() 40 { 41 return upperCase; 42 } 43 44 public void setUpperCase(boolean value) 45 { 46 upperCase = value; 47 } 48 49 protected Object doTransform(Object src, String encoding) throws TransformerException 50 { 51 if (src == null) 52 { 53 return StringUtils.EMPTY; 54 } 55 56 try 57 { 58 return StringUtils.toHexString((byte[])src, upperCase); 59 } 60 catch (Exception ex) 61 { 62 throw new TransformerException(this, ex); 63 } 64 } 65 66 } 67 | Popular Tags |