View Javadoc

1   /*
2    * $Id: ReusablePropertyConfiguration.java 20850 2010-12-30 20:16:18Z dirk.olmes $
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   * Allow initial mutation; first call of reset stores values as reference and allows
17   * further temporary mutation; further calls to reset return to reference.
18   */
19  public class ReusablePropertyConfiguration implements PropertyConfiguration
20  {
21      private PropertyConfiguration reference;
22      private PropertyConfiguration delegate;
23  
24      public ReusablePropertyConfiguration()
25      {
26          this(new SimplePropertyConfiguration());
27      }
28  
29      public ReusablePropertyConfiguration(PropertyConfiguration delegate)
30      {
31          this.delegate = delegate;
32      }
33  
34      public void reset()
35      {
36          if (null == reference)
37          {
38              reference = delegate;
39          }
40          delegate = new TempWrapperPropertyConfiguration(reference);
41      }
42  
43      public void addReference(String propertyName)
44      {
45          delegate.addReference(propertyName);
46      }
47  
48      public void addMapping(String propertyName, Map mappings)
49      {
50          delegate.addMapping(propertyName, mappings);
51      }
52  
53      public void addMapping(String propertyName, String mappings)
54      {
55          delegate.addMapping(propertyName, mappings);
56      }
57  
58      public void addMapping(String propertyName, ValueMap mappings)
59      {
60          delegate.addMapping(propertyName, mappings);
61      }
62  
63      public void addAlias(String alias, String propertyName)
64      {
65          delegate.addAlias(alias, propertyName);
66      }
67  
68      public void addCollection(String propertyName)
69      {
70          delegate.addCollection(propertyName);
71      }
72  
73      public void addIgnored(String propertyName)
74      {
75          delegate.addIgnored(propertyName);
76      }
77  
78      public void removeIgnored(String propertyName)
79      {
80          delegate.removeIgnored(propertyName);
81      }
82  
83      public void setIgnoredDefault(boolean ignoreAll)
84      {
85          delegate.setIgnoredDefault(ignoreAll);
86      }
87  
88      public String getAttributeMapping(String alias)
89      {
90          return delegate.getAttributeMapping(alias);
91      }
92  
93      public String getAttributeAlias(String mapping)
94      {
95          return delegate.getAttributeAlias(mapping);
96      }
97  
98      public boolean isCollection(String propertyName)
99      {
100         return delegate.isCollection(propertyName);
101     }
102 
103     public boolean isIgnored(String propertyName)
104     {
105         return delegate.isIgnored(propertyName);
106     }
107 
108     public boolean isReference(String attributeName)
109     {
110         return 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 delegate.translateName(oldName);
121     }
122 
123     public Object translateValue(String name, String value)
124     {
125         return delegate.translateValue(name, value);
126     }
127 
128 }