View Javadoc

1   /*
2    * $Id: ReusablePropertyConfiguration.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.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  
22      private PropertyConfiguration reference;
23      private PropertyConfiguration delegate;
24  
25      public ReusablePropertyConfiguration()
26      {
27          this(new SimplePropertyConfiguration());
28      }
29  
30      public ReusablePropertyConfiguration(PropertyConfiguration delegate)
31      {
32          this.delegate = delegate;
33      }
34  
35     public void reset()
36      {
37          if (null == reference)
38          {
39              reference = delegate;
40          }
41          delegate = new TempWrapperPropertyConfiguration(reference);
42      }
43  
44      public void addReference(String propertyName)
45      {
46          delegate.addReference(propertyName);
47      }
48  
49      public void addMapping(String propertyName, Map mappings)
50      {
51          delegate.addMapping(propertyName, mappings);
52      }
53  
54      public void addMapping(String propertyName, String mappings)
55      {
56          delegate.addMapping(propertyName, mappings);
57      }
58  
59      public void addMapping(String propertyName, ValueMap mappings)
60      {
61          delegate.addMapping(propertyName, mappings);
62      }
63  
64      public void addAlias(String alias, String propertyName)
65      {
66          delegate.addAlias(alias, propertyName);
67      }
68  
69      public void addCollection(String propertyName)
70      {
71          delegate.addCollection(propertyName);
72      }
73  
74      public void addIgnored(String propertyName)
75      {
76          delegate.addIgnored(propertyName);
77      }
78  
79      public void removeIgnored(String propertyName)
80      {
81          delegate.removeIgnored(propertyName);
82      }
83  
84      public void setIgnoredDefault(boolean ignoreAll)
85      {
86          delegate.setIgnoredDefault(ignoreAll);
87      }
88  
89      public String getAttributeMapping(String alias)
90      {
91          return delegate.getAttributeMapping(alias);
92      }
93  
94      public String getAttributeAlias(String mapping)
95      {
96          return delegate.getAttributeAlias(mapping);
97      }
98  
99      public boolean isCollection(String propertyName)
100     {
101         return delegate.isCollection(propertyName);
102     }
103 
104     public boolean isIgnored(String propertyName)
105     {
106         return delegate.isIgnored(propertyName);
107     }
108 
109     public boolean isReference(String attributeName)
110     {
111         return delegate.isReference(attributeName);
112     }
113 
114     public SingleProperty getSingleProperty(String propertyName)
115     {
116         return new SinglePropertyWrapper(propertyName, this);
117     }
118 
119     public String translateName(String oldName)
120     {
121         return delegate.translateName(oldName);
122     }
123 
124     public Object translateValue(String name, String value)
125     {
126         return delegate.translateValue(name, value);
127     }
128 
129 }