Coverage Report - org.mule.transformer.simple.HexStringToByteArray
 
Classes in this File Line Coverage Branch Coverage Complexity
HexStringToByteArray
0%
0/9
0%
0/2
0
 
 1  
 /*
 2  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 3  
  * The software in this package is published under the terms of the CPAL v1.0
 4  
  * license, a copy of which has been included with this distribution in the
 5  
  * LICENSE.txt file.
 6  
  */
 7  
 package org.mule.transformer.simple;
 8  
 
 9  
 import org.mule.api.transformer.TransformerException;
 10  
 import org.mule.transformer.AbstractTransformer;
 11  
 import org.mule.transformer.types.DataTypeFactory;
 12  
 import org.mule.util.ArrayUtils;
 13  
 import org.mule.util.StringUtils;
 14  
 
 15  
 /**
 16  
  * Converts a Hex String to a Byte array
 17  
  */
 18  
 public class HexStringToByteArray extends AbstractTransformer
 19  
 {
 20  
     public HexStringToByteArray()
 21  0
     {
 22  0
         registerSourceType(DataTypeFactory.STRING);
 23  0
         setReturnDataType(DataTypeFactory.BYTE_ARRAY);
 24  0
     }
 25  
 
 26  
     @Override
 27  
     protected Object doTransform(Object src, String outputEncoding) throws TransformerException
 28  
     {
 29  0
         if (src == null)
 30  
         {
 31  0
             return ArrayUtils.EMPTY_BYTE_ARRAY;
 32  
         }
 33  
 
 34  
         try
 35  
         {
 36  0
             return StringUtils.hexStringToByteArray((String) src);
 37  
         }
 38  0
         catch (Exception ex)
 39  
         {
 40  0
             throw new TransformerException(this, ex);
 41  
         }
 42  
     }
 43  
 
 44  
 }