[jboss-cvs] jboss-seam/src/main/org/jboss/seam/util ...

Gavin King gavin.king at jboss.com
Thu Oct 19 16:08:48 EDT 2006


  User: gavin   
  Date: 06/10/19 16:08:48

  Modified:    src/main/org/jboss/seam/util  Reflections.java
  Log:
  will come in handy later
  
  Revision  Changes    Path
  1.14      +18 -1     jboss-seam/src/main/org/jboss/seam/util/Reflections.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Reflections.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/util/Reflections.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -b -r1.13 -r1.14
  --- Reflections.java	8 Oct 2006 14:01:54 -0000	1.13
  +++ Reflections.java	19 Oct 2006 20:08:48 -0000	1.14
  @@ -1,4 +1,4 @@
  -//$Id: Reflections.java,v 1.13 2006/10/08 14:01:54 gavin Exp $
  +//$Id: Reflections.java,v 1.14 2006/10/19 20:08:48 gavin Exp $
   package org.jboss.seam.util;
   
   import java.beans.Introspector;
  @@ -178,6 +178,23 @@
         throw new IllegalArgumentException("no such setter method: " + clazz.getName() + '.' + name);
      }
      
  +   public static Method getGetterMethod(Class clazz, String name)
  +   {
  +      Method[] methods = clazz.getMethods();
  +      for (Method method: methods)
  +      {
  +         String methodName = method.getName();
  +         if ( methodName.matches("^(get|is).*") && method.getParameterTypes().length==0 )
  +         {
  +            if ( Introspector.decapitalize( methodName.substring(3) ).equals(name) )
  +            {
  +               return method;
  +            }
  +         }
  +      }
  +      throw new IllegalArgumentException("no such getter method: " + clazz.getName() + '.' + name);
  +   }
  +   
      public static Field getField(Class clazz, String name)
      {
         for ( Class superClass = clazz; superClass!=Object.class; superClass=superClass.getSuperclass() )
  
  
  



More information about the jboss-cvs-commits mailing list