org.openarchitectureware.workflow.util
Class ReflectionUtil

java.lang.Object
  extended by org.openarchitectureware.workflow.util.ReflectionUtil

public class ReflectionUtil
extends java.lang.Object

Provides static helper methods to deal with element fields using reflection.

Author:
Clemens Kadura (zAJKa)

Method Summary
static boolean checkFields(java.lang.Object element)
          check if the element has member fields.
static java.util.List<java.lang.String> getFieldNames(java.lang.Object element)
          returns a list of names of the fields.
static java.lang.Object getFieldValue(java.lang.Object object, java.lang.String name)
          Returns the value of a field of an object.
static java.lang.String getNameToString(java.lang.Object element)
          Null save toString
static java.lang.String getSimpleName(java.lang.Object element)
          return a String representation of the element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getSimpleName

public static java.lang.String getSimpleName(java.lang.Object element)
return a String representation of the element. It is "null", the content of a String or the simple class name for all other types.
Hint: Primitives wrapper classes are not handled specially, so the result is not the primitive value but the class name. But since getFieldValue(..) returns a String representation of primitives, this should not be a problem here.

Parameters:
element - the element
Returns:
the string representation

getNameToString

public static java.lang.String getNameToString(java.lang.Object element)
Null save toString

Parameters:
element - the element
Returns:
the string representation

checkFields

public static boolean checkFields(java.lang.Object element)
check if the element has member fields. For an array it checks if it is not empty.

Parameters:
element - the element
Returns:
yes or no

getFieldNames

public static java.util.List<java.lang.String> getFieldNames(java.lang.Object element)
returns a list of names of the fields. For an array it returns "[i]" as name where i is the position in the array.

Parameters:
element -
Returns:

getFieldValue

public static java.lang.Object getFieldValue(java.lang.Object object,
                                             java.lang.String name)
Returns the value of a field of an object.
For primitives it returns a string representation.
It returns null in case of any exceptions.

Parameters:
object - the questioned object
name - the name of the field
Returns:
the value