View Javadoc

    1   package org.apache.turbine.pipeline;
    2
    3   import java.util.HashMap;
    4   import java.util.Map;
    5
    6
    7   /*
    8    * Licensed to the Apache Software Foundation (ASF) under one
    9    * or more contributor license agreements.  See the NOTICE file
    10   * distributed with this work for additional information
    11   * regarding copyright ownership.  The ASF licenses this file
    12   * to you under the Apache License, Version 2.0 (the
    13   * "License"); you may not use this file except in compliance
    14   * with the License.  You may obtain a copy of the License at
    15   *
    16   *   http://www.apache.org/licenses/LICENSE-2.0
    17   *
    18   * Unless required by applicable law or agreed to in writing,
    19   * software distributed under the License is distributed on an
    20   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    21   * KIND, either express or implied.  See the License for the
    22   * specific language governing permissions and limitations
    23   * under the License.
    24   */
    25
    26
    27  /**
    28   * <p>A <b>PipelineData</b> is a holder for data being passed from one
    29   * Valve to the next.
    30   * The detailed contract for a Valve is included in the description of
    31   * the <code>invoke()</code> method below.</p>
    32   *
    33   * <b>HISTORICAL NOTE</b>:  The "PipelineData" name was assigned to this
    34   * holder as it functions similarily to the RunData object, but without
    35   * the additional methods
    36   *
    37   * @author <a href="mailto:epugh@opensourceconnections.com">Eric Pugh</a>
    38   * @author <a href="mailto:peter@courcoux.biz">Peter Courcoux</a>
    39   */
    40  public class DefaultPipelineData implements PipelineData
    41  {
    42      private final Map<Class<?>, Map<?, ?>> map = new HashMap<Class<?>, Map<?, ?>>();
    43
    44      public void put(Class<?> key, Map<?, ?> value)
    45      {
    46          map.put(key, value);
    47      }
    48
    49      public Map<?, ?> get(Class key)
    50      {
    51          return map.get(key);
    52      }
    53
    54      public Object get(Class<?> key, Object innerKey)
    55      {
    56          Map<?, ?> innerMap = get(key);
    57          if (innerMap == null)
    58          {
    59              return null;
    60          }
    61          return innerMap.get(innerKey);
    62      }
    63
    64
    65  }