de.unihalle.informatik.Alida.dataio.provider.helpers
Class ALDParametrizedClassDataIOHelper

java.lang.Object
  extended by de.unihalle.informatik.Alida.dataio.provider.helpers.ALDParametrizedClassDataIOHelper

public class ALDParametrizedClassDataIOHelper
extends java.lang.Object

Helper class to configure and handle parametrized class objects.

Author:
posch, moeller

Constructor Summary
ALDParametrizedClassDataIOHelper()
           
 
Method Summary
static java.util.HashMap<java.lang.String,java.lang.reflect.Field> getAnnotatedFields(java.lang.Class<?> myclass)
          Return all fields for member variables of myclass or any of its super classes which is annotated with ALDClassParameter.
static java.lang.Object getValue(java.lang.reflect.Field field, java.lang.Object obj)
          Return the value of the member variable associated with field in the object obj.
static void setValue(java.lang.reflect.Field field, java.lang.Object obj, java.lang.Object value)
          Sets the value of the member variable associated with field in the object obj.
static void setValue(java.lang.String name, java.lang.Object obj, java.lang.Object value)
          Sets the field with given name of object objto value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ALDParametrizedClassDataIOHelper

public ALDParametrizedClassDataIOHelper()
Method Detail

getAnnotatedFields

public static java.util.HashMap<java.lang.String,java.lang.reflect.Field> getAnnotatedFields(java.lang.Class<?> myclass)
Return all fields for member variables of myclass or any of its super classes which is annotated with ALDClassParameter.

Parameters:
myclass -
Returns:
fields of annotated member variables

getValue

public static java.lang.Object getValue(java.lang.reflect.Field field,
                                        java.lang.Object obj)
Return the value of the member variable associated with field in the object obj.

Parameters:
field - field of the member variable
obj - from which to return the value
Returns:
value of the field in obj

setValue

public static void setValue(java.lang.reflect.Field field,
                            java.lang.Object obj,
                            java.lang.Object value)
                     throws java.lang.IllegalAccessException
Sets the value of the member variable associated with field in the object obj.

Parameters:
field - field of the member variable
obj - from which to return the value
Throws:
java.lang.IllegalAccessException

setValue

public static void setValue(java.lang.String name,
                            java.lang.Object obj,
                            java.lang.Object value)
                     throws java.lang.IllegalAccessException
Sets the field with given name of object objto value.

The method recursively iterates over all class fields and fields of super classes to find the requested field. An exception is thrown if the requested field could not be found or accessed.

Parameters:
name - Name of field to set.
obj - Object in which field is to set.
value - Value to set for the field.
Throws:
java.lang.IllegalAccessException