org.jaffa.persistence.engines.jdbcengine.util
Class MoldingService

java.lang.Object
  extended byorg.jaffa.persistence.engines.jdbcengine.util.MoldingService

public class MoldingService
extends Object

The MoldingService uses reflection to create/update persistent objects using ClassMetaData defintions. This can also set the initial state of a persistent object from the ResultSet.


Method Summary
static Object getInstanceValue(IPersistent object, ClassMetaData classMetaData, String attributeName)
          This gets the value of the attributeName from the Persistent object, using the accessor method cached in the ClassMetaData defintion.
static IPersistent getObject(ClassMetaData classMetaData)
          Creates an instance of the persistent class, as defined in the input ClassMetaData defintion.
static IPersistent getObject(ClassMetaData classMetaData, ResultSet rs, String engineType)
          Creates an instance of the persistent class, as defined in the input ClassMetaData defintion.
static void setInstanceValue(IPersistent object, ClassMetaData classMetaData, String attributeName, Object value)
          This sets the value of the attribute from the Persistent object, using the mutator method cached in the ClassMetaData defintion.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getObject

public static IPersistent getObject(ClassMetaData classMetaData)
                             throws ClassNotFoundException,
                                    InstantiationException,
                                    IllegalAccessException
Creates an instance of the persistent class, as defined in the input ClassMetaData defintion.

Parameters:
classMetaData - The ClassMetaData object, whose corresponding persistent class is to be instantiated.
Returns:
an instance of the Persistent class, defined in the ClassMetaData defintion.
Throws:
ClassNotFoundException - if the Persistent class is not found.
InstantiationException - if this Class represents an abstract class, an interface, an array class, a primitive type, or void; or if the class has no nullary constructor; or if the instantiation fails for some other reason.
IllegalAccessException - if the class or its nullary constructor is not accessible.

getInstanceValue

public static Object getInstanceValue(IPersistent object,
                                      ClassMetaData classMetaData,
                                      String attributeName)
                               throws IllegalAccessException,
                                      InvocationTargetException
This gets the value of the attributeName from the Persistent object, using the accessor method cached in the ClassMetaData defintion.

Parameters:
object - The Persistent object.
classMetaData - The ClassMetaData definition for the Persistent object.
attributeName - The attribute whose value will be returned.
Returns:
the value of the attribute.
Throws:
IllegalAccessException - if the accessor Method object enforces Java language access control and the underlying method is inaccessible.
InvocationTargetException - if the accessor method throws an exception.

setInstanceValue

public static void setInstanceValue(IPersistent object,
                                    ClassMetaData classMetaData,
                                    String attributeName,
                                    Object value)
                             throws IllegalAccessException,
                                    InvocationTargetException
This sets the value of the attribute from the Persistent object, using the mutator method cached in the ClassMetaData defintion.

Parameters:
object - The Persistent object.
classMetaData - The ClassMetaData definition for the Persistent object.
attributeName - The attribute whose value will be set.
value - The value to be set.
Throws:
IllegalAccessException - if the mutator Method object enforces Java language access control and the underlying method is inaccessible.
InvocationTargetException - if the mutator method throws an exception.

getObject

public static IPersistent getObject(ClassMetaData classMetaData,
                                    ResultSet rs,
                                    String engineType)
                             throws ClassNotFoundException,
                                    InstantiationException,
                                    IllegalAccessException,
                                    InvocationTargetException,
                                    SQLException,
                                    IOException
Creates an instance of the persistent class, as defined in the input ClassMetaData defintion. It will set the attributes using the values from the ResultSet.

Parameters:
classMetaData - The ClassMetaData object, whose corresponding persistent class is to be instantiated.
rs - The ResultSet used for creating the initial state of the persistent object.
engineType - The engine type as defined in init.xml
Returns:
an instance of the Persistent class, defined in the ClassMetaData defintion.
Throws:
ClassNotFoundException - if the Persistent class is not found.
InstantiationException - if this Class represents an abstract class, an interface, an array class, a primitive type, or void; or if the class has no nullary constructor; or if the instantiation fails for some other reason.
IllegalAccessException - if the class or its nullary constructor is not accessible.
InvocationTargetException - if the mutator method throws an exception.
SQLException - if a database access error occurs.
IOException - if any error occurs in reading the data from the database.


Copyright © 2002-2004 JAFFA Project.