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  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 3  
  * The software in this package is published under the terms of the CPAL v1.0
 4  
  * license, a copy of which has been included with this distribution in the
 5  
  * LICENSE.txt file.
 6  
  */
 7  
 package org.mule.config.spring.parsers.generic;
 8  
 
 9  
 import org.mule.util.StringUtils;
 10  
 
 11  
 import org.w3c.dom.Element;
 12  
 import org.w3c.dom.Node;
 13  
 
 14  
 /**
 15  
  * An extension to {@link ChildDefinitionParser} which recurses up the DOM
 16  
  * tree until it finds a named parent.
 17  
  */
 18  
 public class DescendentDefinitionParser extends ChildDefinitionParser
 19  
 {
 20  
     public DescendentDefinitionParser(String setterMethod, Class clazz)
 21  
     {
 22  0
         super(setterMethod, clazz);
 23  0
     }
 24  
 
 25  
     protected String getParentBeanName(Element element)
 26  
     {
 27  0
         Node node = element;
 28  0
         while (null != node && node instanceof Element)
 29  
         {
 30  0
             String name = super.getParentBeanName((Element) node);
 31  0
             if (!StringUtils.isBlank(name))
 32  
             {
 33  0
                 return name;
 34  
             }
 35  0
             node = element.getParentNode();
 36  0
         }
 37  0
         throw new IllegalStateException("Bean: " + element.getNodeName() + " has no grandparent");
 38  
     }
 39  
 }