Coverage Report - org.apache.turbine.pipeline.DefaultPipelineData
 
Classes in this File Line Coverage Branch Coverage Complexity
DefaultPipelineData
100%
9/9
100%
2/2
1,667
 
 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 similarly 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  34
 public class DefaultPipelineData implements PipelineData
 41  
 {
 42  34
     private final Map<Class<?>, Map<Class<?>, ? super Object>> map =
 43  
         new HashMap<Class<?>, Map<Class<?>, ? super Object>>();
 44  
 
 45  
     /**
 46  
      * Put a configured map of objects into the pipeline data object
 47  
      *
 48  
      * @param key the key class
 49  
      * @param value the value map
 50  
      */
 51  
     @Override
 52  
     public void put(Class<?> key, Map<Class<?>, ? super Object> value)
 53  
     {
 54  34
         map.put(key, value);
 55  34
     }
 56  
 
 57  
     /**
 58  
      * Get the configured map of objects for the given key
 59  
      *
 60  
      * @param key the key class
 61  
      * @return the value map or null if no such key exists
 62  
      */
 63  
     @Override
 64  
     public Map<Class<?>, ? super Object> get(Class<?> key)
 65  
     {
 66  605
         return map.get(key);
 67  
     }
 68  
 
 69  
     /**
 70  
      * Get a value from the configured map of objects for the given keys
 71  
      *
 72  
      * @param key the key class
 73  
      * @param innerKey the key into the value map
 74  
      * @return the inner value or null if no such keys exist
 75  
      */
 76  
     @Override
 77  
     @SuppressWarnings("unchecked")
 78  
     public <T> T get(Class<?> key, Class<T> innerKey)
 79  
     {
 80  349
         Map<Class<?>, ? super Object> innerMap = get(key);
 81  349
         if (innerMap == null)
 82  
         {
 83  3
             return null;
 84  
         }
 85  346
         return (T) innerMap.get(innerKey);
 86  
     }
 87  
 }