001 /* 002 @license.text@ 003 */ 004 package biz.hammurapi.sql; 005 006 import java.sql.ResultSet; 007 import java.sql.SQLException; 008 009 import biz.hammurapi.convert.CompositeConverter; 010 011 /** 012 * Projects first column by invoking ResultSet.getObject(1) 013 * @author Pavel Vlasov 014 * @version $Revision: 1.3 $ 015 */ 016 public class FirstColumnProjector implements Projector { 017 018 private Class targetClass; 019 020 public FirstColumnProjector() { 021 // Default constructor 022 } 023 024 public FirstColumnProjector(Class targetClass) { 025 this.targetClass=targetClass; 026 } 027 028 public Object project(ResultSet rs) throws SQLException { 029 return targetClass==null ? rs.getObject(1) : CompositeConverter.getDefaultConverter().convert(rs.getObject(1), targetClass, false); 030 } 031 }