|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjcckit.util.Factory
public class Factory
General purpose factory method based on ConfigParameters
and Java's Reflection API.
Field Summary | |
---|---|
static String |
CLASS_NAME_KEY
The constant defining the key className. |
Method Summary | |
---|---|
static Object |
create(ConfigParameters configParameters)
Creates an object based on the specified configuration parameters. |
static Object |
create(ConfigParameters configParameters,
String defaultClassName)
Creates an object based on the specified configuration parameters and default class name. |
static Object |
create(String className)
Creates an instance of the specified class. |
static Object |
createOrGet(ConfigParameters configParameters,
Object defaultObject)
Creates an object based on the specified configuration parameters or returns the default object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String CLASS_NAME_KEY
Method Detail |
---|
public static Object create(String className)
className
- Fully-qualified name of a class with a default
constructor.
IllegalArgumentException
- if the instance could be created.public static Object create(ConfigParameters configParameters)
CLASS_NAME_KEY
.
The constructor with a single argument of the type
ConfigParameter is invoked with the argument
configParameters. If such a constructor
does not exists the default constructor is invoked. If
neither of these constructors exist a FactoryException
is thrown.
configParameters
- Configuration parameters.
IllegalArgumentException
- if key className is missing.
FactoryException
- wrapping any kind of exception or error occured.public static Object create(ConfigParameters configParameters, String defaultClassName)
CLASS_NAME_KEY
is missed in
configParameters defaultClassName is used.
Otherwise it works as create(jcckit.util.ConfigParameters)
.
configParameters
- Configuration parameters.defaultClassName
- Default class name.
FactoryException
- wrapping any kind of exception or error occured.public static Object createOrGet(ConfigParameters configParameters, Object defaultObject)
create(jcckit.util.ConfigParameters)
, except that is does
not throw an IllegalArgumentException if key className
is missing. Instead defaultObject is returned.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |