package edu.columbia.gemma.util;

/**
 * <hr>
 * <p>
 * Copyright (c) 2004 Columbia University
 * 
 * @author pavlidis
 * @version $Id$
 */
public class ReflectionUtil {
    /**
     * @param obj
     * @return Unqualified type name
     */
    public static String objectToTypeName( Object obj ) {
        return obj.getClass().getName().substring( obj.getClass().getName().lastIndexOf( '.' ) + 1 );
    }

    /**
     * @param cls
     * @return Unqualified type name.
     */
    public static String classToTypeName( Class cls ) {
        return cls.getName().substring( cls.getName().lastIndexOf( '.' ) + 1 );
    }

    /**
     * @param obj
     * @return
     */
    public static Class getBaseForImpl( Object obj ) {
        return getImplForBase( obj.getClass() );
    }

    /**
     * @param cls
     * @return
     */
    public static Class getImplForBase( Class cls ) {
        if ( cls.getName().endsWith( "Impl" ) ) {
            return cls.getSuperclass();
        }
        return cls;
    }

}

@@ -31,16 +31,91 @@
 l;%0A%0A/**%0A
+ * Various methods useful for manipulating Gemma objects using Reflection.%0A
  * %3Chr%3E%0A
@@ -238,16 +238,70 @@
 nUtil %7B%0A
+%0A    private static final String DAO_SUFFIX = %22Dao%22;%0A%0A
     /**%0A
@@ -1135,10 +1135,540 @@
 %0A    %7D%0A%0A
+    /**%0A     * @param gemmaObj A Gemma domain object.%0A     * @return Name of Dao bean; for example, given foo.Bar, it returns %22barDao%22.%0A     */%0A    public static String constructDaoName( Object gemmaObj ) %7B%0A        String baseDaoName = getBaseForImpl( gemmaObj ) + DAO_SUFFIX;%0A%0A        if ( baseDaoName.length() == DAO_SUFFIX.length() ) return null;%0A%0A        baseDaoName = baseDaoName.substring( baseDaoName.lastIndexOf( '.' ) + 1 );%0A        return baseDaoName.substring( 0, 1 ).toLowerCase() + baseDaoName.substring( 1 );%0A    %7D%0A%0A
 %7D%0A

add constructDaoname method