net.sf.arise.util
Class ReflectionUtil

java.lang.Object
  |
  +--net.sf.arise.util.ReflectionUtil

public final class ReflectionUtil
extends java.lang.Object

Author:
Maja S Bratseth

Method Summary
static void copy(java.lang.reflect.Field field, java.lang.Object oldObject, java.lang.Object newObject)
          Copies the value of the given field from oldObjectnewObject, regardless of the field's access modifiers.
static java.lang.reflect.Field[] getAllFields(java.lang.Class c)
          Returns all the fields declared in a class or any of its superclasses
static java.lang.reflect.Field[] getNonStaticDeclaredFields(java.lang.Class clazz)
           
static java.lang.Class getPrimitiveType(java.lang.Class clazz)
           
static java.lang.String getSimpleClassName(java.lang.Class aClass)
          Returns the simple class name for the given class object.
static java.lang.String getSimpleClassName(java.lang.String className)
          Returns the simple class name for the given (full or simple) class name.
static java.lang.reflect.Field[] getStaticDeclaredFields(java.lang.Class clazz)
           
static java.lang.String getTypeString(java.lang.Class clazz)
           
static java.lang.Object getValue(java.lang.reflect.Field field, java.lang.Object object)
          Gets the value of the given field from the given object, regardless of the field's access modifiers.
static void setValue(java.lang.reflect.Field field, java.lang.Object object, java.lang.Object value)
          Sets the given value of the given field on the given object.
static void sortFields(java.lang.reflect.Field[] fields)
           
static java.lang.String stringValueOf(java.lang.Object object)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getSimpleClassName

public static java.lang.String getSimpleClassName(java.lang.Class aClass)

Returns the simple class name for the given class object.

Parameters:
aClass - a class object
Returns:
the simple class name for the class object

getSimpleClassName

public static java.lang.String getSimpleClassName(java.lang.String className)

Returns the simple class name for the given (full or simple) class name.

Parameters:
className - a class name, with or without package qualifiers
Returns:
the simple class name (without package qualifiers)

getAllFields

public static java.lang.reflect.Field[] getAllFields(java.lang.Class c)
Returns all the fields declared in a class or any of its superclasses

Parameters:
c - the class to get the fields from, not null
Returns:
all the fields that is declared in the given class or in any of its superclasses, regardless of modifiers

copy

public static void copy(java.lang.reflect.Field field,
                        java.lang.Object oldObject,
                        java.lang.Object newObject)
                 throws java.lang.IllegalAccessException
Copies the value of the given field from oldObjectnewObject, regardless of the field's access modifiers. The field must not be final.

Parameters:
field - the field to copy, not null, not final
oldObject - the object to copy the value from, not null
newObject - the object to copy the alue into, not null
java.lang.IllegalAccessException

getValue

public static java.lang.Object getValue(java.lang.reflect.Field field,
                                        java.lang.Object object)
                                 throws java.lang.IllegalAccessException
Gets the value of the given field from the given object, regardless of the field's access modifiers. The field must not be final.

Parameters:
field - the field to copy, not null, not final
java.lang.IllegalAccessException

setValue

public static void setValue(java.lang.reflect.Field field,
                            java.lang.Object object,
                            java.lang.Object value)
                     throws java.lang.IllegalAccessException
Sets the given value of the given field on the given object. to newObject, regardless of the field's access modifiers. The field must not be final.

Parameters:
field - the field to copy, not null, not final
java.lang.IllegalAccessException

getPrimitiveType

public static java.lang.Class getPrimitiveType(java.lang.Class clazz)

getTypeString

public static java.lang.String getTypeString(java.lang.Class clazz)

stringValueOf

public static java.lang.String stringValueOf(java.lang.Object object)

getStaticDeclaredFields

public static java.lang.reflect.Field[] getStaticDeclaredFields(java.lang.Class clazz)

getNonStaticDeclaredFields

public static java.lang.reflect.Field[] getNonStaticDeclaredFields(java.lang.Class clazz)

sortFields

public static void sortFields(java.lang.reflect.Field[] fields)


All code and documentation is

Copyright (c) : 2000-2003 Kjetil Valstadsve & Maja S. Bratseth