Coverage report

  %line %branch
org.apache.commons.jexl.util.introspection.Introspector
32% 
67% 

 1  
 /*
 2  
  * Copyright 2001,2004 The Apache Software Foundation.
 3  
  * 
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  * 
 8  
  *      http://www.apache.org/licenses/LICENSE-2.0
 9  
  * 
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 
 17  
 package org.apache.commons.jexl.util.introspection;
 18  
 
 19  
 import java.lang.reflect.Method;
 20  
 
 21  
 import org.apache.commons.logging.Log;
 22  
 
 23  
 
 24  
 /**
 25  
  * This basic function of this class is to return a Method
 26  
  * object for a particular class given the name of a method
 27  
  * and the parameters to the method in the form of an Object[]
 28  
  *
 29  
  * The first time the Introspector sees a 
 30  
  * class it creates a class method map for the
 31  
  * class in question. Basically the class method map
 32  
  * is a Hastable where Method objects are keyed by a
 33  
  * concatenation of the method name and the names of
 34  
  * classes that make up the parameters.
 35  
  *
 36  
  * For example, a method with the following signature:
 37  
  *
 38  
  * public void method(String a, StringBuffer b)
 39  
  *
 40  
  * would be mapped by the key:
 41  
  *
 42  
  * "method" + "java.lang.String" + "java.lang.StringBuffer"
 43  
  *
 44  
  * This mapping is performed for all the methods in a class
 45  
  * and stored for 
 46  
  * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
 47  
  * @author <a href="mailto:bob@werken.com">Bob McWhirter</a>
 48  
  * @author <a href="mailto:szegedia@freemail.hu">Attila Szegedi</a>
 49  
  * @author <a href="mailto:paulo.gaspar@krankikom.de">Paulo Gaspar</a>
 50  
  * @version $Id: Introspector.java,v 1.6 2004/08/23 13:50:00 dion Exp $
 51  
  */
 52  
 public class Introspector extends IntrospectorBase
 53  
 {
 54  
     /**
 55  
      *  define a public string so that it can be looked for
 56  
      *  if interested
 57  
      */
 58  
 
 59  
     public static final String CACHEDUMP_MSG = 
 60  
         "Introspector : detected classloader change. Dumping cache.";
 61  
 
 62  
     /**
 63  
      *  our engine runtime services
 64  
      */
 65  30
     private  Log rlog = null;
 66  
 
 67  
     /**
 68  
      *  Recieves our RuntimeServices object
 69  
      */
 70  2
     public Introspector(Log logger)
 71  28
     {
 72  30
         this.rlog = logger;
 73  30
     }
 74  
    
 75  
     /**
 76  
      * Gets the method defined by <code>name</code> and
 77  
      * <code>params</code> for the Class <code>c</code>.
 78  
      *
 79  
      * @param c Class in which the method search is taking place
 80  
      * @param name Name of the method being searched for
 81  
      * @param params An array of Objects (not Classes) that describe the
 82  
      *               the parameters
 83  
      *
 84  
      * @return The desired Method object.
 85  
      */
 86  
     public Method getMethod(Class c, String name, Object[] params)
 87  
         throws Exception
 88  
     {
 89  
         /*
 90  
          *  just delegate to the base class
 91  
          */
 92  
 
 93  
         try
 94  
         {
 95  1131
             return super.getMethod( c, name, params );
 96  
         }
 97  
         catch( MethodMap.AmbiguousException ae )
 98  
         {
 99  
             /*
 100  
              *  whoops.  Ambiguous.  Make a nice log message and return null...
 101  
              */
 102  
 
 103  0
             String msg = "Introspection Error : Ambiguous method invocation "
 104  
                 + name + "( ";
 105  
 
 106  0
             for (int i = 0; i < params.length; i++)
 107  
             {
 108  0
                 if ( i > 0)
 109  0
                     msg += ", ";
 110  
                 
 111  0
                 msg += params[i].getClass().getName();
 112  
             }
 113  
             
 114  0
             msg = msg + ") for class " + c;
 115  
             
 116  0
             rlog.error( msg );
 117  
         }
 118  
 
 119  0
         return null;
 120  
     }
 121  
 
 122  
     /**
 123  
      * Clears the classmap and classname
 124  
      * caches, and logs that we did so
 125  
      */
 126  
     protected void clearCache()
 127  
     {
 128  0
         super.clearCache();
 129  0
         rlog.info( CACHEDUMP_MSG );
 130  0
     }
 131  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.