de.smartics.exceptions.report.utils
Class RuntimeUtils

Package class diagram package RuntimeUtils
java.lang.Object
  extended by de.smartics.exceptions.report.utils.RuntimeUtils

public final class RuntimeUtils
     
     
extends Object

Utilities to instantiate classes and access their runtime information.


Constructor Summary
RuntimeUtils(ClassLoader classLoader)
          Default constructor.
 
Method Summary
 Class<?> loadClass(com.thoughtworks.qdox.model.JavaClass classDoc)
          Loads the class referenced by the given classDoc.
 Class<?> loadClass(String className)
          Loads the given class.
static Enum<?> loadEnumInstance(Class<?> clazz, String identifier)
          Loads the enumeration element instance with the given identifier from the given class.
 Object loadInstance(com.thoughtworks.qdox.model.JavaField fieldDoc)
          Loads the instance referenced by the given fieldDoc.
static Object loadStaticFieldInstance(Class<?> clazz, String identifier)
          Loads the static property instance with the given identifier from the given class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RuntimeUtils

public RuntimeUtils(ClassLoader classLoader)
Default constructor.

Parameters:
classLoader - the class loader to use to instantiate the referenced class.
Method Detail

loadInstance

public Object loadInstance(com.thoughtworks.qdox.model.JavaField fieldDoc)
                    throws ClassNotFoundException,
                           NullPointerException
Loads the instance referenced by the given fieldDoc.

Parameters:
fieldDoc - the property of a class to be instantiated. This may be an enumeration element or a constant in a class.
Returns:
the instance if fieldDoc references an enumeration element or a constant, null otherwise.
Throws:
ClassNotFoundException - if the class of the field or any depending classes cannot be loaded.
NullPointerException - if fieldDoc is null.

loadClass

public Class<?> loadClass(com.thoughtworks.qdox.model.JavaClass classDoc)
                   throws ClassNotFoundException,
                          NullPointerException
Loads the class referenced by the given classDoc.

Parameters:
classDoc - the class documentation to load the class.
Returns:
the class instance.
Throws:
NullPointerException - if classDoc is null.
ClassNotFoundException - if the class of the field or any depending classes cannot be loaded.

loadClass

public Class<?> loadClass(String className)
                   throws ClassNotFoundException,
                          NullPointerException
Loads the given class.

Parameters:
className - the fully qualified class name.
Returns:
the class instance.
Throws:
NullPointerException - if className is null.
ClassNotFoundException - if the class cannot be loaded.

loadEnumInstance

public static Enum<?> loadEnumInstance(Class<?> clazz,
                                       String identifier)
                                throws NullPointerException
Loads the enumeration element instance with the given identifier from the given class.

Parameters:
clazz - the enumeration class that contains the requested enumeration element.
identifier - the identifier of the enumeration element to return.
Returns:
the enumeration element instance or null if the class is not an enumeration or the enumeration does not contain an element with a name matching the given identifier.
Throws:
NullPointerException - if clazz or identifier is null.

loadStaticFieldInstance

public static Object loadStaticFieldInstance(Class<?> clazz,
                                             String identifier)
                                      throws NullPointerException
Loads the static property instance with the given identifier from the given class.

Parameters:
clazz - the class that contains the requested static property.
identifier - the identifier of the static property to return.
Returns:
the static property instance or null if the class does not contain a static property with a name matching the given identifier.
Throws:
NullPointerException - if clazz or identifier is null.


Copyright © 2007-2013 Kronseder & Reiner GmbH - smartics. All Rights Reserved.