Here you can find the source of invoke(Method method, Object javaBean, Object value)
Parameter | Description |
---|---|
method | a parameter |
javaBean | a parameter |
value | a parameter |
public static Object invoke(Method method, Object javaBean, Object value)
//package com.java2s; /************************************************************************************ * @File name : ReflectionUtil.java * * @Author : JUNJZHU/* www . j a v a2s. c om*/ * * @Date : 2012-11-16 * * @Copyright Notice: * Copyright (c) 2012 Shanghai OnStar, Inc. All Rights Reserved. * This software is published under the terms of the Shanghai OnStar Software * License version 1.0, a copy of which has been included with this * distribution in the LICENSE.txt file. * * * ---------------------------------------------------------------------------------- * Date Who Version Comments * 2012-11-16 ????10:26:21 JUNJZHU 1.0 Initial Version ************************************************************************************/ import java.lang.reflect.Method; public class Main { /** * @Author : XIAOXCHE * @Date : 2012-12-10 * @param method * @param javaBean * @param value * @return null */ public static Object invoke(Method method, Object javaBean, Object value) { Object[] paramValue = null; if (value == paramValue) { paramValue = new Object[0]; } else { paramValue = new Object[] { value }; } try { return method.invoke(javaBean, paramValue); } catch (Exception e) { e.printStackTrace(); } return null; } }