Coverage Report - org.mule.transformers.simple.HexStringToByteArray
 
Classes in this File Line Coverage Branch Coverage Complexity
HexStringToByteArray
0%
0/9
0%
0/3
3.5
 
 1  
 /*
 2  
  * $Id: HexStringToByteArray.java 7976 2007-08-21 14:26:13Z dirk.olmes $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 9  
  */
 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.ArrayUtils;
 16  
 import org.mule.util.StringUtils;
 17  
 
 18  
 /**
 19  
  * Converts a Hex String to a Byte array
 20  
  */
 21  
 public class HexStringToByteArray extends AbstractTransformer
 22  
 {
 23  
 
 24  
     public HexStringToByteArray()
 25  0
     {
 26  0
         registerSourceType(String.class);
 27  0
         setReturnClass(byte[].class);
 28  0
     }
 29  
 
 30  
     protected Object doTransform(Object src, String encoding) throws TransformerException
 31  
     {
 32  0
         if (src == null)
 33  
         {
 34  0
             return ArrayUtils.EMPTY_BYTE_ARRAY;
 35  
         }
 36  
 
 37  
         try
 38  
         {
 39  0
             return StringUtils.hexStringToByteArray((String) src);
 40  
         }
 41  0
         catch (Exception ex)
 42  
         {
 43  0
             throw new TransformerException(this, ex);
 44  
         }
 45  
     }
 46  
 
 47  
 }