View Javadoc

1   /*
2    * $Id: TempWrapperPropertyConfiguration.java 19695 2010-09-22 17:30:20Z esteban.robles $
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.assembly.configuration;
12  
13  import java.util.Map;
14  
15  /**
16   * Wrap a PropertyConfiguration so that changes are kept in the wrapper
17   */
18  public class TempWrapperPropertyConfiguration implements PropertyConfiguration
19  {
20  
21      protected PropertyConfiguration delegate;
22      protected SimplePropertyConfiguration extra = new SimplePropertyConfiguration();
23      private boolean greedyIgnore;
24  
25      public TempWrapperPropertyConfiguration(PropertyConfiguration delegate)
26      {
27          this(delegate, true);
28      }
29  
30      public TempWrapperPropertyConfiguration(PropertyConfiguration delegate, boolean greedyIgnore)
31      {
32          this.delegate = delegate;
33          this.greedyIgnore = greedyIgnore;
34      }
35  
36      public void addReference(String propertyName)
37      {
38          extra.addReference(propertyName);
39      }
40  
41      public void addMapping(String propertyName, Map mappings)
42      {
43          extra.addMapping(propertyName, mappings);
44      }
45  
46      public void addMapping(String propertyName, String mappings)
47      {
48          extra.addMapping(propertyName, mappings);
49      }
50  
51      public void addMapping(String propertyName, ValueMap mappings)
52      {
53          extra.addMapping(propertyName, mappings);
54      }
55  
56      public void addAlias(String alias, String propertyName)
57      {
58          extra.addAlias(alias, propertyName);
59      }
60  
61      public void addCollection(String propertyName)
62      {
63          extra.addCollection(propertyName);
64      }
65  
66      public void addIgnored(String propertyName)
67      {
68          extra.addIgnored(propertyName);
69      }
70  
71      public void removeIgnored(String propertyName)
72      {
73          extra.removeIgnored(propertyName);
74      }
75  
76      public void setIgnoredDefault(boolean ignoreAll)
77      {
78          extra.setIgnoredDefault(ignoreAll);
79      }
80  
81      public String getAttributeMapping(String alias)
82      {
83          return extra.getAttributeMapping(alias, delegate.getAttributeMapping(alias));
84      }
85  
86      public String getAttributeAlias(String mapping)
87      {
88          return extra.getAttributeMapping(mapping, delegate.getAttributeAlias(mapping));
89      }
90  
91      public boolean isCollection(String propertyName)
92      {
93          return extra.isCollection(propertyName) || delegate.isCollection(propertyName);
94      }
95  
96      public boolean isIgnored(String propertyName)
97      {
98          if (greedyIgnore)
99          {
100             return extra.isIgnored(propertyName) || delegate.isIgnored(propertyName);
101         }
102         else
103         {
104             return extra.isIgnored(propertyName) && delegate.isIgnored(propertyName);            
105         }
106     }
107 
108     public boolean isReference(String attributeName)
109     {
110         return extra.isReference(attributeName) || delegate.isReference(attributeName);
111     }
112 
113     public SingleProperty getSingleProperty(String propertyName)
114     {
115         return new SinglePropertyWrapper(propertyName, this);
116     }
117 
118     public String translateName(String oldName)
119     {
120         return extra.translateName(delegate.translateName(oldName));
121     }
122 
123     public Object translateValue(String name, String value)
124     {
125         Object intermediate = delegate.translateValue(name, value);
126         if (intermediate != null && intermediate.equals(value))
127         {
128             return extra.translateValue(name, value);
129         }
130         else
131         {
132             return intermediate;
133         }
134     }
135 
136 }