Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
NestedMapWithAttributesDefinitionParser |
|
| 1.0;1 |
1 | /* | |
2 | * $Id: NestedMapWithAttributesDefinitionParser.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.specific.properties; | |
12 | ||
13 | import org.mule.config.spring.parsers.AbstractMuleBeanDefinitionParser; | |
14 | import org.mule.config.spring.parsers.assembly.MapEntryCombiner; | |
15 | import org.mule.config.spring.parsers.collection.ChildSingletonMapDefinitionParser; | |
16 | import org.mule.config.spring.parsers.delegate.AbstractSingleParentFamilyDefinitionParser; | |
17 | import org.mule.config.spring.parsers.generic.AttributePropertiesDefinitionParser; | |
18 | import org.mule.config.spring.parsers.processors.AddAttribute; | |
19 | ||
20 | /** | |
21 | * This generates a nested map (an element of the parent map, with the key "mapKey", which is a map itself) | |
22 | * and then adds any attributes as name/value pairs. Embedded elements can then insert further entries using | |
23 | * {@link org.mule.config.spring.parsers.collection.ChildSingletonMapDefinitionParser} or, if the entry is | |
24 | * just a simple value, {@link org.mule.config.spring.parsers.specific.properties.SimplePropertyDefinitionParser}. | |
25 | * The target setter is {@link org.mule.config.spring.parsers.assembly.MapEntryCombiner#VALUE}. | |
26 | */ | |
27 | public class NestedMapWithAttributesDefinitionParser extends AbstractSingleParentFamilyDefinitionParser | |
28 | { | |
29 | ||
30 | public NestedMapWithAttributesDefinitionParser(String mapSetter, String mapKey) | |
31 | 0 | { |
32 | 0 | addDelegate(new ChildSingletonMapDefinitionParser(mapSetter)) |
33 | .addCollection(mapSetter) | |
34 | .setIgnoredDefault(true) | |
35 | .removeIgnored(MapEntryCombiner.KEY) | |
36 | .registerPreProcessor(new AddAttribute(MapEntryCombiner.KEY, mapKey)); | |
37 | 0 | addChildDelegate(new AttributePropertiesDefinitionParser(MapEntryCombiner.VALUE)) |
38 | .addIgnored(AbstractMuleBeanDefinitionParser.ATTRIBUTE_NAME) | |
39 | .addIgnored(MapEntryCombiner.KEY); | |
40 | 0 | } |
41 | ||
42 | } | |
43 |