This project has retired. For details please refer to its Attic page.
ReflectionUtils (Apache Gora 0.2 API)

org.apache.gora.util
Class ReflectionUtils

java.lang.Object
  extended by org.apache.gora.util.ReflectionUtils

public class ReflectionUtils
extends Object

Utility methods related to reflection


Field Summary
static Class<?>[] EMPTY_CLASS_ARRAY
           
static Object[] EMPTY_OBJECT_ARRAY
           
 
Constructor Summary
ReflectionUtils()
           
 
Method Summary
static
<T> Constructor<T>
getConstructor(Class<T> clazz)
          Returns the empty argument constructor of the class.
static Object getStaticField(Class<?> clazz, String fieldName)
          Returns the value of a named static field
static boolean hasConstructor(Class<?> clazz)
          Returns whether the class defines an empty argument constructor.
static
<T> T
newInstance(Class<T> clazz)
          Constructs a new instance of the class using the no-arg constructor.
static Object newInstance(String classStr)
          Constructs a new instance of the class using the no-arg constructor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_CLASS_ARRAY

public static Class<?>[] EMPTY_CLASS_ARRAY

EMPTY_OBJECT_ARRAY

public static Object[] EMPTY_OBJECT_ARRAY
Constructor Detail

ReflectionUtils

public ReflectionUtils()
Method Detail

getConstructor

public static <T> Constructor<T> getConstructor(Class<T> clazz)
                                     throws SecurityException,
                                            NoSuchMethodException
Returns the empty argument constructor of the class.

Throws:
SecurityException
NoSuchMethodException

hasConstructor

public static boolean hasConstructor(Class<?> clazz)
                              throws SecurityException,
                                     NoSuchMethodException
Returns whether the class defines an empty argument constructor.

Throws:
SecurityException
NoSuchMethodException

newInstance

public static <T> T newInstance(Class<T> clazz)
                     throws InstantiationException,
                            IllegalAccessException,
                            SecurityException,
                            NoSuchMethodException,
                            IllegalArgumentException,
                            InvocationTargetException
Constructs a new instance of the class using the no-arg constructor.

Parameters:
clazz - the class of the object
Returns:
a new instance of the object
Throws:
InstantiationException
IllegalAccessException
SecurityException
NoSuchMethodException
IllegalArgumentException
InvocationTargetException

newInstance

public static Object newInstance(String classStr)
                          throws InstantiationException,
                                 IllegalAccessException,
                                 ClassNotFoundException,
                                 SecurityException,
                                 IllegalArgumentException,
                                 NoSuchMethodException,
                                 InvocationTargetException
Constructs a new instance of the class using the no-arg constructor.

Parameters:
classStr - the class name of the object
Returns:
a new instance of the object
Throws:
InstantiationException
IllegalAccessException
ClassNotFoundException
SecurityException
IllegalArgumentException
NoSuchMethodException
InvocationTargetException

getStaticField

public static Object getStaticField(Class<?> clazz,
                                    String fieldName)
                             throws IllegalArgumentException,
                                    SecurityException,
                                    IllegalAccessException,
                                    NoSuchFieldException
Returns the value of a named static field

Throws:
IllegalArgumentException
SecurityException
IllegalAccessException
NoSuchFieldException


Copyright © 2010-2013 The Apache Software Foundation. All Rights Reserved.