View Javadoc

1   /*
2    * $Id: ListPropertyDefinitionParser.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.parsers.specific.properties;
12  
13  import org.mule.config.spring.parsers.assembly.MapEntryCombiner;
14  import org.mule.config.spring.parsers.generic.ParentDefinitionParser;
15  
16  import org.w3c.dom.Element;
17  
18  /**
19   * This allows a child element to extends a list of values, via an attribute, on a parent setter.
20   * Typically it is used with
21   * {@link org.mule.config.spring.parsers.specific.properties.ElementInNestedMapDefinitionParser}
22   * whose setter is {@link org.mule.config.spring.parsers.assembly.MapEntryCombiner#VALUE}.
23   */
24  public class ListPropertyDefinitionParser extends ParentDefinitionParser
25  {
26  
27      public ListPropertyDefinitionParser(String attribute)
28      {
29          this(MapEntryCombiner.VALUE, attribute);
30      }
31  
32      /**
33       * This method is to explain how things work.  If you need to call it, then you also need to replace
34       * override the class ({#link #getBeanClass}).
35       *
36       * @param setter
37       * @param attribute
38       */
39      protected ListPropertyDefinitionParser(String setter, String attribute)
40      {
41          setIgnoredDefault(true);
42          removeIgnored(attribute);
43          addCollection(attribute);
44          if (!setter.equals(attribute))
45          {
46              addAlias(attribute, setter);
47          }
48      }
49  
50      protected Class getBeanClass(Element element)
51      {
52          return MapEntryCombiner.class;
53      }
54  
55  }