Coverage Report - org.mule.config.spring.parsers.generic.DescendentDefinitionParser
 
Classes in this File Line Coverage Branch Coverage Complexity
DescendentDefinitionParser
0%
0/10
0%
0/6
3
 
 1  
 /*
 2  
  * $Id: DescendentDefinitionParser.java 10256 2008-01-08 15:20:25Z 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  
 package org.mule.config.spring.parsers.generic;
 11  
 
 12  
 import org.mule.util.StringUtils;
 13  
 
 14  
 import org.w3c.dom.Element;
 15  
 import org.w3c.dom.Node;
 16  
 
 17  
 /**
 18  
  * An extension to {@line ChildDefinitionParser} which recurses up the DOM
 19  
  * tree until it finds a named parent.
 20  
  */
 21  
 public class DescendentDefinitionParser extends ChildDefinitionParser
 22  
 {
 23  
     public DescendentDefinitionParser(String setterMethod, Class clazz)
 24  
     {
 25  0
         super(setterMethod, clazz);
 26  0
     }
 27  
 
 28  
     protected String getParentBeanName(Element element)
 29  
     {
 30  0
         Node node = element;
 31  0
         while (null != node && node instanceof Element)
 32  
         {
 33  0
             String name = super.getParentBeanName((Element) node);
 34  0
             if (!StringUtils.isBlank(name))
 35  
             {
 36  0
                 return name;
 37  
             }
 38  0
             node = element.getParentNode();
 39  0
         }
 40  0
         throw new IllegalStateException("Bean: " + element.getNodeName() + " has no grandparent");
 41  
     }
 42  
 }