From: Jeff M. <cus...@us...> - 2002-06-19 15:26:51
|
Update of /cvsroot/mockobjects/mockobjects-java/src/extensions/com/mockobjects/eziba/sql In directory usw-pr-cvs1:/tmp/cvs-serv12913/src/extensions/com/mockobjects/eziba/sql Modified Files: PreparedStatement.java Log Message: Lots of small changes to mocks Index: PreparedStatement.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/extensions/com/mockobjects/eziba/sql/PreparedStatement.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- PreparedStatement.java 29 Jul 2001 19:50:25 -0000 1.1 +++ PreparedStatement.java 19 Jun 2002 15:26:16 -0000 1.2 @@ -31,132 +31,110 @@ */ package com.mockobjects.eziba.sql; + +import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; -import java.io.ByteArrayOutputStream; import java.io.Reader; import java.math.BigDecimal; import java.sql.SQLException; import java.util.Calendar; -import java.util.Vector;public class PreparedStatement - extends Statement - implements java.sql.PreparedStatement -{ +import java.util.Vector; + +public class PreparedStatement + extends Statement + implements java.sql.PreparedStatement { protected final Vector m_args = new Vector(); - protected void setArg(int p_pos,Object p_arg) - { + protected void setArg(int p_pos, Object p_arg) { p_pos--; - if (m_args.size() <= p_pos) - { + if(m_args.size() <= p_pos) { int size = m_args.size(); - m_args.setSize(p_pos+1); - for (int i = size; i < m_args.size(); ++i) - { - m_args.set(i,Connection.WILDCARD); + m_args.setSize(p_pos + 1); + for(int i = size; i < m_args.size(); ++i) { + m_args.set(i, Connection.WILDCARD); } } - m_args.set(p_pos,p_arg); + m_args.set(p_pos, p_arg); } - protected final Object [] getArguments() - { + protected final Object[] getArguments() { m_args.trimToSize(); return m_args.toArray(); } - PreparedStatement(Connection p_connection, String p_sql) - { - super(p_connection,p_sql); + PreparedStatement(Connection p_connection, String p_sql) { + super(p_connection, p_sql); } - public void addBatch() - { + public void addBatch() { throw new NotImplementedException(); } - public void clearParameters() - { + public void clearParameters() { throw new NotImplementedException(); } public boolean execute() - throws SQLException - { + throws SQLException { m_returnValue = -1; m_resultSet = null; - try - { + try { m_returnValue = executeUpdate(); return false; - } - catch (SQLException e) - { + } catch(SQLException e) { m_resultSet = executeQuery(); return true; } } - public java.sql.ResultSet getResultSet() - { + public java.sql.ResultSet getResultSet() { return m_resultSet; } - public int getUpdateCount() - { + public int getUpdateCount() { return m_returnValue; } public java.sql.ResultSet executeQuery() - throws SQLException - { - return connection.getRegisteredResult(sql,getArguments()); + throws SQLException { + return connection.getRegisteredResult(sql, getArguments()); } public int executeUpdate() - throws SQLException - { + throws SQLException { return connection.getRegisteredUpdate(sql, getArguments()); } - public void setInt(int parameterIndex, int x) - { + public void setInt(int parameterIndex, int x) { setArg(parameterIndex, new Integer(x)); } - public void setString(int parameterIndex, String x) - { + public void setString(int parameterIndex, String x) { setArg(parameterIndex, x); } - public void setBigDecimal(int parameterIndex, BigDecimal x) - { + public void setBigDecimal(int parameterIndex, BigDecimal x) { setArg(parameterIndex, x); } public void setBinaryStream(int parameterIndex, InputStream x, int length) - throws SQLException - { - try - { + throws SQLException { + try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); int c = 0; - while ( ((c = x.read()) != -1) ) - { + while(((c = x.read()) != -1)) { baos.write(c); } - setArg(parameterIndex,baos.toByteArray()); - } - catch (IOException e) - { + setArg(parameterIndex, baos.toByteArray()); + } catch(IOException e) { throw new SQLException("IOException reading stream"); } } - public void setNull(int parameterIndex, int sqlType) - { - setArg(parameterIndex,null); + public void setNull(int parameterIndex, int sqlType) { + setArg(parameterIndex, null); } private int m_returnValue; @@ -167,131 +145,106 @@ - public java.sql.ResultSetMetaData getMetaData() - { + public java.sql.ResultSetMetaData getMetaData() { throw new NotImplementedException(); } - public void setArray(int i, java.sql.Array x) - { + public void setArray(int i, java.sql.Array x) { throw new NotImplementedException(); } - public void setAsciiStream(int parameterIndex, InputStream x, int length) - { + public void setAsciiStream(int parameterIndex, InputStream x, int length) { throw new NotImplementedException(); } - public void setBlob(int i, java.sql.Blob x) - { + public void setBlob(int i, java.sql.Blob x) { throw new NotImplementedException(); } - public void setBoolean(int parameterIndex, boolean x) - { + public void setBoolean(int parameterIndex, boolean x) { throw new NotImplementedException(); } - public void setByte(int parameterIndex, byte x) - { + public void setByte(int parameterIndex, byte x) { throw new NotImplementedException(); } - public void setBytes(int parameterIndex, byte[] x) - { + public void setBytes(int parameterIndex, byte[] x) { throw new NotImplementedException(); } - public void setCharacterStream(int parameterIndex, Reader reader, int length) - { + public void setCharacterStream(int parameterIndex, Reader reader, int length) { throw new NotImplementedException(); } - public void setClob(int i, java.sql.Clob x) - { + public void setClob(int i, java.sql.Clob x) { throw new NotImplementedException(); } - public void setDate(int parameterIndex, java.sql.Date x) - { + public void setDate(int parameterIndex, java.sql.Date x) { throw new NotImplementedException(); } - public void setDate(int parameterIndex, java.sql.Date x, Calendar cal) - { + public void setDate(int parameterIndex, java.sql.Date x, Calendar cal) { throw new NotImplementedException(); } - public void setDouble(int parameterIndex, double x) - { + public void setDouble(int parameterIndex, double x) { throw new NotImplementedException(); } - public void setFloat(int parameterIndex, float x) - { + public void setFloat(int parameterIndex, float x) { throw new NotImplementedException(); } - public void setLong(int parameterIndex, long x) - { + public void setLong(int parameterIndex, long x) { throw new NotImplementedException(); } - public void setNull(int paramIndex, int sqlType, String typeName) - { + public void setNull(int paramIndex, int sqlType, String typeName) { throw new NotImplementedException(); } - public void setObject(int parameterIndex, Object x) - { + public void setObject(int parameterIndex, Object x) { throw new NotImplementedException(); } - public void setObject(int parameterIndex, Object x, int targetSqlType) - { + public void setObject(int parameterIndex, Object x, int targetSqlType) { throw new NotImplementedException(); } - public void setObject(int parameterIndex, Object x, int targetSqlType, int scale) - { + public void setObject(int parameterIndex, Object x, int targetSqlType, int scale) { throw new NotImplementedException(); } - public void setRef(int i, java.sql.Ref x) - { + public void setRef(int i, java.sql.Ref x) { throw new NotImplementedException(); } - public void setShort(int parameterIndex, short x) - { + public void setShort(int parameterIndex, short x) { throw new NotImplementedException(); } - public void setTime(int parameterIndex, java.sql.Time x) - { + public void setTime(int parameterIndex, java.sql.Time x) { throw new NotImplementedException(); } - public void setTime(int parameterIndex, java.sql.Time x, Calendar cal) - { + public void setTime(int parameterIndex, java.sql.Time x, Calendar cal) { throw new NotImplementedException(); } - public void setTimestamp(int parameterIndex, java.sql.Timestamp x) - { + public void setTimestamp(int parameterIndex, java.sql.Timestamp x) { throw new NotImplementedException(); } - public void setTimestamp(int parameterIndex, java.sql.Timestamp x, Calendar cal) - { + public void setTimestamp(int parameterIndex, java.sql.Timestamp x, Calendar cal) { throw new NotImplementedException(); } /** * @deprecated */ - public void setUnicodeStream(int parameterIndex, InputStream x, int length) - { + public void setUnicodeStream(int parameterIndex, InputStream x, int length) { throw new NotImplementedException(); } } |