org.exolab.jmscts.core
Class ClassHelper

java.lang.Object
  |
  +--org.exolab.jmscts.core.ClassHelper

public final class ClassHelper
extends java.lang.Object

Helper for loading classes and setting/getting any public properties.

Version:
$Revision: 1.3 $ $Date: 2004/01/31 13:44:24 $
Author:
Tim Anderson

Method Summary
static java.lang.reflect.Method getMethod(java.lang.Class type, java.lang.String name, java.lang.Object[] args)
          Helper to return a method given its name and a list of arguments
static java.lang.String getPrimitiveName(java.lang.Class wrapper)
          Helper to return the primitive type name associated with an object wrapper type
static java.lang.Class getPrimitiveType(java.lang.Class wrapper)
          Helper to return the primitive type associated with an object wrapper type
static Property[] getProperties(java.lang.Object object)
          Helper to returns the properties of an object
static java.lang.Object instantiate(java.lang.String className, Property[] properties)
          Create a new instance of an object identified by its class name, and set its properties
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

instantiate

public static java.lang.Object instantiate(java.lang.String className,
                                           Property[] properties)
                                    throws java.lang.ClassNotFoundException,
                                           java.lang.IllegalAccessException,
                                           java.lang.InstantiationException,
                                           java.lang.reflect.InvocationTargetException,
                                           java.lang.NoSuchMethodException
Create a new instance of an object identified by its class name, and set its properties
Parameters:
className - the name of the class
properties - the list of properties to set
Returns:
a new instance the specified class
Throws:
java.lang.ClassNotFoundException - if the class cannot be located
java.lang.IllegalAccessException - if the class or initializer is not accessible
java.lang.InstantiationException - if the instantiation fails
java.lang.reflect.InvocationTargetException - if the underlying method throws an exception
java.lang.NoSuchMethodException - if a matching method is not found

getProperties

public static Property[] getProperties(java.lang.Object object)
                                throws java.lang.IllegalAccessException,
                                       java.lang.reflect.InvocationTargetException
Helper to returns the properties of an object
Parameters:
object - the object to retrieve properties for
Returns:
the set of properties of object
Throws:
java.lang.IllegalAccessException - if the class or initializer is not accessible
java.lang.reflect.InvocationTargetException - if the underlying method throws an exception

getMethod

public static java.lang.reflect.Method getMethod(java.lang.Class type,
                                                 java.lang.String name,
                                                 java.lang.Object[] args)
                                          throws java.lang.NoSuchMethodException
Helper to return a method given its name and a list of arguments
Parameters:
type - the class to locate the method on
name - the method name
args - the list of arguments to match against, or null if the method takes no arguments
Returns:
the method matching the name and list of arguments
Throws:
java.lang.NoSuchMethodException - if the method cannot be found

getPrimitiveType

public static java.lang.Class getPrimitiveType(java.lang.Class wrapper)
Helper to return the primitive type associated with an object wrapper type
Parameters:
wrapper - the object wrapper class
Returns:
the associated primitive type, or the wrapper type, if there is no associated primitive type

getPrimitiveName

public static java.lang.String getPrimitiveName(java.lang.Class wrapper)
Helper to return the primitive type name associated with an object wrapper type
Parameters:
wrapper - the object wrapper class
Returns:
the associated primitive type name, or the wrapper type name, if there is no associated primitive type. Array types are returned in the form '[]'


Copyright © 2001-2004 JMS CTS Team. All Rights Reserved.