JHotDraw 7.6

org.jhotdraw.util
Class Methods

java.lang.Object
  extended by org.jhotdraw.util.Methods

public class Methods
extends java.lang.Object

Methods contains convenience methods for method invocations using java.lang.reflect.

Version:
$Id: Methods.java 717 2010-11-21 12:30:57Z rawcoder $
Author:
Werner Randelshofer

Method Summary
static java.lang.Object invoke(java.lang.Object obj, java.lang.String methodName)
          Invokes the specified accessible parameterless method if it exists.
static java.lang.Object invoke(java.lang.Object obj, java.lang.String methodName, boolean newValue)
          Invokes the specified setter method if it exists.
static java.lang.Object invoke(java.lang.Object obj, java.lang.String methodName, java.lang.Class[] clazz, java.lang.Object... newValue)
          Invokes the specified setter method if it exists.
static java.lang.Object invoke(java.lang.Object obj, java.lang.String methodName, java.lang.Class clazz, java.lang.Object newValue)
          Invokes the specified setter method if it exists.
static java.lang.Object invoke(java.lang.Object obj, java.lang.String methodName, float newValue)
          Invokes the specified setter method if it exists.
static java.lang.Object invoke(java.lang.Object obj, java.lang.String methodName, int newValue)
          Invokes the specified method if it exists.
static java.lang.Object invoke(java.lang.Object obj, java.lang.String methodName, java.lang.String stringParameter)
          Invokes the specified accessible method with a string parameter if it exists.
static boolean invokeGetter(java.lang.Object obj, java.lang.String methodName, boolean defaultValue)
          Invokes the specified getter method if it exists.
static int invokeGetter(java.lang.Object obj, java.lang.String methodName, int defaultValue)
          Invokes the specified getter method if it exists.
static long invokeGetter(java.lang.Object obj, java.lang.String methodName, long defaultValue)
          Invokes the specified getter method if it exists.
static java.lang.Object invokeGetter(java.lang.Object obj, java.lang.String methodName, java.lang.Object defaultValue)
          Invokes the specified getter method if it exists.
static void invokeIfExists(java.lang.Object obj, java.lang.String methodName)
          Invokes the specified setter method if it exists.
static void invokeIfExists(java.lang.Object obj, java.lang.String methodName, boolean newValue)
          Invokes the specified method if it exists.
static void invokeIfExists(java.lang.Object obj, java.lang.String methodName, java.lang.Class clazz, java.lang.Object newValue)
          Invokes the specified setter method if it exists.
static void invokeIfExists(java.lang.Object obj, java.lang.String methodName, float newValue)
          Invokes the specified setter method if it exists.
static void invokeIfExistsWithEnum(java.lang.Object obj, java.lang.String methodName, java.lang.String enumClassName, java.lang.String enumValueName)
          Invokes the specified setter method if it exists.
static java.lang.Object invokeStatic(java.lang.Class clazz, java.lang.String methodName)
          Invokes the specified accessible parameterless method if it exists.
static java.lang.Object invokeStatic(java.lang.Class clazz, java.lang.String methodName, java.lang.Class[] types, java.lang.Object[] values)
          Invokes the specified parameterless method if it exists.
static java.lang.Object invokeStatic(java.lang.String clazz, java.lang.String methodName)
          Invokes the specified accessible parameterless method if it exists.
static java.lang.Object invokeStatic(java.lang.String clazz, java.lang.String methodName, java.lang.Class[] types, java.lang.Object[] values)
          Invokes the specified parameterless method if it exists.
static java.lang.Object invokeStatic(java.lang.String clazz, java.lang.String methodName, java.lang.Class[] types, java.lang.Object[] values, java.lang.Object defaultValue)
          Invokes the specified parameterless method if it exists.
static boolean invokeStaticGetter(java.lang.Class clazz, java.lang.String methodName, boolean defaultValue)
          Invokes the specified getter method if it exists.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

invoke

public static java.lang.Object invoke(java.lang.Object obj,
                                      java.lang.String methodName)
                               throws java.lang.NoSuchMethodException
Invokes the specified accessible parameterless method if it exists.

Parameters:
obj - The object on which to invoke the method.
methodName - The name of the method.
Returns:
The return value of the method.
Throws:
java.lang.NoSuchMethodException

invoke

public static java.lang.Object invoke(java.lang.Object obj,
                                      java.lang.String methodName,
                                      java.lang.String stringParameter)
                               throws java.lang.NoSuchMethodException
Invokes the specified accessible method with a string parameter if it exists.

Parameters:
obj - The object on which to invoke the method.
methodName - The name of the method.
stringParameter - The String parameter
Returns:
The return value of the method or METHOD_NOT_FOUND.
Throws:
java.lang.NoSuchMethodException

invokeStatic

public static java.lang.Object invokeStatic(java.lang.Class clazz,
                                            java.lang.String methodName)
                                     throws java.lang.NoSuchMethodException
Invokes the specified accessible parameterless method if it exists.

Parameters:
clazz - The class on which to invoke the method.
methodName - The name of the method.
Returns:
The return value of the method or METHOD_NOT_FOUND.
Throws:
java.lang.NoSuchMethodException

invokeStatic

public static java.lang.Object invokeStatic(java.lang.String clazz,
                                            java.lang.String methodName)
                                     throws java.lang.NoSuchMethodException
Invokes the specified accessible parameterless method if it exists.

Parameters:
clazz - The class on which to invoke the method.
methodName - The name of the method.
Returns:
The return value of the method.
Throws:
java.lang.NoSuchMethodException

invokeStatic

public static java.lang.Object invokeStatic(java.lang.Class clazz,
                                            java.lang.String methodName,
                                            java.lang.Class[] types,
                                            java.lang.Object[] values)
                                     throws java.lang.NoSuchMethodException
Invokes the specified parameterless method if it exists.

Parameters:
clazz - The class on which to invoke the method.
methodName - The name of the method.
types - The parameter types.
values - The parameter values.
Returns:
The return value of the method.
Throws:
java.lang.NoSuchMethodException

invokeStatic

public static java.lang.Object invokeStatic(java.lang.String clazz,
                                            java.lang.String methodName,
                                            java.lang.Class[] types,
                                            java.lang.Object[] values)
                                     throws java.lang.NoSuchMethodException
Invokes the specified parameterless method if it exists.

Parameters:
clazz - The class on which to invoke the method.
methodName - The name of the method.
types - The parameter types.
values - The parameter values.
Returns:
The return value of the method.
Throws:
java.lang.NoSuchMethodException

invokeStatic

public static java.lang.Object invokeStatic(java.lang.String clazz,
                                            java.lang.String methodName,
                                            java.lang.Class[] types,
                                            java.lang.Object[] values,
                                            java.lang.Object defaultValue)
Invokes the specified parameterless method if it exists.

Parameters:
clazz - The class on which to invoke the method.
methodName - The name of the method.
types - The parameter types.
values - The parameter values.
defaultValue - The default value.
Returns:
The return value of the method or the default value if the method does not exist or is not accessible.

invokeGetter

public static int invokeGetter(java.lang.Object obj,
                               java.lang.String methodName,
                               int defaultValue)
Invokes the specified getter method if it exists.

Parameters:
obj - The object on which to invoke the method.
methodName - The name of the method.
defaultValue - This value is returned, if the method does not exist.
Returns:
The value returned by the getter method or the default value.

invokeGetter

public static long invokeGetter(java.lang.Object obj,
                                java.lang.String methodName,
                                long defaultValue)
Invokes the specified getter method if it exists.

Parameters:
obj - The object on which to invoke the method.
methodName - The name of the method.
defaultValue - This value is returned, if the method does not exist.
Returns:
The value returned by the getter method or the default value.

invokeGetter

public static boolean invokeGetter(java.lang.Object obj,
                                   java.lang.String methodName,
                                   boolean defaultValue)
Invokes the specified getter method if it exists.

Parameters:
obj - The object on which to invoke the method.
methodName - The name of the method.
defaultValue - This value is returned, if the method does not exist.
Returns:
The value returned by the getter method or the default value.

invokeGetter

public static java.lang.Object invokeGetter(java.lang.Object obj,
                                            java.lang.String methodName,
                                            java.lang.Object defaultValue)
Invokes the specified getter method if it exists.

Parameters:
obj - The object on which to invoke the method.
methodName - The name of the method.
defaultValue - This value is returned, if the method does not exist.
Returns:
The value returned by the getter method or the default value.

invokeStaticGetter

public static boolean invokeStaticGetter(java.lang.Class clazz,
                                         java.lang.String methodName,
                                         boolean defaultValue)
Invokes the specified getter method if it exists.

Parameters:
clazz - The object on which to invoke the method.
methodName - The name of the method.
defaultValue - This value is returned, if the method does not exist.
Returns:
The value returned by the getter method or the default value.

invoke

public static java.lang.Object invoke(java.lang.Object obj,
                                      java.lang.String methodName,
                                      boolean newValue)
                               throws java.lang.NoSuchMethodException
Invokes the specified setter method if it exists.

Parameters:
obj - The object on which to invoke the method.
methodName - The name of the method.
Throws:
java.lang.NoSuchMethodException

invoke

public static java.lang.Object invoke(java.lang.Object obj,
                                      java.lang.String methodName,
                                      int newValue)
                               throws java.lang.NoSuchMethodException
Invokes the specified method if it exists.

Parameters:
obj - The object on which to invoke the method.
methodName - The name of the method.
Throws:
java.lang.NoSuchMethodException

invoke

public static java.lang.Object invoke(java.lang.Object obj,
                                      java.lang.String methodName,
                                      float newValue)
                               throws java.lang.NoSuchMethodException
Invokes the specified setter method if it exists.

Parameters:
obj - The object on which to invoke the method.
methodName - The name of the method.
Throws:
java.lang.NoSuchMethodException

invoke

public static java.lang.Object invoke(java.lang.Object obj,
                                      java.lang.String methodName,
                                      java.lang.Class clazz,
                                      java.lang.Object newValue)
                               throws java.lang.NoSuchMethodException
Invokes the specified setter method if it exists.

Parameters:
obj - The object on which to invoke the method.
methodName - The name of the method.
Throws:
java.lang.NoSuchMethodException

invoke

public static java.lang.Object invoke(java.lang.Object obj,
                                      java.lang.String methodName,
                                      java.lang.Class[] clazz,
                                      java.lang.Object... newValue)
                               throws java.lang.NoSuchMethodException
Invokes the specified setter method if it exists.

Parameters:
obj - The object on which to invoke the method.
methodName - The name of the method.
Throws:
java.lang.NoSuchMethodException

invokeIfExists

public static void invokeIfExists(java.lang.Object obj,
                                  java.lang.String methodName)
Invokes the specified setter method if it exists.

Parameters:
obj - The object on which to invoke the method.
methodName - The name of the method.

invokeIfExists

public static void invokeIfExists(java.lang.Object obj,
                                  java.lang.String methodName,
                                  float newValue)
Invokes the specified setter method if it exists.

Parameters:
obj - The object on which to invoke the method.
methodName - The name of the method.

invokeIfExists

public static void invokeIfExists(java.lang.Object obj,
                                  java.lang.String methodName,
                                  boolean newValue)
Invokes the specified method if it exists.

Parameters:
obj - The object on which to invoke the method.
methodName - The name of the method.

invokeIfExists

public static void invokeIfExists(java.lang.Object obj,
                                  java.lang.String methodName,
                                  java.lang.Class clazz,
                                  java.lang.Object newValue)
Invokes the specified setter method if it exists.

Parameters:
obj - The object on which to invoke the method.
methodName - The name of the method.

invokeIfExistsWithEnum

public static void invokeIfExistsWithEnum(java.lang.Object obj,
                                          java.lang.String methodName,
                                          java.lang.String enumClassName,
                                          java.lang.String enumValueName)
Invokes the specified setter method if it exists.

Parameters:
obj - The object on which to invoke the method.
methodName - The name of the method.

Copyright 1996-2010 (c) by the authors and contributors of the JHotDraw project.
Some rights reserved.