Clover coverage report - Code Coverage for tapestry release 4.0-alpha-3
Coverage timestamp: Mon May 16 2005 09:05:49 EDT
file stats: LOC: 75   Methods: 2
NCLOC: 24   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
BeanProviderPropertyAccessor.java 25% 40% 50% 37.5%
coverage coverage
 1   
 // Copyright 2004, 2005 The Apache Software Foundation
 2   
 //
 3   
 // Licensed under the Apache License, Version 2.0 (the "License");
 4   
 // you may not use this file except in compliance with the License.
 5   
 // You may obtain a copy of the License at
 6   
 //
 7   
 //     http://www.apache.org/licenses/LICENSE-2.0
 8   
 //
 9   
 // Unless required by applicable law or agreed to in writing, software
 10   
 // distributed under the License is distributed on an "AS IS" BASIS,
 11   
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12   
 // See the License for the specific language governing permissions and
 13   
 // limitations under the License.
 14   
 
 15   
 package org.apache.tapestry.bean;
 16   
 
 17   
 import java.util.Map;
 18   
 
 19   
 import ognl.ObjectPropertyAccessor;
 20   
 import ognl.OgnlException;
 21   
 
 22   
 import org.apache.tapestry.IBeanProvider;
 23   
 
 24   
 /**
 25   
  *  Adapts a {@link org.apache.tapestry.IBeanProvider} to
 26   
  *  <a href="http://www.ognl.org">OGNL</a> by exposing the named
 27   
  *  beans provided by the provider as read-only properties of
 28   
  *  the provider.
 29   
  * 
 30   
  *  <p>This is registered by {@link org.apache.tapestry.AbstractComponent}.
 31   
  *
 32   
  *  @author Howard Lewis Ship
 33   
  *  @since 2.2
 34   
  *
 35   
  **/
 36   
 
 37   
 public class BeanProviderPropertyAccessor extends ObjectPropertyAccessor
 38   
 {
 39   
     /**
 40   
      *  Checks to see if the name matches the name of a bean inside
 41   
      *  the provider and returns that bean if so.
 42   
      *  Otherwise, invokes the super implementation.
 43   
      * 
 44   
      **/
 45   
     
 46  73
     public Object getProperty(Map context, Object target, Object name) throws OgnlException
 47   
     {
 48  73
         IBeanProvider provider = (IBeanProvider)target;
 49  73
         String beanName = (String)name;
 50   
         
 51  73
         if (provider.canProvideBean(beanName))
 52  73
             return provider.getBean(beanName);
 53   
         
 54  0
         return super.getProperty(context, target, name);
 55   
     }
 56   
 
 57   
     /**
 58   
      *  Returns true if the name matches a bean provided by the provider.
 59   
      *  Otherwise invokes the super implementation.
 60   
      * 
 61   
      **/
 62   
     
 63  0
     public boolean hasGetProperty(Map context, Object target, Object oname) throws OgnlException
 64   
     {
 65  0
         IBeanProvider provider = (IBeanProvider)target;
 66  0
         String beanName = (String)oname;
 67   
 
 68  0
         if (provider.canProvideBean(beanName))
 69  0
             return true;
 70   
             
 71  0
         return super.hasGetProperty(context, target, oname);
 72   
     }
 73   
 
 74   
 }
 75