net.sourceforge.jdbcimporter.util
Class CustomObjectFactory

java.lang.Object
  extended bynet.sourceforge.jdbcimporter.util.CustomObjectFactory

public class CustomObjectFactory
extends java.lang.Object

The CustomObjectFactory class is a factory for custom objects. The factory can also apply properties to the custom object via Java Bean setter methods.

Version:
0.6
Author:
Chris Nagy

Field Summary
protected  java.util.Map mapping
          The mapping between types and implementation class names.
protected  java.lang.Class objBaseClass
          The base interface or class for all custom object created.
 
Constructor Summary
CustomObjectFactory(java.lang.Class objClass)
          Creates a new custom object factory that will create objects of the given class.
 
Method Summary
 void addMapping(java.lang.String prefix, java.lang.String className)
          Add a mapping of a short prefix to a class name that is an ancestor of the base class.
protected  void applyProperty(java.lang.Object obj, java.lang.String name, java.lang.String value)
          Set the property in the object with the value.
 java.lang.Object getObjectImpl(java.lang.String prefix, java.util.Map properties)
          Create a custom object based on the class name mapped to the prefix and apply the properties to the custom object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mapping

protected java.util.Map mapping
The mapping between types and implementation class names.


objBaseClass

protected java.lang.Class objBaseClass
The base interface or class for all custom object created.

Constructor Detail

CustomObjectFactory

public CustomObjectFactory(java.lang.Class objClass)
Creates a new custom object factory that will create objects of the given class.

Parameters:
objClass - the base class of all custom objects
Method Detail

addMapping

public void addMapping(java.lang.String prefix,
                       java.lang.String className)
Add a mapping of a short prefix to a class name that is an ancestor of the base class.

Parameters:
prefix - the string prefix
className - the class name

getObjectImpl

public java.lang.Object getObjectImpl(java.lang.String prefix,
                                      java.util.Map properties)
                               throws InvalidCustomObjectDefException
Create a custom object based on the class name mapped to the prefix and apply the properties to the custom object.

Parameters:
prefix - the prefix mapping
properties - the properties to apply
Returns:
the custom object
Throws:
InvalidCustomObjectDefException - if the prefix is not mapped, the class is not an ancestor of the base class or a property could not be applied to the custom object.

applyProperty

protected void applyProperty(java.lang.Object obj,
                             java.lang.String name,
                             java.lang.String value)
                      throws InvalidCustomObjectDefException
Set the property in the object with the value.

Parameters:
obj - the object
name - the name of the property
value - the value
Throws:
InvalidCustomObjectDefException