ojb.broker.accesslayer
Class RowReaderDefaultImpl

java.lang.Object
  |
  +--ojb.broker.accesslayer.RowReaderDefaultImpl
All Implemented Interfaces:
RowReader, java.io.Serializable
Direct Known Subclasses:
RowReaderTestImpl

public class RowReaderDefaultImpl
extends java.lang.Object
implements RowReader

See Also:
Serialized Form

Constructor Summary
RowReaderDefaultImpl()
           
 
Method Summary
protected  java.lang.Object buildWithMultiArgsConstructor(ClassDescriptor cld, java.lang.Object[] row, java.lang.reflect.Constructor multiArgsConstructor)
           
protected  java.lang.Object buildWithReflection(ClassDescriptor cld, java.lang.Object[] row)
           
 void readObjectArrayFrom(java.sql.ResultSet rs, ClassDescriptor descriptor, java.lang.Object[] row)
          materialize a single object, described by cld, from the first row of the ResultSet rs.
 java.lang.Object readObjectFrom(java.lang.Object[] row, ClassDescriptor descriptor)
          materialize a single object, described by cld, from the first row of the ResultSet rs.
 void readPkValuesFrom(java.sql.ResultSet rs, ClassDescriptor cld, java.lang.Object[] row)
          Read primary key fields from the current ResultRow into the Object[] row.# ConversionStrategies are applied here!
protected  ClassDescriptor selectClassDescriptor(java.lang.Object[] row, ClassDescriptor cld)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RowReaderDefaultImpl

public RowReaderDefaultImpl()
Method Detail

readObjectFrom

public java.lang.Object readObjectFrom(java.lang.Object[] row,
                                       ClassDescriptor descriptor)
                                throws PersistenceBrokerException
materialize a single object, described by cld, from the first row of the ResultSet rs. There are two possible strategies: 1. The persistent class defines a public constructor with arguments matching the persistent primitive attributes of the class. In this case we build an array args of arguments from rs and call Constructor.newInstance(args) to build an object. 2. The persistent class does not provide such a constructor, but only a public default constructor. In this case we create an empty instance with Class.newInstance(). This empty instance is then filled by calling Field::set(obj,getObject(matchingColumn)) for each attribute. The second strategy needs n calls to Field::set() which are much more expensive than the filling of the args array in the first strategy. client applications should therefore define adequate constructors to benefit from performance gain of the first strategy.

Specified by:
readObjectFrom in interface RowReader
PersistenceBrokerException

readObjectArrayFrom

public void readObjectArrayFrom(java.sql.ResultSet rs,
                                ClassDescriptor descriptor,
                                java.lang.Object[] row)
                         throws PersistenceBrokerException
materialize a single object, described by cld, from the first row of the ResultSet rs. There are two possible strategies: 1. The persistent class defines a public constructor with arguments matching the persistent primitive attributes of the class. In this case we build an array args of arguments from rs and call Constructor.newInstance(args) to build an object. 2. The persistent class does not provide such a constructor, but only a public default constructor. In this case we create an empty instance with Class.newInstance(). This empty instance is then filled by calling Field::set(obj,getObject(matchingColumn)) for each attribute. The second strategy needs n calls to Field::set() which are much more expensive than the filling of the args array in the first strategy. client applications should therefore define adequate constructors to benefit from performance gain of the first strategy.

Specified by:
readObjectArrayFrom in interface RowReader
PersistenceBrokerException

selectClassDescriptor

protected ClassDescriptor selectClassDescriptor(java.lang.Object[] row,
                                                ClassDescriptor cld)
                                         throws PersistenceBrokerException
PersistenceBrokerException

buildWithReflection

protected java.lang.Object buildWithReflection(ClassDescriptor cld,
                                               java.lang.Object[] row)
                                        throws java.lang.InstantiationException,
                                               java.lang.IllegalAccessException,
                                               java.sql.SQLException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.sql.SQLException

buildWithMultiArgsConstructor

protected java.lang.Object buildWithMultiArgsConstructor(ClassDescriptor cld,
                                                         java.lang.Object[] row,
                                                         java.lang.reflect.Constructor multiArgsConstructor)
                                                  throws java.sql.SQLException,
                                                         java.lang.InstantiationException,
                                                         java.lang.IllegalAccessException,
                                                         java.lang.reflect.InvocationTargetException,
                                                         PersistenceBrokerException
java.sql.SQLException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
PersistenceBrokerException

readPkValuesFrom

public void readPkValuesFrom(java.sql.ResultSet rs,
                             ClassDescriptor cld,
                             java.lang.Object[] row)
Description copied from interface: RowReader
Read primary key fields from the current ResultRow into the Object[] row.# ConversionStrategies are applied here!

Specified by:
readPkValuesFrom in interface RowReader


Authors: Thomas Mahler and others. (C) 2000, 2001.
All rights reserved. Published under the Gnu Public License.
http://objectbridge.sourceforge.net
Version: 0.8.375, 2002-04-04