Coverage Report - org.apache.tapestry.enhance.ClassInspectorImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
ClassInspectorImpl
0%
0/12
0%
0/6
4
 
 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  
 package org.apache.tapestry.enhance;
 15  
 
 16  
 import java.beans.BeanInfo;
 17  
 import java.beans.Introspector;
 18  
 import java.beans.PropertyDescriptor;
 19  
 import java.lang.reflect.Method;
 20  
 
 21  
 import org.apache.hivemind.ApplicationRuntimeException;
 22  
 
 23  
 
 24  
 /**
 25  
  * Implemenation of {@link ClassInspector} that is compatible with 
 26  
  * 1.4 jres.
 27  
  */
 28  0
 public class ClassInspectorImpl implements ClassInspector
 29  
 {
 30  
 
 31  
     /**
 32  
      * {@inheritDoc}
 33  
      */
 34  
     public MethodSignature getMethodSignature(Class implementing, Method m)
 35  
     {
 36  0
         return new MethodSignatureImpl(m);
 37  
     }
 38  
     
 39  
     /**
 40  
      * {@inheritDoc}
 41  
      */
 42  
     public MethodSignature getPropertyAccessor(Class type, String propertyName)
 43  
     {
 44  
         try {
 45  0
             BeanInfo info = Introspector.getBeanInfo(type);
 46  0
             PropertyDescriptor[] props = info.getPropertyDescriptors();
 47  
             
 48  0
             for (int i=0; i < props.length; i++) {
 49  
                 
 50  0
                 if (!propertyName.equals(props[i].getName())) {
 51  0
                     continue;
 52  
                 }
 53  
                 
 54  0
                 return new MethodSignatureImpl(props[i].getReadMethod() != null ? props[i].getReadMethod() : props[i].getWriteMethod());
 55  
             } 
 56  
             
 57  0
         } catch (Throwable t) {
 58  
             
 59  0
             throw new ApplicationRuntimeException("Error reading property " + propertyName + " from base class : " + type, t);
 60  0
         }
 61  
         
 62  0
         return null;
 63  
     }
 64  
 
 65  
 }