Coverage Report - org.mule.transformers.simple.ObjectArrayToString
 
Classes in this File Line Coverage Branch Coverage Complexity
ObjectArrayToString
0%
0/14
0%
0/4
2
 
 1  
 /*
 2  
  * $Id: ObjectArrayToString.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.StringUtils;
 16  
 
 17  
 /**
 18  
  * <code>ObjectArrayToString</code> transformer is the opposite of 
 19  
  * StringToObjectArray - it simply converts Object[] to a String in which each
 20  
  * element is separated by a configurable delimiter (default is a space).
 21  
  */
 22  
 
 23  
 public class ObjectArrayToString extends AbstractTransformer
 24  
 {
 25  0
     private String delimiter = null;
 26  
     private static final String DEFAULT_DELIMITER = " ";
 27  
 
 28  
     public ObjectArrayToString()
 29  0
     {
 30  0
         registerSourceType(Object[].class);
 31  0
         setReturnClass(String.class);
 32  0
     }
 33  
 
 34  
     public Object doTransform(Object src, String encoding) throws TransformerException
 35  
     {
 36  0
         if (src == null) return src;
 37  
 
 38  0
         Object[] in = (Object[])src;
 39  0
         String out = StringUtils.join(in, getDelimiter());
 40  
 
 41  
         /*
 42  
         for (int i = 0; i < in.length; i++)
 43  
         {
 44  
             if (in[i] != null)
 45  
             {
 46  
                 if (i > 0) out += getDelimiter();
 47  
                 out += in[i].toString();
 48  
             }
 49  
         }
 50  
         */
 51  
 
 52  0
         return out;
 53  
     }
 54  
 
 55  
     /**
 56  
      * @return the delimiter
 57  
      */
 58  
     public String getDelimiter()
 59  
     {
 60  0
         if (delimiter == null)
 61  0
             return DEFAULT_DELIMITER;
 62  
         else
 63  0
             return delimiter;
 64  
     }
 65  
 
 66  
     /**
 67  
      * @param sets the delimiter
 68  
      */
 69  
     public void setDelimiter(String delimiter)
 70  
     {
 71  0
         this.delimiter = delimiter;
 72  0
     }
 73  
         
 74  
 }