001/* 
002 * JKNIV, whinstone one contract to access your database.
003 * 
004 * Copyright (C) 2017, the original author or authors.
005 *
006 * This library is free software; you can redistribute it and/or
007 * modify it under the terms of the GNU Lesser General Public
008 * License as published by the Free Software Foundation; either
009 * version 2.1 of the License.
010 * 
011 * This library is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014 * Lesser General Public License for more details.
015 * 
016 * You should have received a copy of the GNU Lesser General Public
017 * License along with this library; if not, write to the Free Software Foundation, Inc., 
018 * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
019 */
020package net.sf.jkniv.whinstone;
021
022import java.sql.SQLException;
023
024import net.sf.jkniv.reflect.beans.ObjectProxy;
025import net.sf.jkniv.whinstone.classification.Transformable;
026
027/**
028 * Extract the result for each row from {@code ResultSet}.
029 * <p>
030 * <b>Note:</b> ResultRow must be {@code stateless}.
031 * 
032 * @param <T> Type of objects thats must be returned.
033 * @param <R> Type of objects thats database connection return as row, JDBC is {link ResultSet} 
034 * JPA is {@code Object[]}.
035 * 
036 * @author Alisson Gomes
037 * @since 0.6.0
038 */
039public interface ResultRow<T,R>
040{
041    /**
042     * Retrieve column values from the current row, implementations must don't call {@code next} 
043     * neither {@code close} methods.
044     * 
045     * @param rs A ResultSet or Object[] pointing to its current row of data
046     * @param rownum The row number
047     * @return the instance of object with {@code ResultSet} data.
048     * @throws SQLException errors that occurs when access {@code ResultSet} methods.
049     */
050    T row(R rs, int rownum) throws SQLException;
051    
052    Transformable<T> getTransformable();
053    
054    void setColumns(JdbcColumn<R>[] columns);
055    
056    /*
057     * Set into {@code proxy} the value of {@code jdbcObject}
058     * @param column metadata
059     * @param jdbcObject value of column row
060     * @param proxy for object that represents a row {@code T}
061     */
062    //void setValueOf(JdbcColumn<?> column, Object jdbcObject, ObjectProxy<?> proxy);
063
064}