当前位置: 首页>>代码示例>>Java>>正文


Java ArrayUtils.EMPTY_OBJECT_ARRAY属性代码示例

本文整理汇总了Java中org.apache.commons.lang.ArrayUtils.EMPTY_OBJECT_ARRAY属性的典型用法代码示例。如果您正苦于以下问题:Java ArrayUtils.EMPTY_OBJECT_ARRAY属性的具体用法?Java ArrayUtils.EMPTY_OBJECT_ARRAY怎么用?Java ArrayUtils.EMPTY_OBJECT_ARRAY使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.commons.lang.ArrayUtils的用法示例。


在下文中一共展示了ArrayUtils.EMPTY_OBJECT_ARRAY属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: invokeMethod

/**
 * <p>Invoke a named method whose parameter type matches the object type.</p>
 *
 * <p>This method delegates the method search to {@link #getMatchingAccessibleMethod(Class, String, Class[])}.</p>
 *
 * <p>This method supports calls to methods taking primitive parameters 
 * via passing in wrapping classes. So, for example, a <code>Boolean</code> object
 * would match a <code>boolean</code> primitive.</p>
 *
 * @param object invoke method on this object
 * @param methodName get method with this name
 * @param args use these arguments - treat null as empty array
 * @param parameterTypes match these parameters - treat null as empty array
 * @return The value returned by the invoked method
 *
 * @throws NoSuchMethodException if there is no such accessible method
 * @throws InvocationTargetException wraps an exception thrown by the method invoked
 * @throws IllegalAccessException if the requested method is not accessible via reflection
 */
public static Object invokeMethod(Object object, String methodName,
        Object[] args, Class[] parameterTypes)
        throws NoSuchMethodException, IllegalAccessException,
        InvocationTargetException {
    if (parameterTypes == null) {
        parameterTypes = ArrayUtils.EMPTY_CLASS_ARRAY;
    }
    if (args == null) {
        args = ArrayUtils.EMPTY_OBJECT_ARRAY;
    }
    Method method = getMatchingAccessibleMethod(object.getClass(),
            methodName, parameterTypes);
    if (method == null) {
        throw new NoSuchMethodException("No such accessible method: "
                + methodName + "() on object: "
                + object.getClass().getName());
    }
    return method.invoke(object, args);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:38,代码来源:MethodUtils.java

示例2: invokeExactMethod

/**
 * <p>Invoke a method whose parameter types match exactly the parameter
 * types given.</p>
 *
 * <p>This uses reflection to invoke the method obtained from a call to
 * <code>getAccessibleMethod()</code>.</p>
 *
 * @param object invoke method on this object
 * @param methodName get method with this name
 * @param args use these arguments - treat null as empty array
 * @param parameterTypes match these parameters - treat null as empty array
 * @return The value returned by the invoked method
 *
 * @throws NoSuchMethodException if there is no such accessible method
 * @throws InvocationTargetException wraps an exception thrown by the
 *  method invoked
 * @throws IllegalAccessException if the requested method is not accessible
 *  via reflection
 */
public static Object invokeExactMethod(Object object, String methodName,
        Object[] args, Class[] parameterTypes)
        throws NoSuchMethodException, IllegalAccessException,
        InvocationTargetException {
    if (args == null) {
        args = ArrayUtils.EMPTY_OBJECT_ARRAY;
    }
    if (parameterTypes == null) {
        parameterTypes = ArrayUtils.EMPTY_CLASS_ARRAY;
    }
    Method method = getAccessibleMethod(object.getClass(), methodName,
            parameterTypes);
    if (method == null) {
        throw new NoSuchMethodException("No such accessible method: "
                + methodName + "() on object: "
                + object.getClass().getName());
    }
    return method.invoke(object, args);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:38,代码来源:MethodUtils.java

示例3: invokeConstructor

/**
 * <p>Returns new instance of <code>klazz</code> created using constructor
 * with signature <code>parameterTypes</code> and actual arguments
 * <code>args</code>.</p>
 * 
 * <p>The signatures should be assignment compatible.</p>
 * 
 * @param cls the class to be constructed.
 * @param args actual argument array
 * @param parameterTypes parameter types array
 * @return new instance of <code>klazz</code>
 * 
 * @throws NoSuchMethodException if matching constructor cannot be found
 * @throws IllegalAccessException thrown on the constructor's invocation
 * @throws InvocationTargetException thrown on the constructor's invocation
 * @throws InstantiationException thrown on the constructor's invocation
 * @see Constructor#newInstance
 */
public static Object invokeConstructor(Class cls, Object[] args, Class[] parameterTypes)
        throws NoSuchMethodException, IllegalAccessException, InvocationTargetException,
        InstantiationException {
    if (parameterTypes == null) {
        parameterTypes = ArrayUtils.EMPTY_CLASS_ARRAY;
    }
    if (args == null) {
        args = ArrayUtils.EMPTY_OBJECT_ARRAY;
    }
    Constructor ctor = getMatchingAccessibleConstructor(cls, parameterTypes);
    if (null == ctor) {
        throw new NoSuchMethodException("No such accessible constructor on object: "
                + cls.getName());
    }
    return ctor.newInstance(args);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:34,代码来源:ConstructorUtils.java

示例4: invokeExactConstructor

/**
 * <p>Returns new instance of <code>klazz</code> created using constructor
 * with signature <code>parameterTypes</code> and actual arguments
 * <code>args</code>.</p>
 * 
 * <p>The signatures should match exactly.</p>
 * 
 * @param cls the class to be constructed.
 * @param args actual argument array
 * @param parameterTypes parameter types array
 * @return new instance of <code>klazz</code>
 * 
 * @throws NoSuchMethodException if matching constructor cannot be found
 * @throws IllegalAccessException thrown on the constructor's invocation
 * @throws InvocationTargetException thrown on the constructor's invocation
 * @throws InstantiationException thrown on the constructor's invocation
 * @see Constructor#newInstance
 */
public static Object invokeExactConstructor(Class cls, Object[] args,
        Class[] parameterTypes) throws NoSuchMethodException, IllegalAccessException,
        InvocationTargetException, InstantiationException {
    if (args == null) {
        args = ArrayUtils.EMPTY_OBJECT_ARRAY;
    }
    if (parameterTypes == null) {
        parameterTypes = ArrayUtils.EMPTY_CLASS_ARRAY;
    }
    Constructor ctor = getAccessibleConstructor(cls, parameterTypes);
    if (null == ctor) {
        throw new NoSuchMethodException("No such accessible constructor on object: "
                + cls.getName());
    }
    return ctor.newInstance(args);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:34,代码来源:ConstructorUtils.java

示例5: invokeExactStaticMethod

/**
 * <p>Invoke a static method whose parameter types match exactly the parameter
 * types given.</p>
 *
 * <p>This uses reflection to invoke the method obtained from a call to
 * {@link #getAccessibleMethod(Class, String, Class[])}.</p>
 *
 * @param cls invoke static method on this class
 * @param methodName get method with this name
 * @param args use these arguments - treat null as empty array
 * @param parameterTypes match these parameters - treat null as empty array
 * @return The value returned by the invoked method
 *
 * @throws NoSuchMethodException if there is no such accessible method
 * @throws InvocationTargetException wraps an exception thrown by the
 *  method invoked
 * @throws IllegalAccessException if the requested method is not accessible
 *  via reflection
 */
public static Object invokeExactStaticMethod(Class cls, String methodName,
        Object[] args, Class[] parameterTypes)
        throws NoSuchMethodException, IllegalAccessException,
        InvocationTargetException {
    if (args == null) {
        args = ArrayUtils.EMPTY_OBJECT_ARRAY;
    }
    if (parameterTypes == null) {
        parameterTypes = ArrayUtils.EMPTY_CLASS_ARRAY;
    }
    Method method = getAccessibleMethod(cls, methodName, parameterTypes);
    if (method == null) {
        throw new NoSuchMethodException("No such accessible method: "
                + methodName + "() on class: " + cls.getName());
    }
    return method.invoke(null, args);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:36,代码来源:MethodUtils.java

示例6: invokeStaticMethod

/**
 * <p>Invoke a named static method whose parameter type matches the object type.</p>
 *
 * <p>This method delegates the method search to {@link #getMatchingAccessibleMethod(Class, String, Class[])}.</p>
 *
 * <p>This method supports calls to methods taking primitive parameters 
 * via passing in wrapping classes. So, for example, a <code>Boolean</code> class
 * would match a <code>boolean</code> primitive.</p>
 *
 *
 * @param cls invoke static method on this class
 * @param methodName get method with this name
 * @param args use these arguments - treat null as empty array
 * @param parameterTypes match these parameters - treat null as empty array
 * @return The value returned by the invoked method
 *
 * @throws NoSuchMethodException if there is no such accessible method
 * @throws InvocationTargetException wraps an exception thrown by the
 *  method invoked
 * @throws IllegalAccessException if the requested method is not accessible
 *  via reflection
 */
public static Object invokeStaticMethod(Class cls, String methodName,
        Object[] args, Class[] parameterTypes)
        throws NoSuchMethodException, IllegalAccessException,
        InvocationTargetException {
    if (parameterTypes == null) {
        parameterTypes = ArrayUtils.EMPTY_CLASS_ARRAY;
    }
    if (args == null) {
        args = ArrayUtils.EMPTY_OBJECT_ARRAY;
    }
    Method method = getMatchingAccessibleMethod(cls, methodName,
            parameterTypes);
    if (method == null) {
        throw new NoSuchMethodException("No such accessible method: "
                + methodName + "() on class: " + cls.getName());
    }
    return method.invoke(null, args);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:40,代码来源:MethodUtils.java


注:本文中的org.apache.commons.lang.ArrayUtils.EMPTY_OBJECT_ARRAY属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。