Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E4E04DDEB for ; Fri, 21 Sep 2012 08:59:10 +0000 (UTC) Received: (qmail 9426 invoked by uid 500); 21 Sep 2012 08:59:10 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 9145 invoked by uid 500); 21 Sep 2012 08:59:09 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 7691 invoked by uid 99); 21 Sep 2012 08:59:07 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 Sep 2012 08:59:07 +0000 Date: Fri, 21 Sep 2012 19:59:07 +1100 (NCT) From: "Simone Tripodi (JIRA)" To: issues@commons.apache.org Message-ID: <1800943045.107019.1348217947685.JavaMail.jiratomcat@arcas> In-Reply-To: <1054610104.16197.1344250142365.JavaMail.jiratomcat@issues-vm> Subject: [jira] [Commented] (DBUTILS-97) Add an AbstractResultSetHandler implementation in order to reduce redundant 'resultSet' variable invocation MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/DBUTILS-97?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13460370#comment-13460370 ] Simone Tripodi commented on DBUTILS-97: --------------------------------------- Any other though, Bill? If you don't have objections, I'll check it in! TIA! > Add an AbstractResultSetHandler implementation in order to reduce redundant 'resultSet' variable invocation > ----------------------------------------------------------------------------------------------------------- > > Key: DBUTILS-97 > URL: https://issues.apache.org/jira/browse/DBUTILS-97 > Project: Commons DbUtils > Issue Type: New Feature > Affects Versions: 1.6 > Reporter: Simone Tripodi > Assignee: Simone Tripodi > Fix For: 1.6 > > Attachments: DBUTILS-97.patch > > > According to the DRY principle (Don't Repeat Yourself), repeating {{resultSet}} variable inside the {{ResultSetHandler#handle(ResultSet)}} over and over for each iteration can get a little tedious. > It would be helpful adding a support class, named {{AbstractResultSetHandler}}, which implicitly gives users access to {{ResultSet}}'s methods. _For example_, we could extend {{AbstractResultSetHandler}} and rewrite the mapping below: > {code} > new ResultSetHandler>> { > @Override > public Collection> handle(ResultSet rs) throws SQLException { > Collection> result = new LinkedList>(); > while (rs.next()) { > Map current = new HashMap(); > for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) { > current.put(rs.getMetaData().getColumnName(i), rs.getObject(i)); > } > result.add(current); > } > return result; > } > } > {code} > as: > {code} > new AbstractResultSetHandler>> { > @Override > protected Collection> handle() throws SQLException { > Collection> result = new LinkedList>(); > while (next()) { > Map current = new HashMap(); > for (int i = 1; i <= getMetaData().getColumnCount(); i++) { > current.put(getMetaData().getColumnName(i), getObject(i)); > } > result.add(current); > } > return result; > } > } > {code} -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira