Coverage Report - org.mule.transformer.simple.GetBeanProperty
 
Classes in this File Line Coverage Branch Coverage Complexity
GetBeanProperty
0%
0/10
N/A
1.75
 
 1  
 /*
 2  
  * $Id: GetBeanProperty.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.transformer.simple;
 12  
 
 13  
 import org.mule.api.transformer.TransformerException;
 14  
 import org.mule.transformer.AbstractTransformer;
 15  
 
 16  
 import org.apache.commons.beanutils.PropertyUtils;
 17  
 
 18  
 /**
 19  
  * Looks up a property from a JavaBean using PropertyUtils.getProperty().
 20  
  * Nested properties are valid, assuming they follow JavaBean conventions.
 21  
  * 
 22  
  *   <transformer name="ExtractCustomer" className="org.mule.transformer.simple.GetBeanProperty">
 23  
  *       <properties>
 24  
  *           <property name="propertyName" value="customerRequest.customer" />
 25  
  *       </properties>
 26  
  *   </transformer>
 27  
  */
 28  
 public class GetBeanProperty extends AbstractTransformer
 29  
 {
 30  
     private String propertyName;
 31  
     
 32  
     public GetBeanProperty()
 33  
     {
 34  0
         super();
 35  0
         registerSourceType(Object.class);
 36  0
         setReturnClass(Object.class);
 37  0
     }
 38  
 
 39  
     public Object doTransform(Object src, String encoding) throws TransformerException
 40  
     {
 41  
         try
 42  
         {
 43  0
             return PropertyUtils.getProperty(src, this.propertyName);
 44  
         }
 45  0
         catch (Exception e)
 46  
         {
 47  0
             throw new TransformerException(this, e);
 48  
         }
 49  
     }
 50  
 
 51  
     public String getPropertyName()
 52  
     {
 53  0
         return propertyName;
 54  
     }
 55  
 
 56  
     public void setPropertyName(String propertyName)
 57  
     {
 58  0
         this.propertyName = propertyName;
 59  0
     }
 60  
 
 61  
 }