Back to index

wims  3.65+svn20090927
Static Public Member Functions
fr.ove.utils.Factory Class Reference

A little factory to dynamically instanciate classes. More...

List of all members.

Static Public Member Functions

static Object getClassInstance (String className)
 Returns an instance of the class with the specified name.

Detailed Description

A little factory to dynamically instanciate classes.

Author:
1999 DIRAT Laurent
Version:
1.0 29/10/1999

Definition at line 14 of file Factory.java.


Member Function Documentation

static Object fr.ove.utils.Factory.getClassInstance ( String  className) [inline, static]

Returns an instance of the class with the specified name.

Parameters:
classNamethe name of the class we want an instance.

Definition at line 19 of file Factory.java.

                                                            {
        Object newClass = null;
        
       try {
              Class c = Class.forName(className);
              
              try {
                     newClass = c.newInstance();
              }
              catch (InstantiationException e ) {
                     System.out.println(className + " cannot be instantiated");
                     return null;
              }
              catch (IllegalAccessException e ) {
                     System.out.println(className + " impossible to access default constructor");
                     return null;
              }
              catch (NoClassDefFoundError e ) {
                     System.out.println("No definition of " + className + " can be found");
              }

        }
        catch (ClassNotFoundException e) {
              System.out.println("Class " + className + " not found");
                     return null;
        }

        return newClass;
    }

Here is the caller graph for this function:


The documentation for this class was generated from the following file: