You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by to...@apache.org on 2008/04/09 13:02:07 UTC
svn commit: r646264 [9/13] - in /harmony/enhanced/classlib/branches/java6:
depends/build/ depends/build/platform/ depends/files/
modules/accessibility/ modules/annotation/ modules/applet/ modules/archive/
modules/archive/src/main/java/java/util/jar/ mo...
Modified: harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/ProviderServiceTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/ProviderServiceTest.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/ProviderServiceTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/ProviderServiceTest.java Wed Apr 9 04:01:14 2008
@@ -67,21 +67,12 @@
Provider.Service s = new Provider.Service(p,
"type", "algorithm", "className", null, null);
- if (!s.getType().equals("type")) {
- fail("getType() failed");
- }
- if (!s.getAlgorithm().equals("algorithm")) {
- fail("getAlgorithm() failed");
- }
- if (s.getProvider()!= p) {
- fail("getProvider() failed");
- }
- if (!s.getClassName().equals("className")) {
- fail("getClassName() failed");
- }
- if (!s.supportsParameter(new Object())) {
- fail("supportsParameter() failed");
- }
+ assertEquals("getType() failed", "type", s.getType());
+ assertEquals("getAlgorithm() failed", "algorithm", s.getAlgorithm());
+ assertSame("getProvider() failed", p, s.getProvider());
+ assertEquals("getClassName() failed", "className", s.getClassName());
+ assertTrue("supportsParameter() failed", s
+ .supportsParameter(new Object()));
}
public void testGetAttribute() {
@@ -94,9 +85,7 @@
} catch (NullPointerException e) {
}
- if (s.getAttribute("aaa") != null) {
- fail("getAttribute(aaa) failed");
- }
+ assertNull("getAttribute(aaa) failed", s.getAttribute("aaa"));
HashMap hm = new HashMap();
hm.put("attribute", "value");
@@ -105,33 +94,22 @@
s = new Provider.Service(p, "type", "algorithm", "className",
null, hm);
- if (s.getAttribute("bbb") != null) {
- fail("getAttribute(bbb) failed");
- }
- if (!s.getAttribute("attribute").equals("value")) {
- fail("getAttribute(attribute) failed");
- }
- if (!s.getAttribute("KeySize").equals("1024")) {
- fail("getAttribute(KeySize) failed");
- }
+ assertNull("getAttribute(bbb) failed", s.getAttribute("bbb"));
+ assertEquals("getAttribute(attribute) failed", "value", s
+ .getAttribute("attribute"));
+ assertEquals("getAttribute(KeySize) failed", "1024", s
+ .getAttribute("KeySize"));
}
- public void testNewInstance() {
+ public void testNewInstance() throws NoSuchAlgorithmException {
Provider p = new MyProvider();
Provider.Service s = new Provider.Service(p, "SecureRandom",
"algorithm",
"org.apache.harmony.security.tests.support.RandomImpl",
null, null);
- Object o = null;
- try {
- o = s.newInstance(null);
- } catch (NoSuchAlgorithmException e) {
- e.printStackTrace();
- fail("newInstance() failed");
- }
- if (!(o instanceof RandomImpl)) {
- fail("incorrect instance");
- }
+
+ Object o = s.newInstance(null);
+ assertTrue("incorrect instance", o instanceof RandomImpl);
try {
o = s.newInstance(new Object());
Modified: harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/ProviderTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/ProviderTest.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/ProviderTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/ProviderTest.java Wed Apr 9 04:01:14 2008
@@ -53,25 +53,20 @@
* Class under test for void Provider()
*/
public final void testProvider() {
- if (!p.getProperty("Provider.id name").equals(String.valueOf(p.getName()))) {
- fail("Incorrect \"Provider.id name\" value");
- }
- if (!p.getProperty("Provider.id version").equals(String.valueOf(p.getVersion()))) {
- fail("Incorrect \"Provider.id version\" value");
- }
- if (!p.getProperty("Provider.id info").equals(String.valueOf(p.getInfo()))) {
- fail("Incorrect \"Provider.id info\" value");
- }
- if (!p.getProperty("Provider.id className").equals(p.getClass().getName())) {
- fail("Incorrect \"Provider.id className\" value");
- }
+ assertEquals("Provider.id name", p.getProperty("Provider.id name"),
+ String.valueOf(p.getName()));
+ assertEquals("Provider.id version", p
+ .getProperty("Provider.id version"), String.valueOf(p
+ .getVersion()));
+ assertEquals("Provider.id info", p.getProperty("Provider.id info"),
+ String.valueOf(p.getInfo()));
+ assertEquals("Provider.id className", p
+ .getProperty("Provider.id className"), p.getClass().getName());
}
public final void testClear() {
p.clear();
- if (p.getProperty("MessageDigest.SHA-1") != null) {
- fail("Provider contains properties");
- }
+ assertNull(p.getProperty("MessageDigest.SHA-1"));
}
/*
@@ -79,29 +74,22 @@
*/
public final void testProviderStringdoubleString() {
Provider p = new MyProvider("Provider name", 123.456, "Provider info");
- if (!p.getName().equals("Provider name") ||
- p.getVersion() != 123.456 ||
- !p.getInfo().equals("Provider info")) {
- fail("Incorrect values");
- }
+
+ assertEquals("Provider name", p.getName());
+ assertEquals(123.456, p.getVersion(), 0L);
+ assertEquals("Provider info", p.getInfo());
}
public final void testGetName() {
- if (!p.getName().equals("MyProvider")) {
- fail("Incorrect provider name");
- }
+ assertEquals("MyProvider", p.getName());
}
public final void testGetVersion() {
- if (p.getVersion() != 1.0) {
- fail("Incorrect provider version");
- }
+ assertEquals(1.0, p.getVersion(), 0L);
}
public final void testGetInfo() {
- if (!p.getInfo().equals("Provider for testing")) {
- fail("Incorrect provider info");
- }
+ assertEquals("Provider for testing", p.getInfo());
}
/*
@@ -181,22 +169,19 @@
} catch (UnsupportedOperationException e) {
}
Set s1 = p.keySet();
- if ((s == s1) || s1.isEmpty() ) {
- fail("Must return unmodifiable set");
- }
- if (s1.size() != 8) {
- fail("Incorrect set size");
- }
- if (!s1.contains("MessageDigest.SHA-256") ||
- !s1.contains("MessageDigest.SHA-1") ||
- !s1.contains("Alg.Alias.MessageDigest.SHA1") ||
- !s1.contains("MessageDigest.abc") ||
- !s1.contains("Provider.id info") ||
- !s1.contains("Provider.id className") ||
- !s1.contains("Provider.id version") ||
- !s1.contains("Provider.id name")) {
- fail("Incorrect set");
- }
+
+ assertNotSame(s, s1);
+ assertFalse(s1.isEmpty());
+ assertEquals(8, s1.size());
+
+ assertTrue(s1.contains("MessageDigest.SHA-256"));
+ assertTrue(s1.contains("MessageDigest.SHA-1"));
+ assertTrue(s1.contains("Alg.Alias.MessageDigest.SHA1"));
+ assertTrue(s1.contains("MessageDigest.abc"));
+ assertTrue(s1.contains("Provider.id info"));
+ assertTrue(s1.contains("Provider.id className"));
+ assertTrue(s1.contains("Provider.id version"));
+ assertTrue(s1.contains("Provider.id name"));
}
/*
@@ -211,21 +196,18 @@
} catch (UnsupportedOperationException e) {
}
Collection c1 = p.values();
- if ((c == c1) || c1.isEmpty() ) {
- fail("Must return unmodifiable set");
- }
- if (c1.size() != 8) {
- fail("Incorrect set size " + c1.size());
- }
- if (!c1.contains("MyProvider") ||
- !c1.contains("aaa.bbb.ccc.ddd") ||
- !c1.contains("Provider for testing") ||
- !c1.contains("1.0") ||
- !c1.contains("SomeClassName") ||
- !c1.contains("SHA-1") ||
- !c1.contains(p.getClass().getName())) {
- fail("Incorrect set");
- }
+
+ assertNotSame(c, c1);
+ assertFalse(c1.isEmpty());
+ assertEquals(8, c1.size());
+
+ assertTrue(c1.contains("MyProvider"));
+ assertTrue(c1.contains("aaa.bbb.ccc.ddd"));
+ assertTrue(c1.contains("Provider for testing"));
+ assertTrue(c1.contains("1.0"));
+ assertTrue(c1.contains("SomeClassName"));
+ assertTrue(c1.contains("SHA-1"));
+ assertTrue(c1.contains(p.getClass().getName()));
}
/*
@@ -234,14 +216,12 @@
public final void testPutObjectObject() {
p.put("MessageDigest.SHA-1", "aaa.bbb.ccc.ddd");
p.put("Type.Algorithm", "className");
- if (!"aaa.bbb.ccc.ddd".equals(p.getProperty("MessageDigest.SHA-1").trim()) ) {
- fail("Incorrect property value");
- }
+ assertEquals("aaa.bbb.ccc.ddd", p.getProperty("MessageDigest.SHA-1")
+ .trim());
Set services = p.getServices();
- if (services.size() != 3) {
- fail("incorrect size");
- }
+ assertEquals(3, services.size());
+
for (Iterator it = services.iterator(); it.hasNext();) {
Provider.Service s = (Provider.Service)it.next();
if ("Type".equals(s.getType()) &&
@@ -268,23 +248,17 @@
*/
public final void testRemoveObject() {
Object o = p.remove("MessageDigest.SHA-1");
- if (!"SomeClassName".equals(o)) {
- fail("Incorrect return value");
- }
- if (p.getProperty("MessageDigest.SHA-1") != null) {
- fail("Provider contains properties");
- }
- if (p.getServices().size() != 1){
- fail("Service not removed");
- }
+
+ assertEquals("SomeClassName", o);
+ assertNull(p.getProperty("MessageDigest.SHA-1"));
+ assertEquals(1, p.getServices().size());
}
public final void testService1() {
p.put("MessageDigest.SHA-1", "AnotherClassName");
Provider.Service s = p.getService("MessageDigest", "SHA-1");
- if (!"AnotherClassName".equals(s.getClassName())) {
- fail("Incorrect class name "+ s.getClassName());
- }
+
+ assertEquals("AnotherClassName", s.getClassName());
}
/*
Modified: harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecurityTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecurityTest.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecurityTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecurityTest.java Wed Apr 9 04:01:14 2008
@@ -324,6 +324,9 @@
fail("No expected NullPointerException.");
} catch (NullPointerException e) {
}
+
+ Security.setProperty("myprop","test white space ");
+ assertEquals("test white space", Security.getProperty("myprop"));
}
/**
Modified: harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SignedObjectTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SignedObjectTest.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SignedObjectTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SignedObjectTest.java Wed Apr 9 04:01:14 2008
@@ -15,84 +15,44 @@
* limitations under the License.
*/
-/**
-* @author Boris V. Kuznetsov
-* @version $Revision$
-*/
-
package org.apache.harmony.security.tests.java.security;
-import java.security.*;
-import java.io.IOException;
-import java.security.spec.InvalidKeySpecException;
-import java.util.Properties;
-import org.apache.harmony.security.tests.support.TestKeyPair;
+import java.security.NoSuchAlgorithmException;
+import java.security.Signature;
+import java.security.SignedObject;
+import java.util.Properties;
import junit.framework.TestCase;
+import org.apache.harmony.security.tests.support.TestKeyPair;
/**
* Tests for <code>SignedObject</code> constructor and methods
- *
*/
public class SignedObjectTest extends TestCase {
- public void testSignedObject() {
- Signature sig = null;
- TestKeyPair tkp = null;
- Properties prop;
-
- try {
- sig = Signature.getInstance("SHA1withDSA");
- } catch (NoSuchAlgorithmException e) {
- fail(e.toString());
- }
-
- try {
- tkp = new TestKeyPair("DSA");
- } catch (NoSuchAlgorithmException e) {
- e.printStackTrace();
- return;
- }
- prop = new Properties();
- prop.put("aaa", "bbb");
- SignedObject so = null;
- try {
- so = new SignedObject(prop, tkp.getPrivate(), sig);
- } catch (IOException e) {
- fail(e.toString());
- } catch (SignatureException e) {
- fail(e.toString());
- } catch (InvalidKeyException e) {
- fail(e.toString());
- } catch (InvalidKeySpecException e) {
- fail(e.toString());
- }
+ public void testSignedObject() throws Exception {
+ TestKeyPair tkp = null;
+ Properties prop;
+
+ Signature sig = Signature.getInstance("SHA1withDSA");
- assertEquals("SHA1withDSA", so.getAlgorithm());
-
try {
- assertEquals(so.getObject(), prop);
- } catch (ClassNotFoundException e) {
- fail(e.toString());
- } catch (IOException e) {
- fail(e.toString());
+ tkp = new TestKeyPair("DSA");
+ } catch (NoSuchAlgorithmException e) {
+ e.printStackTrace();
+ return;
}
- try {
- if (!so.verify(tkp.getPublic(), sig)) {
- fail("verify() failed");
- }
- } catch (SignatureException e) {
- fail(e.toString());
- } catch (InvalidKeyException e) {
- fail(e.toString());
- } catch (InvalidKeySpecException e) {
- fail(e.toString());
- }
-
- if (so.getSignature() == null) {
- fail("signature is null");
- }
- }
-
+ prop = new Properties();
+ prop.put("aaa", "bbb");
+
+ SignedObject so = new SignedObject(prop, tkp.getPrivate(), sig);
+
+ assertEquals("SHA1withDSA", so.getAlgorithm());
+ assertEquals(prop, so.getObject());
+
+ assertTrue("verify() failed", so.verify(tkp.getPublic(), sig));
+
+ assertNotNull("signature is null", so.getSignature());
+ }
}
Modified: harmony/enhanced/classlib/branches/java6/modules/sound/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sound/build.xml?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sound/build.xml (original)
+++ harmony/enhanced/classlib/branches/java6/modules/sound/build.xml Wed Apr 9 04:01:14 2008
@@ -104,7 +104,8 @@
<target name="build-jar" depends="svn-info">
<jar destfile="${hy.jdk}/jre/lib/boot/${hy.sound.packaging.jarname}.jar"
- manifest="${hy.sound}/META-INF/MANIFEST.MF">
+ manifest="${hy.sound}/META-INF/MANIFEST.MF"
+ compress="${hy.jar.compress}">
<fileset refid="classes" />
<manifest>
<attribute name="Implementation-Version" value="${svn.info}"/>
Modified: harmony/enhanced/classlib/branches/java6/modules/sql/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/META-INF/MANIFEST.MF?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/META-INF/MANIFEST.MF (original)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/META-INF/MANIFEST.MF Wed Apr 9 04:01:14 2008
@@ -25,10 +25,16 @@
java.util.logging,
java.util.zip;resolution:=optional,
javax.naming,
+ javax.xml.parsers,
javax.xml.transform,
+ javax.xml.transform.dom,
+ javax.xml.transform.stream,
org.apache.harmony.kernel.vm,
org.apache.harmony.luni.util,
org.apache.harmony.testframework.serialization;hy_usage=test;resolution:=optional,
+ org.w3c.dom,
+ org.xml.sax,
+ org.xml.sax.helpers,
tests.support;hy_usage=test;resolution:=optional
Export-Package: java.sql,
javax.sql,
Modified: harmony/enhanced/classlib/branches/java6/modules/sql/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/build.xml?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/build.xml (original)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/build.xml Wed Apr 9 04:01:14 2008
@@ -98,7 +98,8 @@
<target name="build-jar" depends="svn-info">
<jar destfile="${hy.jdk}/jre/lib/boot/sql.jar"
- manifest="${hy.sql}/META-INF/MANIFEST.MF">
+ manifest="${hy.sql}/META-INF/MANIFEST.MF"
+ compress="${hy.jar.compress}">
<fileset refid="classes" />
<manifest>
<attribute name="Implementation-Version" value="${svn.info}"/>
Modified: harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/javax/sql/rowset/BaseRowSet.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/javax/sql/rowset/BaseRowSet.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/javax/sql/rowset/BaseRowSet.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/javax/sql/rowset/BaseRowSet.java Wed Apr 9 04:01:14 2008
@@ -173,6 +173,7 @@
throw new SQLException();
}
this.command = cmd;
+ clearParameters();
}
public String getUrl() throws SQLException {
@@ -359,7 +360,7 @@
if (rows < 0) {
throw new SQLException();
}
- if (rows > maxRows) {
+ if (maxRows != 0 && rows > maxRows) {
throw new SQLException();
}
this.fetchSize = rows;
@@ -990,7 +991,7 @@
}
return result;
}
-
+
public BaseRowSet clone() throws CloneNotSupportedException{
BaseRowSet result = (BaseRowSet) super.clone();
return result;
Modified: harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/javax/sql/rowset/spi/SyncFactory.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/javax/sql/rowset/spi/SyncFactory.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/javax/sql/rowset/spi/SyncFactory.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/javax/sql/rowset/spi/SyncFactory.java Wed Apr 9 04:01:14 2008
@@ -56,7 +56,6 @@
private static String resLocation;
- // TODO: the default provider hasn't been implemented yet
private static String defaultProviderName = "org.apache.harmony.sql.internal.rowset.HYOptimisticProvider"; //$NON-NLS-1$
private static ProviderImpl defaultProvider = new ProviderImpl(
Modified: harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/nls/messages.properties
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/nls/messages.properties?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/nls/messages.properties (original)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/nls/messages.properties Wed Apr 9 04:01:14 2008
@@ -71,3 +71,30 @@
rowset.8=The ResultSet type is TYPE_FORWARD_ONLY
rowset.9=PageSize can not be larger than MaxRows
rowset.10=Data type mismatch
+rowset.11=Illegal operation on an insert row
+rowset.12=Match columns should not be empty or null string
+rowset.13=Set Match columns before getting them
+rowset.14=Positioned updates not supported
+rowset.15=Columns being unset are not the same as set
+rowset.16=Not a valid command
+rowset.17=The Result Set is CONCUR_READ_ONLY
+rowset.18=None column is updated
+rowset.19=Populate data before calling
+rowset.20=Match columns should be greater than 0
+rowset.21=Not Updateable of the CurrentRow
+rowset.22=Number of rows is less than fetch size
+rowset.23=Locking classification is not supported
+rowset.24=Unable to get connection
+rowset.25=(JNDI)Unable to get connection
+rowset.26=The object has not been initialized
+rowset.27=Illegal input string "{0}"
+rowset.28=The given value does not lie between the filter criterion
+rowset.29=Insert failed
+rowset.30=Invalid state
+rowset.31=No current connection
+rowset.32=The given rowset is empty
+rowset.33=Not a rowset
+rowset.34=Not set a match column
+rowset.35=Not a valid match olumn index
+rowset.36=Number of elements of two arrays don't equal
+rowset.37=The RowSet doesn't set the table name
Modified: harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/AbstractRowSetImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/AbstractRowSetImpl.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/AbstractRowSetImpl.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/AbstractRowSetImpl.java Wed Apr 9 04:01:14 2008
@@ -19,558 +19,839 @@
import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
-import java.sql.*;
+import java.sql.Array;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.Connection;
+import java.sql.Date;
+import java.sql.DriverManager;
+import java.sql.NClob;
+import java.sql.PreparedStatement;
+import java.sql.Ref;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.RowId;
+import java.sql.SQLException;
+import java.sql.SQLWarning;
+import java.sql.SQLXML;
+import java.sql.Statement;
+import java.sql.Time;
+import java.sql.Timestamp;
import java.util.Calendar;
import java.util.Map;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.sql.DataSource;
import javax.sql.RowSet;
import javax.sql.rowset.BaseRowSet;
-import org.apache.harmony.luni.util.NotImplementedException;
+import org.apache.harmony.sql.internal.nls.Messages;
public class AbstractRowSetImpl extends BaseRowSet implements RowSet {
+ protected ResultSet resultSet;
+
+ protected Connection connection;
+
+ protected PreparedStatement statement;
+
+ private boolean isClosed = false;
+
+ public AbstractRowSetImpl() {
+ initialProperties();
+ initParams();
+ }
+
public void execute() throws SQLException {
- throw new NotImplementedException();
+ if (isClosed) {
+ throw new SQLException(Messages.getString("rowset.31"));
+ }
+
+ if (connection != null) {
+ connection.close();
+ }
+
+ connection = retrieveConnection();
+ String localCommand = getCommand();
+ if (localCommand == null || getParams() == null) {
+ // rowset.16=Not a valid command
+ throw new SQLException(Messages.getString("rowset.16")); //$NON-NLS-1$
+ }
+
+ statement = connection.prepareStatement(localCommand,
+ ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
+ setParameter(statement);
+
+ resultSet = statement.executeQuery();
+ }
+
+ private Connection retrieveConnection() throws SQLException {
+ if (getUrl() == null && getDataSourceName() == null) {
+ throw new NullPointerException();
+ }
+
+ if (getUrl() != null) {
+ return DriverManager.getConnection(getUrl(), getUsername(), getPassword());
+ } else if (getDataSourceName() != null) {
+ try {
+ Context contex = new InitialContext();
+ DataSource ds = (DataSource) contex.lookup(getDataSourceName());
+ return ds.getConnection();
+ } catch (Exception e) {
+ // rowset.25=(JNDI)Unable to get connection
+ SQLException ex = new SQLException(Messages
+ .getString("rowset.25")); //$NON-NLS-1$
+ throw ex;
+ }
+ }
+ // rowset.24=Unable to get connection
+ throw new SQLException(Messages.getString("rowset.24")); //$NON-NLS-1$
+ }
+
+ private void setParameter(PreparedStatement ps) throws SQLException {
+ Object[] params = getParams();
+ for (int i = 0; i < params.length; i++) {
+ if (params[i] instanceof Object[]) {
+ Object[] objs = (Object[]) params[i];
+ // character stream
+ if (objs.length == 2) {
+ ps.setCharacterStream(i + 1, (Reader) objs[0],
+ ((Integer) objs[1]).intValue());
+ } else {
+ int type = ((Integer) objs[2]).intValue();
+ switch (type) {
+ case BaseRowSet.ASCII_STREAM_PARAM:
+ ps.setAsciiStream(i + 1, (InputStream) objs[0],
+ ((Integer) objs[1]).intValue());
+ break;
+ case BaseRowSet.BINARY_STREAM_PARAM:
+ ps.setBinaryStream(i + 1, (InputStream) objs[0],
+ ((Integer) objs[1]).intValue());
+ break;
+ case BaseRowSet.UNICODE_STREAM_PARAM:
+ ps.setUnicodeStream(i + 1, (InputStream) objs[0],
+ ((Integer) objs[1]).intValue());
+ break;
+ }
+ }
+ } else {
+ ps.setObject(i + 1, params[i]);
+ }
+ }
}
public boolean absolute(int row) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.absolute(row);
}
public void afterLast() throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ resultSet.afterLast();
}
public void beforeFirst() throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ resultSet.beforeFirst();
}
public void cancelRowUpdates() throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ resultSet.cancelRowUpdates();
}
public void clearWarnings() throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ resultSet.clearWarnings();
}
public void close() throws SQLException {
- throw new NotImplementedException();
+ try {
+ if (resultSet != null) {
+ resultSet.close();
+ }
+
+ if (statement != null) {
+ statement.close();
+ }
+
+ if (connection != null) {
+ connection.close();
+ }
+
+ } finally {
+ isClosed = true;
+ }
}
public void deleteRow() throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ resultSet.deleteRow();
}
public int findColumn(String columnName) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.findColumn(columnName);
}
public boolean first() throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.first();
}
public Array getArray(int columnIndex) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getArray(columnIndex);
}
public Array getArray(String colName) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getArray(colName);
}
public InputStream getAsciiStream(int columnIndex) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getAsciiStream(columnIndex);
}
public InputStream getAsciiStream(String columnName) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getAsciiStream(columnName);
}
public BigDecimal getBigDecimal(int columnIndex) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getBigDecimal(columnIndex);
}
- public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException {
- throw new NotImplementedException();
+ public BigDecimal getBigDecimal(int columnIndex, int scale)
+ throws SQLException {
+ checkValid();
+ return resultSet.getBigDecimal(columnIndex, scale);
}
public BigDecimal getBigDecimal(String columnName) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getBigDecimal(columnName);
}
- public BigDecimal getBigDecimal(String columnName, int scale) throws SQLException {
- throw new NotImplementedException();
+ public BigDecimal getBigDecimal(String columnName, int scale)
+ throws SQLException {
+ checkValid();
+ return resultSet.getBigDecimal(columnName, scale);
}
public InputStream getBinaryStream(int columnIndex) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getBinaryStream(columnIndex);
}
public InputStream getBinaryStream(String columnName) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getBinaryStream(columnName);
}
public Blob getBlob(int columnIndex) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getBlob(columnIndex);
}
public Blob getBlob(String columnName) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getBlob(columnName);
}
public boolean getBoolean(int columnIndex) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getBoolean(columnIndex);
}
public boolean getBoolean(String columnName) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getBoolean(columnName);
}
public byte getByte(int columnIndex) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getByte(columnIndex);
}
public byte getByte(String columnName) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getByte(columnName);
}
public byte[] getBytes(int columnIndex) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getBytes(columnIndex);
}
public byte[] getBytes(String columnName) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getBytes(columnName);
}
public Reader getCharacterStream(int columnIndex) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getCharacterStream(columnIndex);
}
public Reader getCharacterStream(String columnName) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getCharacterStream(columnName);
}
public Clob getClob(int columnIndex) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getClob(columnIndex);
}
public Clob getClob(String colName) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getClob(colName);
}
public String getCursorName() throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getCursorName();
}
public Date getDate(int columnIndex) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getDate(columnIndex);
}
public Date getDate(int columnIndex, Calendar cal) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getDate(columnIndex, cal);
}
public Date getDate(String columnName) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getDate(columnName);
}
public Date getDate(String columnName, Calendar cal) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getDate(columnName, cal);
}
public double getDouble(int columnIndex) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getDouble(columnIndex);
}
public double getDouble(String columnName) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getDouble(columnName);
}
public float getFloat(int columnIndex) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getFloat(columnIndex);
}
public float getFloat(String columnName) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getFloat(columnName);
}
public int getInt(int columnIndex) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getInt(columnIndex);
}
public int getInt(String columnName) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getInt(columnName);
}
public long getLong(int columnIndex) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getLong(columnIndex);
}
public long getLong(String columnName) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getLong(columnName);
}
public ResultSetMetaData getMetaData() throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getMetaData();
}
public Object getObject(int columnIndex) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getObject(columnIndex);
}
- public Object getObject(int columnIndex, Map<String, Class<?>> map) throws SQLException {
- throw new NotImplementedException();
+ public Object getObject(int columnIndex, Map<String, Class<?>> map)
+ throws SQLException {
+ checkValid();
+ return resultSet.getObject(columnIndex, map);
}
public Object getObject(String columnName) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getObject(columnName);
}
- public Object getObject(String columnName, Map<String, Class<?>> map) throws SQLException {
- throw new NotImplementedException();
+ public Object getObject(String columnName, Map<String, Class<?>> map)
+ throws SQLException {
+ checkValid();
+ return resultSet.getObject(columnName, map);
}
public Ref getRef(int columnIndex) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getRef(columnIndex);
}
public Ref getRef(String colName) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getRef(colName);
}
public int getRow() throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getRow();
}
public short getShort(int columnIndex) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getShort(columnIndex);
}
public short getShort(String columnName) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getShort(columnName);
}
public Statement getStatement() throws SQLException {
- throw new NotImplementedException();
+ if (statement != null && isClosed) {
+ throw new SQLException();
+ }
+ return statement;
}
public String getString(int columnIndex) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getString(columnIndex);
}
public String getString(String columnName) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getString(columnName);
}
public Time getTime(int columnIndex) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getTime(columnIndex);
}
public Time getTime(int columnIndex, Calendar cal) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getTime(columnIndex, cal);
}
public Time getTime(String columnName) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getTime(columnName);
}
public Time getTime(String columnName, Calendar cal) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getTime(columnName, cal);
}
public Timestamp getTimestamp(int columnIndex) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getTimestamp(columnIndex);
}
- public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException {
- throw new NotImplementedException();
+ public Timestamp getTimestamp(int columnIndex, Calendar cal)
+ throws SQLException {
+ checkValid();
+ return resultSet.getTimestamp(columnIndex, cal);
}
public Timestamp getTimestamp(String columnName) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getTimestamp(columnName);
}
- public Timestamp getTimestamp(String columnName, Calendar cal) throws SQLException {
- throw new NotImplementedException();
+ public Timestamp getTimestamp(String columnName, Calendar cal)
+ throws SQLException {
+ checkValid();
+ return resultSet.getTimestamp(columnName, cal);
}
public java.net.URL getURL(int columnIndex) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getURL(columnIndex);
}
public java.net.URL getURL(String columnName) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getURL(columnName);
}
public InputStream getUnicodeStream(int columnIndex) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getUnicodeStream(columnIndex);
}
public InputStream getUnicodeStream(String columnName) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getUnicodeStream(columnName);
}
public SQLWarning getWarnings() throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.getWarnings();
}
public void insertRow() throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ resultSet.insertRow();
}
public boolean isAfterLast() throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.isAfterLast();
}
public boolean isBeforeFirst() throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.isBeforeFirst();
}
public boolean isFirst() throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.isFirst();
}
public boolean isLast() throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.isLast();
}
public boolean last() throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.last();
}
public void moveToCurrentRow() throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ resultSet.moveToCurrentRow();
}
public void moveToInsertRow() throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ resultSet.moveToInsertRow();
}
public boolean next() throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.next();
}
public boolean previous() throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.previous();
}
public void refreshRow() throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ resultSet.refreshRow();
}
public boolean relative(int rows) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.relative(rows);
}
public boolean rowDeleted() throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.rowDeleted();
}
public boolean rowInserted() throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.rowInserted();
}
public boolean rowUpdated() throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.rowUpdated();
}
public void updateArray(int columnIndex, Array x) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ resultSet.updateArray(columnIndex, x);
}
public void updateArray(String columnName, Array x) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ resultSet.updateArray(columnName, x);
}
- public void updateAsciiStream(int columnIndex, InputStream x, int length) throws SQLException {
- throw new NotImplementedException();
+ public void updateAsciiStream(int columnIndex, InputStream x, int length)
+ throws SQLException {
+ checkValid();
+ resultSet.updateAsciiStream(columnIndex, x, length);
}
- public void updateAsciiStream(String columnName, InputStream x, int length) throws SQLException {
- throw new NotImplementedException();
+ public void updateAsciiStream(String columnName, InputStream x, int length)
+ throws SQLException {
+ checkValid();
+ resultSet.updateAsciiStream(columnName, x, length);
}
- public void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException {
- throw new NotImplementedException();
+ public void updateBigDecimal(int columnIndex, BigDecimal x)
+ throws SQLException {
+ checkValid();
+ resultSet.updateBigDecimal(columnIndex, x);
}
- public void updateBigDecimal(String columnName, BigDecimal x) throws SQLException {
- throw new NotImplementedException();
+ public void updateBigDecimal(String columnName, BigDecimal x)
+ throws SQLException {
+ checkValid();
+ resultSet.updateBigDecimal(columnName, x);
}
- public void updateBinaryStream(int columnIndex, InputStream x, int length) throws SQLException {
- throw new NotImplementedException();
+ public void updateBinaryStream(int columnIndex, InputStream x, int length)
+ throws SQLException {
+ checkValid();
+ resultSet.updateBinaryStream(columnIndex, x, length);
}
- public void updateBinaryStream(String columnName, InputStream x, int length) throws SQLException {
- throw new NotImplementedException();
+ public void updateBinaryStream(String columnName, InputStream x, int length)
+ throws SQLException {
+ checkValid();
+ resultSet.updateBinaryStream(columnName, x, length);
}
public void updateBlob(int columnIndex, Blob x) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ resultSet.updateBlob(columnIndex, x);
}
public void updateBlob(String columnName, Blob x) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ resultSet.updateBlob(columnName, x);
}
public void updateBoolean(int columnIndex, boolean x) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ resultSet.updateBoolean(columnIndex, x);
}
public void updateBoolean(String columnName, boolean x) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ resultSet.updateBoolean(columnName, x);
}
public void updateByte(int columnIndex, byte x) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ resultSet.updateByte(columnIndex, x);
}
public void updateByte(String columnName, byte x) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ resultSet.updateByte(columnName, x);
}
public void updateBytes(int columnIndex, byte[] x) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ resultSet.updateBytes(columnIndex, x);
}
public void updateBytes(String columnName, byte[] x) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ resultSet.updateBytes(columnName, x);
}
- public void updateCharacterStream(int columnIndex, Reader x, int length) throws SQLException {
- throw new NotImplementedException();
+ public void updateCharacterStream(int columnIndex, Reader x, int length)
+ throws SQLException {
+ checkValid();
+ resultSet.updateCharacterStream(columnIndex, x, length);
}
- public void updateCharacterStream(String columnName, Reader reader, int length) throws SQLException {
- throw new NotImplementedException();
+ public void updateCharacterStream(String columnName, Reader reader,
+ int length) throws SQLException {
+ checkValid();
+ resultSet.updateCharacterStream(columnName, reader, length);
}
public void updateClob(int columnIndex, Clob x) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ resultSet.updateClob(columnIndex, x);
}
public void updateClob(String columnName, Clob x) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ resultSet.updateClob(columnName, x);
}
public void updateDate(int columnIndex, Date x) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ resultSet.updateDate(columnIndex, x);
}
public void updateDate(String columnName, Date x) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ resultSet.updateDate(columnName, x);
}
public void updateDouble(int columnIndex, double x) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ resultSet.updateDouble(columnIndex, x);
}
public void updateDouble(String columnName, double x) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ resultSet.updateDouble(columnName, x);
}
public void updateFloat(int columnIndex, float x) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ resultSet.updateFloat(columnIndex, x);
}
public void updateFloat(String columnName, float x) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ resultSet.updateFloat(columnName, x);
}
public void updateInt(int columnIndex, int x) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ resultSet.updateInt(columnIndex, x);
}
public void updateInt(String columnName, int x) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ resultSet.updateInt(columnName, x);
}
public void updateLong(int columnIndex, long x) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ resultSet.updateLong(columnIndex, x);
}
public void updateLong(String columnName, long x) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ resultSet.updateLong(columnName, x);
}
public void updateNull(int columnIndex) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ resultSet.updateNull(columnIndex);
}
public void updateNull(String columnName) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ resultSet.updateNull(columnName);
}
public void updateObject(int columnIndex, Object x) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ resultSet.updateObject(columnIndex, x);
}
- public void updateObject(int columnIndex, Object x, int scale) throws SQLException {
- throw new NotImplementedException();
+ public void updateObject(int columnIndex, Object x, int scale)
+ throws SQLException {
+ checkValid();
+ resultSet.updateObject(columnIndex, x, scale);
}
public void updateObject(String columnName, Object x) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ resultSet.updateObject(columnName, x);
}
- public void updateObject(String columnName, Object x, int scale) throws SQLException {
- throw new NotImplementedException();
+ public void updateObject(String columnName, Object x, int scale)
+ throws SQLException {
+ checkValid();
+ resultSet.updateObject(columnName, x, scale);
}
public void updateRef(int columnIndex, Ref x) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ resultSet.updateRef(columnIndex, x);
}
public void updateRef(String columnName, Ref x) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ resultSet.updateRef(columnName, x);
}
public void updateRow() throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ resultSet.updateRow();
}
public void updateShort(int columnIndex, short x) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ resultSet.updateShort(columnIndex, x);
}
public void updateShort(String columnName, short x) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ resultSet.updateShort(columnName, x);
}
public void updateString(int columnIndex, String x) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ resultSet.updateString(columnIndex, x);
}
public void updateString(String columnName, String x) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ resultSet.updateString(columnName, x);
}
public void updateTime(int columnIndex, Time x) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ resultSet.updateTime(columnIndex, x);
}
public void updateTime(String columnName, Time x) throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ resultSet.updateTime(columnName, x);
}
- public void updateTimestamp(int columnIndex, Timestamp x) throws SQLException {
- throw new NotImplementedException();
+ public void updateTimestamp(int columnIndex, Timestamp x)
+ throws SQLException {
+ checkValid();
+ resultSet.updateTimestamp(columnIndex, x);
}
- public void updateTimestamp(String columnName, Timestamp x) throws SQLException {
- throw new NotImplementedException();
+ public void updateTimestamp(String columnName, Timestamp x)
+ throws SQLException {
+ checkValid();
+ resultSet.updateTimestamp(columnName, x);
}
public boolean wasNull() throws SQLException {
- throw new NotImplementedException();
+ checkValid();
+ return resultSet.wasNull();
}
public int getHoldability() throws SQLException {
// TODO Auto-generated method stub
return 0;
}
-
+
+ public int getConcurrency() throws SQLException {
+ if (resultSet == null) {
+ throw new NullPointerException();
+ }
+ return resultSet.getConcurrency();
+ }
+
public Reader getNCharacterStream(int columnIndex) throws SQLException {
// TODO Auto-generated method stub
return null;
@@ -847,4 +1128,41 @@
}
+ public int getFetchDirection() throws SQLException {
+ if (resultSet == null) {
+ throw new NullPointerException();
+ }
+
+ return resultSet.getFetchDirection();
+ }
+
+ private void checkValid() throws SQLException {
+ if (resultSet == null && connection == null) {
+ throw new SQLException(Messages.getString("rowset.30")); //$NON-NLS-1$
+ }
+
+ if (resultSet == null && connection != null) {
+ throw new NullPointerException();
+ }
+ }
+
+ private void initialProperties() {
+ try {
+ setEscapeProcessing(true);
+ setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
+ setConcurrency(ResultSet.CONCUR_UPDATABLE);
+ setType(ResultSet.TYPE_SCROLL_INSENSITIVE);
+ setMaxRows(0);
+ setQueryTimeout(0);
+ setShowDeleted(false);
+ setUsername(null);
+ setPassword(null);
+ setMaxFieldSize(0);
+ setTypeMap(null);
+ setFetchSize(0);
+ } catch (SQLException e) {
+ // ignore, never reached
+ }
+
+ }
}
Modified: harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/CachedRow.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/CachedRow.java?rev=646264&r1=646263&r2=646264&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/CachedRow.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/CachedRow.java Wed Apr 9 04:01:14 2008
@@ -16,10 +16,17 @@
*/
package org.apache.harmony.sql.internal.rowset;
+import java.io.Serializable;
import java.sql.SQLException;
+import java.sql.SQLWarning;
import java.util.BitSet;
-public class CachedRow implements Cloneable {
+import org.apache.harmony.sql.internal.nls.Messages;
+
+public class CachedRow implements Cloneable, Serializable {
+
+ private static final long serialVersionUID = 5131958045838461662L;
+
private Object[] columnData;
private Object[] originalColumnData;
@@ -34,6 +41,16 @@
private boolean nonUpdateable = false;
+ private SQLWarning sqlWarning = null;
+
+ public SQLWarning getSqlWarning() {
+ return sqlWarning;
+ }
+
+ public void setSqlWarning(SQLWarning sqlWarning) {
+ this.sqlWarning = sqlWarning;
+ }
+
public CachedRow(Object[] columnData) {
this.columnData = columnData.clone();
originalColumnData = columnData.clone();
@@ -48,19 +65,7 @@
mask.set(i);
}
- public void setUnavailable() {
- // FIXME: What is this method used for?
- setDelete();
- setInsert();
- mask.clear();
- mask.flip(0, columnData.length);
- }
-
public void setNonUpdateable() {
- // setDelete();
- // setInsert();
- // mask.clear();
- // mask.flip(0,columnData.length);
nonUpdateable = true;
}
@@ -110,8 +115,8 @@
public void updateObject(int columnIndex, Object x) throws SQLException {
if (nonUpdateable) {
- // TODO load message from resource file
- throw new SQLException("Not Updateable of the CurrentRow");
+ // rowset.21=Not Updateable of the CurrentRow
+ throw new SQLException(Messages.getString("rowset.21")); //$NON-NLS-1$
}
columnData[columnIndex - 1] = x;
@@ -128,6 +133,14 @@
isInsert = false;
mask.flip(0, columnData.length);
originalColumnData = columnData.clone();
+ }
+
+ public void restoreOriginal() {
+ isUpdate = false;
+ isDelete = false;
+ isInsert = false;
+ mask.flip(0, columnData.length);
+ columnData = originalColumnData.clone();
}
public Object getObject(int columnIndex) {