de.smartics.analysis.javadoc.runtime
Class RuntimeUtils

Package class diagram package RuntimeUtils
java.lang.Object
  extended by de.smartics.analysis.javadoc.runtime.RuntimeUtils

public final class RuntimeUtils
     
     
extends Object

Utilities to instantiate classes and access their runtime information.

Author:
Robert Reiner

Method Summary
static Class<?> loadClass(ClassLoader classLoader, com.sun.javadoc.ClassDoc classDoc)
          Loads the class referenced by the given classDoc.
static Enum<?> loadEnumInstance(Class<?> clazz, String identifier)
          Loads the enumeration element instance with the given identifier from the given class.
static Object loadInstance(ClassLoader classLoader, com.sun.javadoc.FieldDoc 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
 

Method Detail

loadInstance

public static Object loadInstance(ClassLoader classLoader,
                                  com.sun.javadoc.FieldDoc fieldDoc)
                           throws ClassNotFoundException,
                                  NullPointerException
Loads the instance referenced by the given fieldDoc.

Parameters:
classLoader - the class loader to use to instantiate the referenced class.
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 classLoader or fieldDoc is null.

loadClass

public static Class<?> loadClass(ClassLoader classLoader,
                                 com.sun.javadoc.ClassDoc classDoc)
                          throws ClassNotFoundException,
                                 NullPointerException
Loads the class referenced by the given classDoc.

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

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 © 2008-2011 Kronseder & Reiner GmbH - smartics. All Rights Reserved.