private void getResultSetMappings ( ) throws SQLException { // // special case for XmlObject, find factory class // if ( _schemaType . isDocumentType ( ) ) { return ; } final String [ ] keys = getKeysFromResultSet ( ) ; // // find setters for return class // HashMap < String , Method > mapFields = new HashMap < String , Method > ( _columnCount * 2 ) ; for ( int i = 1 ; i <= _columnCount ; i ++ ) { mapFields . put ( keys [ i ] , null ) ; } // public methods Method [ ] classMethods = _returnTypeClass . getMethods ( ) ; for ( Method method : classMethods ) { if ( isSetterMethod ( method ) ) { final String fieldName = method . getName ( ) . substring ( 3 ) . toUpperCase ( ) ; if ( mapFields . containsKey ( fieldName ) ) { mapFields . put ( fieldName , method ) ; } } } // finally actually init the fields array _setterMethods = new SetterMethod [ _columnCount + 1 ] ; for ( int i = 1 ; i < _setterMethods . length ; i ++ ) { Method setterMethod = mapFields . get ( keys [ i ] ) ; if ( setterMethod == null ) { throw new ControlException ( "Unable to map the SQL column " + keys [ i ] + " to a field on the " + _returnTypeClass . getName ( ) + " class. Mapping is done using a case insensitive comparision of SQL ResultSet " + "columns to public setter methods on the return class." ) ; } _setterMethods [ i ] = new SetterMethod ( setterMethod ) ; } }
Build the necessary structures to do the mapping