Coverage Report - org.mule.config.spring.parsers.delegate.BooleanAttributeSelectionDefinitionParser
 
Classes in this File Line Coverage Branch Coverage Complexity
BooleanAttributeSelectionDefinitionParser
0%
0/13
0%
0/6
2.5
 
 1  
 /*
 2  
  * $Id: BooleanAttributeSelectionDefinitionParser.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.config.spring.parsers.delegate;
 12  
 
 13  
 import org.mule.config.spring.parsers.MuleDefinitionParser;
 14  
 
 15  
 import org.springframework.beans.factory.xml.ParserContext;
 16  
 import org.w3c.dom.Element;
 17  
 
 18  
 public class BooleanAttributeSelectionDefinitionParser extends AbstractParallelDelegatingDefinitionParser
 19  
 {
 20  
 
 21  
     private String attribute;
 22  
     private boolean dflt;
 23  
     private MuleDefinitionParser whenTrue;
 24  
     private MuleDefinitionParser whenFalse;
 25  
 
 26  
     public BooleanAttributeSelectionDefinitionParser(String attribute, boolean dflt, MuleDefinitionParser whenTrue, MuleDefinitionParser whenFalse)
 27  
     {
 28  0
         super(new MuleDefinitionParser[]{whenTrue, whenFalse});
 29  0
         this.attribute = attribute;
 30  0
         this.dflt = dflt;
 31  0
         this.whenTrue = whenTrue;
 32  0
         this.whenFalse = whenFalse;
 33  0
         addIgnored(attribute);
 34  0
     }
 35  
 
 36  
     protected MuleDefinitionParser getDelegate(Element element, ParserContext parserContext)
 37  
     {
 38  0
         boolean value = dflt;
 39  0
         if (null != element && element.hasAttribute(attribute))
 40  
         {
 41  0
             value = Boolean.valueOf(element.getAttribute(attribute)).booleanValue();
 42  
         }
 43  0
         if (value)
 44  
         {
 45  0
             return whenTrue;
 46  
         }
 47  
         else
 48  
         {
 49  0
             return whenFalse;
 50  
         }
 51  
     }
 52  
 
 53  
 }