001: /*
002: * $Id: ContextWrapper.java 471754 2006-11-06 14:55:09Z husted $
003: *
004: * Licensed to the Apache Software Foundation (ASF) under one
005: * or more contributor license agreements. See the NOTICE file
006: * distributed with this work for additional information
007: * regarding copyright ownership. The ASF licenses this file
008: * to you under the Apache License, Version 2.0 (the
009: * "License"); you may not use this file except in compliance
010: * with the License. You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing,
015: * software distributed under the License is distributed on an
016: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017: * KIND, either express or implied. See the License for the
018: * specific language governing permissions and limitations
019: * under the License.
020: */
021: package org.apache.struts.chain.contexts;
022:
023: import org.apache.commons.chain.Context;
024:
025: import java.util.Collection;
026: import java.util.Map;
027: import java.util.Set;
028:
029: /**
030: * <p> Provide a base class for any Context Implementation which is primarily
031: * intended for use in a subchain. </p> <p> Classes which extend
032: * <code>ContextWrapper</code> may implement typesafe property methods which
033: * also leave their values in the underlying context. </p>
034: */
035: public class ContextWrapper implements Context {
036: private Context base;
037:
038: /**
039: * <p> Instantiate object as a composite around the given Context. </p>
040: *
041: * @param context Context instance to wrap
042: */
043: public ContextWrapper(Context context) {
044: this .base = context;
045: }
046:
047: /**
048: * Provide the underlying Context for this composite.
049: *
050: * @return The undelrying Context
051: */
052: protected Context getBaseContext() {
053: return this .base;
054: }
055:
056: // -------------------------------
057: // Map interface methods
058: // -------------------------------
059: public Set entrySet() {
060: return this .base.entrySet();
061: }
062:
063: public Set keySet() {
064: return this .base.keySet();
065: }
066:
067: public Collection values() {
068: return this .base.values();
069: }
070:
071: public void clear() {
072: this .base.clear();
073: }
074:
075: public void putAll(Map map) {
076: // ISSUE: Should we check this call to putAll?
077: this .base.putAll(map);
078: }
079:
080: public Object remove(Object key) {
081: return this .base.remove(key);
082: }
083:
084: public Object put(Object key, Object value) {
085: // ISSUE: Should we check this call to put?
086: return this .base.put(key, value);
087: }
088:
089: public Object get(Object key) {
090: return this .base.get(key);
091: }
092:
093: public boolean containsValue(Object o) {
094: return this .base.containsValue(o);
095: }
096:
097: public boolean containsKey(Object o) {
098: return this .base.containsKey(o);
099: }
100:
101: public boolean isEmpty() {
102: return this .base.isEmpty();
103: }
104:
105: public int size() {
106: return this.base.size();
107: }
108: }
|