Coverage Report - org.mule.config.spring.util.SpringXMLUtils
 
Classes in this File Line Coverage Branch Coverage Complexity
SpringXMLUtils
0%
0/15
0%
0/16
2.667
 
 1  
 /*
 2  
  * $Id: SpringXMLUtils.java 19191 2010-08-25 21:05:23Z tcarlson $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.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.util;
 12  
 
 13  
 import org.mule.config.spring.parsers.AbstractMuleBeanDefinitionParser;
 14  
 import org.mule.util.StringUtils;
 15  
 import org.mule.util.XMLUtils;
 16  
 
 17  
 import org.apache.commons.logging.Log;
 18  
 import org.apache.commons.logging.LogFactory;
 19  
 import org.springframework.beans.factory.xml.BeanDefinitionParserDelegate;
 20  
 import org.w3c.dom.Element;
 21  
 
 22  
 /**
 23  
  * These only depend on standard (JSE) XML classes and are used by Spring config code.
 24  
  * For a more extensive (sub-)class, see the XMLUtils class in the XML module.
 25  
  */
 26  0
 public class SpringXMLUtils extends XMLUtils
 27  
 {
 28  
 
 29  0
     private static final Log logger = LogFactory.getLog(SpringXMLUtils.class);
 30  
 
 31  
     public static final String MULE_DEFAULT_NAMESPACE = "http://www.mulesoft.org/schema/mule/core";
 32  
     public static final String MULE_NAMESPACE_PREFIX = "http://www.mulesoft.org/schema/mule/";
 33  
 
 34  
     public static boolean isMuleNamespace(Element element)
 35  
     {
 36  0
         String ns = element.getNamespaceURI();
 37  0
         return ns != null && ns.startsWith(MULE_NAMESPACE_PREFIX);
 38  
     }
 39  
 
 40  
     public static boolean isBeansNamespace(Element element)
 41  
     {
 42  0
         String ns = element.getNamespaceURI();
 43  0
         return ns != null && ns.equals(BeanDefinitionParserDelegate.BEANS_NAMESPACE_URI);
 44  
     }
 45  
 
 46  
     public static String getNameOrId(Element element)
 47  
     {
 48  0
         String id = element.getAttribute(AbstractMuleBeanDefinitionParser.ATTRIBUTE_ID);
 49  0
         String name = element.getAttribute(AbstractMuleBeanDefinitionParser.ATTRIBUTE_NAME);
 50  0
         if (StringUtils.isBlank(id))
 51  
         {
 52  0
             if (StringUtils.isBlank(name))
 53  
             {
 54  0
                 return "";
 55  
             }
 56  
             else
 57  
             {
 58  0
                 return name;
 59  
             }
 60  
         }
 61  
         else
 62  
         {
 63  0
             if (!StringUtils.isBlank(name) && !name.equals(id))
 64  
             {
 65  0
                 logger.warn("Id (" + id + ") and name (" + name + ") differ for " + elementToString(element));
 66  
             }
 67  0
             return id;
 68  
         }
 69  
     }
 70  
 
 71  
 }