Here you can find the source of getMethodResult(final Object element, final String methodName)
static Object getMethodResult(final Object element, final String methodName) throws Exception
//package com.java2s; /**//ww w . j a v a 2s . c o m * Copyright 2007, Lorenzo Bolzani * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/MPL-1.1.html **/ import java.lang.reflect.Method; public class Main { static Object getMethodResult(final Object element, final String methodName) throws Exception { return getMethodResult(element, methodName, null); } static Object getMethodResult(final Object element, final String methodName, final Object param) throws Exception { Class[] classes = null; Object[] params = null; if (param != null) { classes = new Class[] { param.getClass() }; params = new Object[] { param }; } // TODO: sistemare final Method m = element.getClass().getMethod(methodName, classes); m.setAccessible(true); return m.invoke(element, params); } }