Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 8061 invoked from network); 24 Oct 2003 02:21:16 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 24 Oct 2003 02:21:16 -0000 Received: (qmail 22539 invoked by uid 500); 24 Oct 2003 02:20:56 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 22286 invoked by uid 500); 24 Oct 2003 02:20:54 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 22273 invoked by uid 500); 24 Oct 2003 02:20:54 -0000 Received: (qmail 22270 invoked from network); 24 Oct 2003 02:20:54 -0000 Received: from unknown (HELO minotaur.apache.org) (209.237.227.194) by daedalus.apache.org with SMTP; 24 Oct 2003 02:20:54 -0000 Received: (qmail 8003 invoked by uid 1581); 24 Oct 2003 02:21:11 -0000 Date: 24 Oct 2003 02:21:11 -0000 Message-ID: <20031024022111.8002.qmail@minotaur.apache.org> From: dgraham@apache.org To: jakarta-commons-sandbox-cvs@apache.org Subject: cvs commit: jakarta-commons-sandbox/dbutils/src/test/org/apache/commons/dbutils MockResultSet.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N dgraham 2003/10/23 19:21:11 Modified: dbutils/src/test/org/apache/commons/dbutils MockResultSet.java Log: Added getString() implementations. Revision Changes Path 1.6 +34 -9 jakarta-commons-sandbox/dbutils/src/test/org/apache/commons/dbutils/MockResultSet.java Index: MockResultSet.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/dbutils/src/test/org/apache/commons/dbutils/MockResultSet.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- MockResultSet.java 23 Oct 2003 04:50:05 -0000 1.5 +++ MockResultSet.java 24 Oct 2003 02:21:11 -0000 1.6 @@ -142,6 +142,16 @@ return this.getObject((String) args[0]); } + } else if (methodName.equals("getString")) { + + if (args[0] instanceof Integer) { + int col = ((Integer) args[0]).intValue(); + return this.getString(col); + + } else if (args[0] instanceof String) { + return this.getString((String) args[0]); + } + } else if (methodName.equals("wasNull")) { return this.wasNull(); @@ -156,11 +166,11 @@ return this.iter.hasNext() ? Boolean.FALSE : Boolean.TRUE; } - /** - * Gets the object at the given column index. - * @param columnIndex A 1 based index. - * @throws SQLException - */ + /** + * Gets the object at the given column index. + * @param columnIndex A 1 based index. + * @throws SQLException + */ protected Object getObject(int columnIndex) throws SQLException { Object obj = this.currentRow[columnIndex - 1]; if (obj == null) { @@ -176,7 +186,7 @@ /** * Returns the column index for the given column name. - * @return A 1 based index + * @return A 1 based index * @throws SQLException if the column name is invalid */ private int findColumnIndex(String columnName) throws SQLException { @@ -188,6 +198,21 @@ } throw new SQLException(columnName + " is not a valid column name."); + } + + /** + * Gets the String at the given column index. + * @param columnIndex A 1 based index. + * @throws SQLException + */ + protected String getString(int columnIndex) throws SQLException { + Object obj = this.getObject(columnIndex); + return (obj == null) ? null : obj.toString(); + } + + protected String getString(String columnName) throws SQLException { + Object obj = this.getObject(this.findColumnIndex(columnName)); + return (obj == null) ? null : obj.toString(); } protected Boolean next() throws SQLException { --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org