protected Object buildOrRefreshObject ( Map row , ClassDescriptor targetClassDescriptor , Object targetObject ) { Object result = targetObject ; FieldDescriptor fmd ; FieldDescriptor [ ] fields = targetClassDescriptor . getFieldDescriptor ( true ) ; if ( targetObject == null ) { // 1. create new object instance if needed result = ClassHelper . buildNewObjectInstance ( targetClassDescriptor ) ; } // 2. fill all scalar attributes of the new object for ( int i = 0 ; i < fields . length ; i ++ ) { fmd = fields [ i ] ; fmd . getPersistentField ( ) . set ( result , row . get ( fmd . getColumnName ( ) ) ) ; } if ( targetObject == null ) { // 3. for new build objects, invoke the initialization method for the class if one is provided Method initializationMethod = targetClassDescriptor . getInitializationMethod ( ) ; if ( initializationMethod != null ) { try { initializationMethod . invoke ( result , NO_ARGS ) ; } catch ( Exception ex ) { throw new PersistenceBrokerException ( "Unable to invoke initialization method:" + initializationMethod . getName ( ) + " for class:" + m_cld . getClassOfObject ( ) , ex ) ; } } } return result ; }
Creates an object instance according to clb and fills its fileds width data provided by row .