Coverage Report - org.mule.transformers.simple.ByteArrayToHexString
 
Classes in this File Line Coverage Branch Coverage Complexity
ByteArrayToHexString
69%
9/13
83%
5/6
2.25
 
 1  
 /*
 2  
  * $Id: ByteArrayToHexString.java 7963 2007-08-21 08:53:15Z 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.StringUtils;
 16  
 
 17  
 /**
 18  
  * Converts a Byte array to a Hex String.
 19  
  */
 20  
 public class ByteArrayToHexString extends AbstractTransformer
 21  
 {
 22  30
     private volatile boolean upperCase = false;
 23  
 
 24  
     public ByteArrayToHexString()
 25  30
     {
 26  34
         registerSourceType(byte[].class);
 27  30
         setReturnClass(String.class);
 28  30
     }
 29  
 
 30  
     public boolean getUpperCase()
 31  
     {
 32  0
         return upperCase;
 33  
     }
 34  
 
 35  
     public void setUpperCase(boolean value)
 36  
     {
 37  4
         upperCase = value;
 38  4
     }
 39  
 
 40  
     protected Object doTransform(Object src, String encoding) throws TransformerException
 41  
     {
 42  18
         if (src == null)
 43  
         {
 44  0
             return StringUtils.EMPTY;
 45  
         }
 46  
 
 47  
         try
 48  
         {
 49  18
             return StringUtils.toHexString((byte[]) src, upperCase);
 50  
         }
 51  0
         catch (Exception ex)
 52  
         {
 53  0
             throw new TransformerException(this, ex);
 54  
         }
 55  
     }
 56  
 
 57  
 }