package com.dotech.ibatis; import com.dotech.servlet.jstl.ResultSupport; import com.dotech.sql.SqlHelper; import com.ibatis.sqlmap.client.extensions.ParameterSetter; import com.ibatis.sqlmap.client.extensions.ResultGetter; import com.ibatis.sqlmap.client.extensions.TypeHandlerCallback; import java.sql.ResultSet; import java.sql.SQLException; import javax.servlet.jsp.jstl.sql.Result; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; public class ResultSetToResultHandler implements TypeHandlerCallback { private static final Log LOG = LogFactory.getLog(ResultSetToResultHandler.class); private final SqlHelper sqlHelper; public ResultSetToResultHandler() { super(); this.sqlHelper = new SqlHelper(); } public Object getResult(ResultGetter getter) throws SQLException { Result result = null; ResultSet rs = null; try { rs = (ResultSet)getter.getObject(); // TODO: throw exception if rs is null? if (rs != null) { result = ResultSupport.toResult(rs); } } finally { this.sqlHelper.close(rs); } checkResult(result); return result; } protected void checkResult(Result result) throws SQLException { } public void setParameter(ParameterSetter setter, Object parameter) throws SQLException { throw new UnsupportedOperationException(); } public Object valueOf(String s) { throw new UnsupportedOperationException(); } }