ContextWrapper xref

View Javadoc

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