Coverage Report - org.mule.config.spring.parsers.collection.ChildListEntryDefinitionParser
 
Classes in this File Line Coverage Branch Coverage Complexity
ChildListEntryDefinitionParser
0%
0/15
0%
0/2
1.125
ChildListEntryDefinitionParser$ListEntry
0%
0/8
N/A
1.125
 
 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.collection;
 8  
 
 9  
 import org.mule.config.spring.parsers.assembly.BeanAssembler;
 10  
 import org.mule.config.spring.parsers.generic.ChildDefinitionParser;
 11  
 import org.mule.config.spring.util.SpringXMLUtils;
 12  
 
 13  
 import org.springframework.beans.factory.support.BeanDefinitionBuilder;
 14  
 import org.springframework.beans.factory.xml.ParserContext;
 15  
 import org.w3c.dom.Element;
 16  
 
 17  
 
 18  
 /**
 19  
  * Process an element as a value that is appended to a list in the parent object (the
 20  
  * enclosing XML element).
 21  
  */
 22  
 public class ChildListEntryDefinitionParser extends ChildDefinitionParser
 23  
 {
 24  
 
 25  
     public static final String VALUE = "value";
 26  0
     private boolean fromText = true;
 27  
 
 28  
     /**
 29  
      * Takes value from enclosed text
 30  
      *
 31  
      * @param propertyName
 32  
      */
 33  
     public ChildListEntryDefinitionParser(String propertyName)
 34  
     {
 35  0
         super(propertyName, ListEntry.class);
 36  0
         setIgnoredDefault(true);
 37  0
     }
 38  
 
 39  
     /**
 40  
      * Takes value from attribute
 41  
      *
 42  
      * @param propertyName
 43  
      * @param attributeName
 44  
      */
 45  
     public ChildListEntryDefinitionParser(String propertyName, String attributeName)
 46  
     {
 47  0
         this(propertyName);
 48  0
         addAlias(attributeName, VALUE);
 49  0
         removeIgnored(attributeName);
 50  0
         fromText = false;
 51  0
     }
 52  
 
 53  
     protected void postProcess(ParserContext context, BeanAssembler assembler, Element element)
 54  
     {
 55  0
         if (fromText)
 56  
         {
 57  0
             assembler.extendBean(VALUE, SpringXMLUtils.getTextChild(element), false);
 58  
         }
 59  0
         super.postProcess(context, assembler, element);
 60  0
     }
 61  
 
 62  
     protected void parseChild(Element element, ParserContext parserContext, BeanDefinitionBuilder builder)
 63  
     {
 64  0
         super.parseChild(element, parserContext, builder);    //To change body of overridden methods use File | Settings | File Templates.
 65  0
     }
 66  
 
 67  
     public static class ListEntry
 68  
     {
 69  
 
 70  
         private Object value;
 71  
 
 72  
         public ListEntry()
 73  
         {
 74  0
             super();
 75  0
         }
 76  
         
 77  
         public ListEntry(Object proxied)
 78  
         {
 79  0
             this();
 80  0
             value = proxied;
 81  0
         }
 82  
 
 83  
         public Object getValue()
 84  
         {
 85  0
             return value;
 86  
         }
 87  
 
 88  
         public void setValue(Object value)
 89  
         {
 90  0
             this.value = value;
 91  0
         }   
 92  
     }
 93  
 
 94  
 }