org.camunda.bpm.engine.impl.util
Class ReflectUtil

java.lang.Object
  extended by org.camunda.bpm.engine.impl.util.ReflectUtil

public abstract class ReflectUtil
extends Object

Author:
Tom Baeyens

Constructor Summary
ReflectUtil()
           
 
Method Summary
static ClassLoader getClassLoader()
           
static Field getField(String fieldName, Class<?> clazz)
          Returns the field of the given class or null if it doesnt exist.
static Field getField(String fieldName, Object object)
          Returns the field of the given object or null if it doesnt exist.
static Method getMethod(Class declaringType, String methodName, Class<?>... parameterTypes)
          Finds a method by name and parameter types.
static URL getResource(String name)
           
static InputStream getResourceAsStream(String name)
           
static String getResourceUrlAsString(String name)
           
static Method getSetter(String fieldName, Class<?> clazz, Class<?> fieldType)
          Returns the setter-method for the given field name or null if no setter exists.
static Method getSingleSetter(String fieldName, Class<?> clazz)
          Returns a setter method based on the fieldName and the java beans setter naming convention or null if none exists.
static
<T> T
instantiate(Class<T> type)
           
static Object instantiate(String className)
           
static Object instantiate(String className, Object[] args)
           
static Object invoke(Object target, String methodName, Object[] args)
           
static Class<?> loadClass(String className)
           
static void setField(Field field, Object object, Object value)
           
static URI urlToURI(URL url)
          Converts an url to an uri.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReflectUtil

public ReflectUtil()
Method Detail

getClassLoader

public static ClassLoader getClassLoader()

loadClass

public static Class<?> loadClass(String className)

getResourceAsStream

public static InputStream getResourceAsStream(String name)

getResource

public static URL getResource(String name)

getResourceUrlAsString

public static String getResourceUrlAsString(String name)

urlToURI

public static URI urlToURI(URL url)
Converts an url to an uri. Escapes whitespaces if needed.

Parameters:
url - the url to convert
Returns:
the resulting uri
Throws:
ProcessEngineException - if the url has invalid syntax

instantiate

public static Object instantiate(String className)

instantiate

public static <T> T instantiate(Class<T> type)

invoke

public static Object invoke(Object target,
                            String methodName,
                            Object[] args)

getField

public static Field getField(String fieldName,
                             Object object)
Returns the field of the given object or null if it doesnt exist.


getField

public static Field getField(String fieldName,
                             Class<?> clazz)
Returns the field of the given class or null if it doesnt exist.


setField

public static void setField(Field field,
                            Object object,
                            Object value)

getSetter

public static Method getSetter(String fieldName,
                               Class<?> clazz,
                               Class<?> fieldType)
Returns the setter-method for the given field name or null if no setter exists.


getSingleSetter

public static Method getSingleSetter(String fieldName,
                                     Class<?> clazz)
Returns a setter method based on the fieldName and the java beans setter naming convention or null if none exists. If multiple setters with different parameter types are present, an exception is thrown. If they have the same parameter type, one of those methods is returned.


instantiate

public static Object instantiate(String className,
                                 Object[] args)

getMethod

public static Method getMethod(Class declaringType,
                               String methodName,
                               Class<?>... parameterTypes)
Finds a method by name and parameter types.

Parameters:
declaringType - the name of the class
methodName - the name of the method to look for
parameterTypes - the types of the parameters


Copyright © 2014 camunda services GmbH. All rights reserved.