Overview | Package | Class | Use | Tree | Deprecated | Index | Help

PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## contrib.ch.randelshofer.quaqua.util
Class Methods

    java.lang.Object
      contrib.ch.randelshofer.quaqua.util.Methods

    public class Methods

extends java.lang.Object

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

Version:
  1.3.1 2006-09-18 Fixed javadoc warnings.
  1.2 2006-08-20 Additional invokeIfExists method added.
  1.2 2006-05-07 Added invokeNew method.
  1.1 2006-02-18 Added more convenience methods.
  1.0 September 24, 2005 Created.
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[] types, java.lang.Object[] values)` Invokes the specified 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 parameterClass, 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` | `invokeIfExists(java.lang.Object obj, java.lang.String methodName, int 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 static method if it exists.
`static java.lang.Object` | `invokeStatic(java.lang.Class clazz, java.lang.String methodName, java.lang.Class type, java.lang.Object value)` Invokes the specified static method if it exists.
`static java.lang.Object` | `invokeStatic(java.lang.String clazz, java.lang.String methodName)` Invokes the specified static 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 static 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 static method if it exists.
`static java.lang.Object` | `invokeStatic(java.lang.String clazz, java.lang.String methodName, java.lang.Class type, java.lang.Object value)` Invokes the specified static 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.
`static java.lang.Object` | `newInstance(java.lang.Class clazz, java.lang.Class[] types, java.lang.Object[] values)` Invokes the specified constructor 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`

### invoke

    public static java.lang.Object invoke(java.lang.Object obj,
                                          java.lang.String methodName,
                                          java.lang.Class[] types,
                                          java.lang.Object[] values)
                                   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.
    `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.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 static 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 static 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 static 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 type,
                                                java.lang.Object value)
                                         throws java.lang.NoSuchMethodException

  Invokes the specified static method if it exists.

  Parameters:
    `clazz` - The class on which to invoke the method.
    `methodName` - The name of the method.
    `type` - The parameter types.
    `value` - 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 static 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.

### invokeStatic

    public static java.lang.Object invokeStatic(java.lang.Class clazz,
                                                java.lang.String methodName,
                                                java.lang.Class type,
                                                java.lang.Object value)
                                         throws java.lang.NoSuchMethodException

  Invokes the specified static method if it exists.

  Parameters:
    `clazz` - The class on which to invoke the method.
    `methodName` - The name of the method.
    `type` - The parameter type.
    `value` - The parameter value.
  Returns:
    The return value of the method or the default value if the method does not exist or is not accessible.
  Throws:
    `java.lang.NoSuchMethodException`

### 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 class 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`

### 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,
                                      int 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,
                                      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 parameterClass,
                                      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.

### newInstance

    public static java.lang.Object newInstance(java.lang.Class clazz,
                                               java.lang.Class[] types,
                                               java.lang.Object[] values)
                                        throws java.lang.NoSuchMethodException,
                                               java.lang.InstantiationException,
                                               java.lang.IllegalAccessException,
                                               java.lang.reflect.InvocationTargetException

  Invokes the specified constructor if it exists.

  Parameters:
    `clazz` - The Class on which to invoke the constructor.
    `types` - The parameter types of the constructor.
    `values` - The parameter values of the constructor.
  Throws:
    `java.lang.NoSuchMethodException`
    `java.lang.InstantiationException`
    `java.lang.IllegalAccessException`
    `java.lang.reflect.InvocationTargetException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help

PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD