Coverage Report - org.mule.config.spring.parsers.processors.AttributeConcatenation
 
Classes in this File Line Coverage Branch Coverage Complexity
AttributeConcatenation
0%
0/16
0%
0/6
2.5
 
 1  
 /*
 2  
  * $Id: AttributeConcatenation.java 10489 2008-01-23 17:53:38Z dfeist $
 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.config.spring.parsers.processors;
 12  
 
 13  
 import org.mule.config.spring.parsers.PreProcessor;
 14  
 import org.mule.config.spring.parsers.assembly.configuration.PropertyConfiguration;
 15  
 import org.mule.util.StringUtils;
 16  
 
 17  
 import org.w3c.dom.Element;
 18  
 
 19  
 public class AttributeConcatenation implements PreProcessor
 20  
 {
 21  
 
 22  
     private String target;
 23  
     private String separator;
 24  
     private String[] sources;
 25  
 
 26  
     public AttributeConcatenation(String target, String separator, String[] sources)
 27  0
     {
 28  0
         this.target = target;
 29  0
         this.separator = separator;
 30  0
         this.sources = sources;
 31  0
     }
 32  
 
 33  
     public void preProcess(PropertyConfiguration config, Element element)
 34  
     {
 35  0
         StringBuffer concat = new StringBuffer();
 36  0
         boolean first = true;
 37  0
         for (int i = 0; i < sources.length; ++i)
 38  
         {
 39  0
             String value = config.translateValue(sources[i], element.getAttribute(sources[i])).toString();
 40  0
             if (StringUtils.isNotEmpty(value))
 41  
             {
 42  0
                 if (first)
 43  
                 {
 44  0
                     first = false;
 45  
                 }
 46  
                 else
 47  
                 {
 48  0
                     concat.append(separator);
 49  
                 }
 50  0
                 concat.append(value);
 51  
             }
 52  
         }
 53  0
         element.setAttribute(target, concat.toString());
 54  0
     }
 55  
 
 56  
 }