Coverage Report - org.mule.config.spring.parsers.generic.GrandchildDefinitionParser
 
Classes in this File Line Coverage Branch Coverage Complexity
GrandchildDefinitionParser
0%
0/18
0%
0/6
2.5
 
 1  
 /*
 2  
  * $Id: GrandchildDefinitionParser.java 11776 2008-05-15 18:58:08Z tcarlson $
 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.w3c.dom.Element;
 13  
 import org.w3c.dom.Node;
 14  
 
 15  
 /**
 16  
  * Same as ChildDefinitionParser but injects the child element into the grandparent object 
 17  
  * (2 levels up in the XML tree).
 18  
  */
 19  
 public class GrandchildDefinitionParser extends ChildDefinitionParser
 20  
 {
 21  
     public GrandchildDefinitionParser(String setterMethod, Class clazz)
 22  
     {
 23  0
         super(setterMethod, clazz);
 24  0
     }
 25  
 
 26  
     public GrandchildDefinitionParser(String setterMethod, Class clazz, Class constraint, boolean allowClassAttribute)
 27  
     {
 28  0
         super(setterMethod, clazz, constraint, allowClassAttribute);
 29  0
     }
 30  
 
 31  
     //@Override
 32  
     protected String getParentBeanName(Element element)
 33  
     {
 34  0
         return getGrandparentBeanName(element);
 35  
     }
 36  
 
 37  
     protected String getGrandparentBeanName(Element element)
 38  
     {
 39  0
         Node parent = element.getParentNode();
 40  0
         if (parent == null)
 41  
         {
 42  0
             logger.error("No parent node found for element " + element);
 43  0
             return null;
 44  
         }
 45  0
         Node grandparent = parent.getParentNode();
 46  0
         if (grandparent == null)
 47  
         {
 48  0
             logger.error("No parent node found for element " + parent);
 49  0
             return null;
 50  
         }
 51  0
         Node grandparentNameAttribute = grandparent.getAttributes().getNamedItem("name");
 52  0
         if (grandparentNameAttribute == null)
 53  
         {
 54  0
             logger.error("Grandparent node has no 'name' attribute: " + grandparent);
 55  0
             return null;
 56  
         }
 57  0
         return grandparentNameAttribute.getNodeValue();
 58  
     }
 59  
 }