/**
 * Copyright @ 2000 Peter Roßbach (pr@webapp.de)
 * 
 * Source is only for non commercial and coaching usage.
 * 
 * Not Warranty to use it.
 */
	
package de.ix.jspTutorial.database ;

import java.sql.* ;

/**
 * @author Peter Rossbach (<a href="mailto://pr@webapp.de">pr@webapp.de</a>)
 * @version $Id:$
 */
public class DatabaseGenericBinder implements I_DatabaseBinder
{
	 /**
    * Version  des Source
    */
   public static String vcid = "$Id:$";

/**
	 * Erzeuge ein Objekt aus der DB Zeile
	 * @param result aktuelle Zeile des DB Cursors
	 * @return Ein Datenbank Objekt
	 */
	public I_DatabaseObject bind(String aType, ResultSet	result)
		throws SQLException
	{
		 I_DatabaseGenericObject object = null ;
		 ResultSetMetaData meta = result.getMetaData();
		 if(meta!=null) {
			  int columnCount = meta.getColumnCount();

		    object = new DatabaseGenericObject();
			 for (int i=1; i <= columnCount; i++) {
				 	Object theValue = result.getObject(i) ;
				 	  System.out.println("Set Value '" + theValue + "' -- " + 
				 	  	meta.getColumnName(i) + ":" + meta.getColumnType(i));
				 	 object.putValue(
				     meta.getColumnName(i),
				     theValue );
			 }
		 }
		 return object ;
	}
	
} // end of class


//
// History:
//
// $Log:$
//
//
