Ontimize 5.2072EN

com.ontimize.util
Class ClassHandler

java.lang.Object
  extended bycom.ontimize.util.ClassHandler

public class ClassHandler
extends java.lang.Object

Utility class to create new class objects.

Uses Reflection Java API.

Since:
Ontimize 5.2059EN
Author:
Imatia Innovation S.L.

Nested Class Summary
static class ClassHandler.BooleanStringConverter
           
static class ClassHandler.ColorStringConverter
           
static class ClassHandler.DefaultStringConverter
           
static interface ClassHandler.StringConverter
           
 
Field Summary
protected static java.util.Map PRIMITIVE_CLASS_OBJECT
           
protected static java.util.Map PRIMITIVE_CLASS_TYPE
           
protected static java.util.Map STRING_CONVERTERS
           
 
Constructor Summary
ClassHandler()
           
 
Method Summary
static java.lang.Object getClassInstance(java.lang.String className)
          Returns the Object instance for the given className
static java.lang.Class getClassObject(java.lang.String className)
          Returns the Class object for the given className.
static java.lang.Class getClassObject(java.lang.String className, boolean primitiveTypes)
          Returns the Class object for the given className.
static java.lang.reflect.Method getMethodObject(java.lang.Object source, java.lang.String name)
          Returns the Method of the given Object source with the given name.
static java.lang.reflect.Method getMethodObject(java.lang.Object source, java.lang.String name, java.lang.Class[] clazz)
          Returns the Method of the given Object source with the name and the parameter class.
static java.lang.Object getValueObject(java.lang.String className, java.lang.String value)
          Returns the given String value converted into the className Class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PRIMITIVE_CLASS_TYPE

protected static final java.util.Map PRIMITIVE_CLASS_TYPE

PRIMITIVE_CLASS_OBJECT

protected static final java.util.Map PRIMITIVE_CLASS_OBJECT

STRING_CONVERTERS

protected static java.util.Map STRING_CONVERTERS
Constructor Detail

ClassHandler

public ClassHandler()
Method Detail

getClassObject

public static java.lang.Class getClassObject(java.lang.String className)
                                      throws java.lang.IllegalArgumentException

Returns the Class object for the given className.

Parameters:
className - The class name of the Class object.
Returns:
Class object for the given className.
Throws:
java.lang.IllegalArgumentException

getClassObject

public static java.lang.Class getClassObject(java.lang.String className,
                                             boolean primitiveTypes)
                                      throws java.lang.IllegalArgumentException

Returns the Class object for the given className.

Allows to return Class objects for the Java primitive types.

Parameters:
className - The class name of the Class object.
primitiveTypes - If true, return the Class for Java primitive types.
Returns:
Class object for the given className.
Throws:
java.lang.IllegalArgumentException

getClassInstance

public static java.lang.Object getClassInstance(java.lang.String className)
                                         throws java.lang.IllegalArgumentException

Returns the Object instance for the given className

Parameters:
className - The class name of the Class object.
Returns:
Object instance for the given className
Throws:
java.lang.IllegalArgumentException

getMethodObject

public static java.lang.reflect.Method getMethodObject(java.lang.Object source,
                                                       java.lang.String name)

Returns the Method of the given Object source with the given name.

Parameters:
source - Object with the method.
name - of the method to return.
Returns:
Method with the given name

getMethodObject

public static java.lang.reflect.Method getMethodObject(java.lang.Object source,
                                                       java.lang.String name,
                                                       java.lang.Class[] clazz)

Returns the Method of the given Object source with the name and the parameter class.

Parameters:
source - Object with the method.
name - of the method to return.
clazz - Array with the Class paramters of the method.
Returns:
Method with the given name and clazz parameters.

getValueObject

public static java.lang.Object getValueObject(java.lang.String className,
                                              java.lang.String value)
                                       throws java.lang.IllegalArgumentException

Returns the given String value converted into the className Class.

Some classes have a custom converter, else the default converter uses the contructor class with the String parameter (a IllegalArgumentException can be thrown).

Parameters:
className - The class name of the returned object value.
value - The String to convert.
Returns:
The string value converted.
Throws:
java.lang.IllegalArgumentException

Ontimize