Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * $Id: ReflectionHelper.java 56757 2011-08-19 16:12:50Z mrotteveel $
  * 
  * Firebird Open Source J2EE Connector - JDBC Driver
  *
  * Distributable under LGPL license.
  * You may obtain a copy of the License at http://www.gnu.org/copyleft/lgpl.html
  *
  * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * LGPL License for more details.
 *
 * This file was created by members of the firebird development team.
 * All individual contributions remain the Copyright (C) of those
 * individuals.  Contributors to this file are either listed here or
 * can be obtained from a CVS history command.
 *
 * All rights reserved.
 */
package org.firebirdsql.ds;
Class containing static helper methods for reflective access.

Author(s):
Mark Rotteveel
Since:
2.2
public final class ReflectionHelper {
    
    private ReflectionHelper() {}
    
    
Get all implemented interfaces by the class.

Parameters:
clazz class to inspect.
Returns:
array of all implemented interfaces.
    public static Class[] getAllInterfaces(Class clazz) {
        Set result = new HashSet();
        do {
            Class[] interfaces = clazz.getInterfaces();
            for (int i = 0; i < interfaces.lengthi++) {
                result.add(interfaces[i]);
            }
            clazz = clazz.getSuperclass();
        } while(clazz.getSuperclass() != null);
        
        return (Class[])result.toArray(new Class[result.size()]);
    }
    
    
Helper function to find specified method in a specified class.

Parameters:
clazz class in which we look for a specified method.
name name of the method.
args types of method params.
Returns:
instance of java.lang.reflect.Method corresponding to specified name and param types.
    public static Method findMethod(Class clazzString nameClass[] args) {
        try {
            return clazz.getMethod(nameargs);
        } catch (NoSuchMethodException nmex) {
            return null;
        }
    }
New to GrepCode? Check out our FAQ X