Coverage Report - org.apache.tiles.ognl.DelegatePropertyAccessor
 
Classes in this File Line Coverage Branch Coverage Complexity
DelegatePropertyAccessor
100%
8/8
N/A
1
 
 1  
 /*
 2  
  * $Id: DelegatePropertyAccessor.java 1049696 2010-12-15 20:30:10Z apetrelli $
 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  
 
 22  
 package org.apache.tiles.ognl;
 23  
 
 24  
 import java.util.Map;
 25  
 
 26  
 import ognl.OgnlContext;
 27  
 import ognl.OgnlException;
 28  
 import ognl.PropertyAccessor;
 29  
 
 30  
 /**
 31  
  * Uses a {@link PropertyAccessorDelegateFactory} to delegate the methods to
 32  
  * another {@link PropertyAccessor}.
 33  
  *
 34  
  * @param <T> The type of the accessed root object.
 35  
  * @version $Rev: 1049696 $ $Date: 2010-12-16 07:30:10 +1100 (Thu, 16 Dec 2010) $
 36  
  * @since 2.2.0
 37  
  */
 38  
 public class DelegatePropertyAccessor<T> implements PropertyAccessor {
 39  
 
 40  
     /**
 41  
      * The property accessor factory.
 42  
      *
 43  
      * @since 2.2.0
 44  
      */
 45  
     private PropertyAccessorDelegateFactory<T> factory;
 46  
 
 47  
     /**
 48  
      * Constructor.
 49  
      *
 50  
      * @param factory The property accessor factory.
 51  
      * @since 2.2.0
 52  
      */
 53  8
     public DelegatePropertyAccessor(PropertyAccessorDelegateFactory<T> factory) {
 54  8
         this.factory = factory;
 55  8
     }
 56  
 
 57  
     /** {@inheritDoc} */
 58  
     @SuppressWarnings("unchecked")
 59  
     public Object getProperty(@SuppressWarnings("rawtypes") Map context, Object target, Object name)
 60  
             throws OgnlException {
 61  15
         return factory.getPropertyAccessor((String) name, (T) target).getProperty(
 62  
                 context, target, name);
 63  
     }
 64  
 
 65  
     /** {@inheritDoc} */
 66  
     @SuppressWarnings("unchecked")
 67  
     public void setProperty(@SuppressWarnings("rawtypes") Map context, Object target, Object name,
 68  
             Object value) throws OgnlException {
 69  1
         factory.getPropertyAccessor((String) name, (T) target).setProperty(context,
 70  
                 target, name, value);
 71  1
     }
 72  
 
 73  
     /** {@inheritDoc} */
 74  
     @SuppressWarnings("unchecked")
 75  
     public String getSourceAccessor(OgnlContext context, Object target,
 76  
             Object index) {
 77  1
         return factory.getPropertyAccessor((String) index, (T) target)
 78  
                 .getSourceAccessor(context, target, index);
 79  
     }
 80  
 
 81  
     /** {@inheritDoc} */
 82  
     @SuppressWarnings("unchecked")
 83  
     public String getSourceSetter(OgnlContext context, Object target,
 84  
             Object index) {
 85  1
         return factory.getPropertyAccessor((String) index, (T) target)
 86  
                 .getSourceSetter(context, target, index);
 87  
     }
 88  
 }