View Javadoc

1   /*
2    * $Id: ContextWrapper.java 421119 2006-07-12 04:49:11Z wsmoak $
3    *
4    * Copyright 2005 The Apache Software Foundation.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *      http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.struts.chain.contexts;
19  
20  import org.apache.commons.chain.Context;
21  
22  import java.util.Collection;
23  import java.util.Map;
24  import java.util.Set;
25  
26  /***
27   * <p> Provide a base class for any Context Implementation which is primarily
28   * intended for use in a subchain. </p> <p> Classes which extend
29   * <code>ContextWrapper</code> may implement typesafe property methods which
30   * also leave their values in the underlying context. </p>
31   */
32  public class ContextWrapper implements Context {
33      private Context base;
34  
35      /***
36       * <p> Instantiate object as a composite around the given Context. </p>
37       *
38       * @param context Context instance to wrap
39       */
40      public ContextWrapper(Context context) {
41          this.base = context;
42      }
43  
44      /***
45       * Provide the underlying Context for this composite.
46       *
47       * @return The undelrying Context
48       */
49      protected Context getBaseContext() {
50          return this.base;
51      }
52  
53      // -------------------------------
54      // Map interface methods
55      // -------------------------------
56      public Set entrySet() {
57          return this.base.entrySet();
58      }
59  
60      public Set keySet() {
61          return this.base.keySet();
62      }
63  
64      public Collection values() {
65          return this.base.values();
66      }
67  
68      public void clear() {
69          this.base.clear();
70      }
71  
72      public void putAll(Map map) {
73          // ISSUE: Should we check this call to putAll?
74          this.base.putAll(map);
75      }
76  
77      public Object remove(Object key) {
78          return this.base.remove(key);
79      }
80  
81      public Object put(Object key, Object value) {
82          // ISSUE: Should we check this call to put?
83          return this.base.put(key, value);
84      }
85  
86      public Object get(Object key) {
87          return this.base.get(key);
88      }
89  
90      public boolean containsValue(Object o) {
91          return this.base.containsValue(o);
92      }
93  
94      public boolean containsKey(Object o) {
95          return this.base.containsKey(o);
96      }
97  
98      public boolean isEmpty() {
99          return this.base.isEmpty();
100     }
101 
102     public int size() {
103         return this.base.size();
104     }
105 }