01: /*
02: * $Id: OracleCursorType.java,v 1.10 2004/09/30 17:27:55 spal Exp $
03: * $Source: /cvsroot/sqlunit/sqlunit/src/net/sourceforge/sqlunit/types/OracleCursorType.java,v $
04: * SQLUnit - a test harness for unit testing database stored procedures.
05: * Copyright (C) 2003 The SQLUnit Team
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License
09: * as published by the Free Software Foundation; either version 2
10: * of the License, or (at your option) any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public License
18: * along with this program; if not, write to the Free Software
19: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20: */
21: package net.sourceforge.sqlunit.types;
22:
23: import net.sourceforge.sqlunit.IErrorCodes;
24: import net.sourceforge.sqlunit.SQLUnitException;
25: import net.sourceforge.sqlunit.SymbolTable;
26: import net.sourceforge.sqlunit.beans.ResultSetBean;
27: import net.sourceforge.sqlunit.utils.XMLUtils;
28:
29: import java.sql.ResultSet;
30:
31: /**
32: * Models a Oracle CURSOR type.
33: * @author Ralph Brendler (rbrendler@users.sourceforge.net)
34: * @author Sujit Pal (spal@users.sourceforge.net)
35: * @version $Revision: 1.10 $
36: * @sqlunit.type name="OracleCursorType" input="No" output="Yes" sortable="No"
37: * wraps="java.sql.ResultSet"
38: * @sqlunit.typename name="CURSOR" server="Oracle"
39: */
40: public class OracleCursorType extends UnsupportedType {
41:
42: /**
43: * Formats a Short type.
44: * @param obj an Object to be converted to the IType interface.
45: * @return the String representation of the object.
46: * @exception SQLUnitException if the formatting failed.
47: */
48: protected String format(final Object obj) throws SQLUnitException {
49: if (!(obj instanceof ResultSet)) {
50: throw new SQLUnitException(
51: IErrorCodes.UNSUPPORTED_DATATYPE_FORMAT,
52: new String[] {
53: SymbolTable.getCurrentResultKey(),
54: (obj == null ? "NULL" : obj.getClass()
55: .getName()), getName(),
56: (new Integer(getId())).toString() });
57: }
58: ResultSet rs = (ResultSet) obj;
59: ResultSetBean rsb = new ResultSetBean(rs, 1);
60: return XMLUtils.toXMLString(rsb.toElement());
61: }
62: }
|