[Mulgara-svn] r127 - branches/java-1.6/src/jar/util/java/org/mulgara/util
pag at mulgara.org
pag at mulgara.org
Sat Nov 4 21:21:02 UTC 2006
Author: pag
Date: 2006-11-04 15:21:02 -0600 (Sat, 04 Nov 2006)
New Revision: 127
Modified:
branches/java-1.6/src/jar/util/java/org/mulgara/util/AbstractMulgaraResultSet.java
branches/java-1.6/src/jar/util/java/org/mulgara/util/ResultSetMetaDataImpl.java
branches/java-1.6/src/jar/util/java/org/mulgara/util/TestResultSet.java
Log:
Initial branch. Compiles in Java-1.6 (not in 1.5). DOES NOT PASS ALL TESTS
Modified: branches/java-1.6/src/jar/util/java/org/mulgara/util/AbstractMulgaraResultSet.java
===================================================================
--- branches/java-1.6/src/jar/util/java/org/mulgara/util/AbstractMulgaraResultSet.java 2006-11-04 20:52:56 UTC (rev 126)
+++ branches/java-1.6/src/jar/util/java/org/mulgara/util/AbstractMulgaraResultSet.java 2006-11-04 21:21:02 UTC (rev 127)
@@ -1617,4 +1617,48 @@
throw new IllegalArgumentException("No such column " + columnName);
}
+
+
+ //--------------------------Java 1.6-----------------------------------
+
+ /**
+ * Returns an object that implements the given interface to allow access to
+ * non-standard methods, or standard methods not exposed by the proxy. If the
+ * receiver implements the interface then the result is the receiver or a
+ * proxy for the receiver. If the receiver is a wrapper and the wrapped
+ * object implements the interface then the result is the wrapped object or a
+ * proxy for the wrapped object. Otherwise return the the result of calling
+ * <code>unwrap</code> recursively on the wrapped object or a proxy for that
+ * result. If the receiver is not a wrapper and does not implement the
+ * interface, then an <code>SQLException</code> is thrown.
+ *
+ * @param iface A Class defining an interface that the result must implement.
+ * @return an object that implements the interface. May be a proxy for the actual implementing object.
+ * @throws SQLException If no object found that implements the interface.
+ */
+ public <T> T unwrap(Class<T> iface) throws SQLException {
+ throw new SQLException(this.getClass().getName() + " does not wrap any objects");
+ }
+
+
+ /**
+ * Returns true if this either implements the interface argument or is
+ * directly or indirectly a wrapper for an object that does. Returns false
+ * otherwise. If this implements the interface then return true, else if this
+ * is a wrapper then return the result of recursively calling
+ * <code>isWrapperFor</code> on the wrapped object. If this does not
+ * implement the interface and is not a wrapper, return false. This method
+ * should be implemented as a low-cost operation compared to
+ * <code>unwrap</code> so that callers can use this method to avoid expensive
+ * <code>unwrap</code> calls that may fail. If this method returns true then
+ * calling unwrap with the same argument should succeed.
+ *
+ * @param iface a Class defining an interface.
+ * @return true if this implements the interface or directly or indirectly wraps an object that does.
+ * @throws SQLException if an error occurs while determining whether this is a wrapper for an object with the given interface.
+ */
+ public boolean isWrapperFor(Class<?> iface) throws SQLException {
+ return false;
+ }
+
}
Modified: branches/java-1.6/src/jar/util/java/org/mulgara/util/ResultSetMetaDataImpl.java
===================================================================
--- branches/java-1.6/src/jar/util/java/org/mulgara/util/ResultSetMetaDataImpl.java 2006-11-04 20:52:56 UTC (rev 126)
+++ branches/java-1.6/src/jar/util/java/org/mulgara/util/ResultSetMetaDataImpl.java 2006-11-04 21:21:02 UTC (rev 127)
@@ -387,4 +387,47 @@
return "java.lang.String";
}
+
+ //--------------------------Java 1.6-----------------------------------
+
+ /**
+ * Returns an object that implements the given interface to allow access to
+ * non-standard methods, or standard methods not exposed by the proxy. If the
+ * receiver implements the interface then the result is the receiver or a
+ * proxy for the receiver. If the receiver is a wrapper and the wrapped
+ * object implements the interface then the result is the wrapped object or a
+ * proxy for the wrapped object. Otherwise return the the result of calling
+ * <code>unwrap</code> recursively on the wrapped object or a proxy for that
+ * result. If the receiver is not a wrapper and does not implement the
+ * interface, then an <code>SQLException</code> is thrown.
+ *
+ * @param iface A Class defining an interface that the result must implement.
+ * @return an object that implements the interface. May be a proxy for the actual implementing object.
+ * @throws SQLException If no object found that implements the interface.
+ */
+ public <T> T unwrap(Class<T> iface) throws SQLException {
+ throw new SQLException(ResultSetMetaDataImpl.class.getName() + " does not wrap any objects");
+ }
+
+
+ /**
+ * Returns true if this either implements the interface argument or is
+ * directly or indirectly a wrapper for an object that does. Returns false
+ * otherwise. If this implements the interface then return true, else if this
+ * is a wrapper then return the result of recursively calling
+ * <code>isWrapperFor</code> on the wrapped object. If this does not
+ * implement the interface and is not a wrapper, return false. This method
+ * should be implemented as a low-cost operation compared to
+ * <code>unwrap</code> so that callers can use this method to avoid expensive
+ * <code>unwrap</code> calls that may fail. If this method returns true then
+ * calling unwrap with the same argument should succeed.
+ *
+ * @param iface a Class defining an interface.
+ * @return true if this implements the interface or directly or indirectly wraps an object that does.
+ * @throws SQLException if an error occurs while determining whether this is a wrapper for an object with the given interface.
+ */
+ public boolean isWrapperFor(Class<?> iface) throws SQLException {
+ return false;
+ }
+
}
Modified: branches/java-1.6/src/jar/util/java/org/mulgara/util/TestResultSet.java
===================================================================
--- branches/java-1.6/src/jar/util/java/org/mulgara/util/TestResultSet.java 2006-11-04 20:52:56 UTC (rev 126)
+++ branches/java-1.6/src/jar/util/java/org/mulgara/util/TestResultSet.java 2006-11-04 21:21:02 UTC (rev 127)
@@ -31,6 +31,7 @@
import java.io.Serializable;
import java.sql.*;
import java.util.*;
+import java.io.*;
// third party packages
import org.apache.log4j.Category;
@@ -544,6 +545,196 @@
return returnState;
}
+ //--------------------------Java 1.6-----------------------------------
+
+ /**
+ * Returns an object that implements the given interface to allow access to
+ * non-standard methods, or standard methods not exposed by the proxy. If the
+ * receiver implements the interface then the result is the receiver or a
+ * proxy for the receiver. If the receiver is a wrapper and the wrapped
+ * object implements the interface then the result is the wrapped object or a
+ * proxy for the wrapped object. Otherwise return the the result of calling
+ * <code>unwrap</code> recursively on the wrapped object or a proxy for that
+ * result. If the receiver is not a wrapper and does not implement the
+ * interface, then an <code>SQLException</code> is thrown.
+ *
+ * @param iface A Class defining an interface that the result must implement.
+ * @return an object that implements the interface. May be a proxy for the actual implementing object.
+ * @throws SQLException If no object found that implements the interface.
+ */
+ public <T> T unwrap(Class<T> iface) throws SQLException {
+ try {
+ return (T)rows;
+ } catch (ClassCastException cce) {
+ throw new SQLException(iface.getClass().getName() + " is not a class wrapped by " + TestResultSet.class.getName());
+ }
+ }
+
+
+ /**
+ * Returns true if this either implements the interface argument or is
+ * directly or indirectly a wrapper for an object that does. Returns false
+ * otherwise. If this implements the interface then return true, else if this
+ * is a wrapper then return the result of recursively calling
+ * <code>isWrapperFor</code> on the wrapped object. If this does not
+ * implement the interface and is not a wrapper, return false. This method
+ * should be implemented as a low-cost operation compared to
+ * <code>unwrap</code> so that callers can use this method to avoid expensive
+ * <code>unwrap</code> calls that may fail. If this method returns true then
+ * calling unwrap with the same argument should succeed.
+ *
+ * @param iface a Class defining an interface.
+ * @return true if this implements the interface or directly or indirectly wraps an object that does.
+ * @throws SQLException if an error occurs while determining whether this is a wrapper for an object with the given interface.
+ */
+ public boolean isWrapperFor(Class<?> iface) throws SQLException {
+ return List.class.equals(iface) || RowList.class.equals(iface);
+ }
+
+ public RowId getRowId(String columnLabel) throws SQLException {
+ throw newSQLFeatureNotSupportedException();
+ }
+
+ public RowId getRowId(int columnIndex) throws SQLException {
+ throw newSQLFeatureNotSupportedException();
+ }
+
+ public void updateRowId(int columnIndex, RowId x) throws SQLException {
+ throw newSQLFeatureNotSupportedException();
+ }
+
+ public void updateRowId(String columnLabel, RowId x) throws SQLException {
+ throw newSQLFeatureNotSupportedException();
+ }
+
+ public int getHoldability() throws SQLException {
+ return ResultSet.HOLD_CURSORS_OVER_COMMIT;
+ }
+
+ public boolean isClosed() throws SQLException {
+ return false;
+ }
+
+ public void updateNString(int columnIndex, String nString) throws SQLException {
+ throw newSQLFeatureNotSupportedException();
+ }
+
+ public void updateNString(String columnLabel, String nString) throws SQLException {
+ throw newSQLFeatureNotSupportedException();
+ }
+
+ public void updateNClob(int columnIndex, NClob nClob) throws SQLException {
+ throw newSQLFeatureNotSupportedException();
+ }
+
+ public void updateNClob(String columnLabel, NClob nClob) throws SQLException {
+ throw newSQLFeatureNotSupportedException();
+ }
+
+ public NClob getNClob(int columnIndex) throws SQLException {
+ throw newSQLFeatureNotSupportedException();
+ }
+
+ public NClob getNClob(String columnLabel) throws SQLException {
+ throw newSQLFeatureNotSupportedException();
+ }
+
+ public SQLXML getSQLXML(int columnIndex) throws SQLException {
+ throw newSQLFeatureNotSupportedException();
+ }
+
+ public SQLXML getSQLXML(String columnLabel) throws SQLException {
+ throw newSQLFeatureNotSupportedException();
+ }
+
+ public void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQLException {
+ throw newSQLFeatureNotSupportedException();
+ }
+
+ public void updateSQLXML(String columnLabel, SQLXML xmlObject) throws SQLException {
+ throw newSQLFeatureNotSupportedException();
+ }
+
+ public String getNString(int columnIndex) throws SQLException {
+ throw newSQLFeatureNotSupportedException();
+ }
+
+ public String getNString(String columnLabel) throws SQLException {
+ throw newSQLFeatureNotSupportedException();
+ }
+
+ public Reader getNCharacterStream(int columnIndex) throws SQLException {
+ throw newSQLFeatureNotSupportedException();
+ }
+
+ public Reader getNCharacterStream(String columnLabel) throws SQLException {
+ throw newSQLFeatureNotSupportedException();
+ }
+
+ public void updateNCharacterStream(int columnIndex, Reader x, long length) throws SQLException {
+ throw newSQLFeatureNotSupportedException();
+ }
+
+ public void updateNCharacterStream(String columnLabel, Reader reader, long length) throws SQLException {
+ throw newSQLFeatureNotSupportedException();
+ }
+
+ public void updateAsciiStream(int columnIndex, InputStream x, long length) throws SQLException {
+ throw newSQLFeatureNotSupportedException();
+ }
+
+ public void updateBinaryStream(int columnIndex, InputStream x, long length) throws SQLException {
+ throw newSQLFeatureNotSupportedException();
+ }
+
+ public void updateCharacterStream(int columnIndex, Reader x, long length) throws SQLException {
+ throw newSQLFeatureNotSupportedException();
+ }
+
+ public void updateAsciiStream(String columnLabel, InputStream x, long length) throws SQLException {
+ throw newSQLFeatureNotSupportedException();
+ }
+
+ public void updateBinaryStream(String columnLabel, InputStream x, long length) throws SQLException {
+ throw newSQLFeatureNotSupportedException();
+ }
+
+ public void updateCharacterStream(String columnLabel, Reader reader, long length) throws SQLException {
+ throw newSQLFeatureNotSupportedException();
+ }
+
+ public void updateBlob(int columnIndex, InputStream inputStream, long length) throws SQLException {
+ throw newSQLFeatureNotSupportedException();
+ }
+
+ public void updateBlob(String columnLabel, InputStream inputStream, long length) throws SQLException {
+ throw newSQLFeatureNotSupportedException();
+ }
+
+ public void updateClob(int columnIndex, Reader reader, long length) throws SQLException {
+ throw newSQLFeatureNotSupportedException();
+ }
+
+ public void updateClob(String columnLabel, Reader reader, long length) throws SQLException {
+ throw newSQLFeatureNotSupportedException();
+ }
+
+ public void updateNClob(int columnIndex, Reader reader, long length) throws SQLException {
+ throw newSQLFeatureNotSupportedException();
+ }
+
+ public void updateNClob(String columnLabel, Reader reader, long length) throws SQLException {
+ throw newSQLFeatureNotSupportedException();
+ }
+
+ private SQLException newSQLFeatureNotSupportedException() {
+ try {
+ return (SQLException)Class.forName("java.sql.SQLFeatureNotSupportedException").newInstance();
+ } catch (Exception e) {
+ return new SQLException();
+ }
+ }
+
//
// Relational algebra methods
//
More information about the Mulgara-svn
mailing list