Changeset: c5efd6e661e5 for monetdb-java
URL: https://dev.monetdb.org/hg/monetdb-java?cmd=changeset;node=c5efd6e661e5
Modified Files:
        src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java
        src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java
        src/main/java/nl/cwi/monetdb/jdbc/MonetSavepoint.java
        src/main/java/nl/cwi/monetdb/jdbc/types/INET.java
        src/main/java/nl/cwi/monetdb/jdbc/types/URL.java
Branch: default
Log Message:

Add "final" keyword to classes, method arguments and local variables where 
possible.`
Improved error messages in MonetSavepoint.
Removed two not needed updateNCharacterStream() methods from MonetResultSet.


diffs (truncated from 1690 to 300 lines):

diff --git a/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java 
b/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java
--- a/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java
+++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java
@@ -1892,7 +1892,7 @@ public class MonetConnection
         * <tt>&amp;"qt" "id" "tc" "cc" "rc"</tt>.
         */
        // {{{ ResultSetResponse class implementation
-       class ResultSetResponse implements Response {
+       final class ResultSetResponse implements Response {
                /** The number of columns in this result */
                public final int columncount;
                /** The total number of rows this result set has */
@@ -2319,7 +2319,7 @@ public class MonetConnection
         * object, it is possible for threads to get the same data.
         */
        // {{{ DataBlockResponse class implementation
-       static class DataBlockResponse implements Response {
+       private final static class DataBlockResponse implements Response {
                /** The String array to keep the data in */
                private final String[] data;
 
@@ -2429,7 +2429,7 @@ public class MonetConnection
         * <tt>&amp;2 0 -1</tt>
         */
        // {{{ UpdateResponse class implementation
-       static class UpdateResponse implements Response {
+       final static class UpdateResponse implements Response {
                public final int count;
                public final String lastid;
 
@@ -2502,7 +2502,7 @@ public class MonetConnection
         * <tt>&amp;4 (t|f)</tt>
         */
        // {{{ AutoCommitResponse class implementation
-       class AutoCommitResponse extends SchemaResponse {
+       private final class AutoCommitResponse extends SchemaResponse {
                public final boolean autocommit;
 
                public AutoCommitResponse(final boolean ac) {
@@ -2518,7 +2518,7 @@ public class MonetConnection
         * responsibility to the caller to prevent concurrent access.
         */
        // {{{ ResponseList class implementation
-       class ResponseList {
+       final class ResponseList {
                /** The cache size (number of rows in a DataBlockResponse 
object) */
                private final int cachesize;
                /** The maximum number of results for this query */
diff --git a/src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java 
b/src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java
--- a/src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java
+++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java
@@ -10,14 +10,9 @@ package nl.cwi.monetdb.jdbc;
 
 import nl.cwi.monetdb.mcl.parser.MCLParseException;
 import nl.cwi.monetdb.mcl.parser.TupleLineParser;
-import java.io.ByteArrayInputStream;
 import java.io.InputStream;
 import java.io.Reader;
-import java.io.StringReader;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
 import java.math.BigDecimal;
-import java.net.MalformedURLException;
 import java.net.URL;
 import java.sql.Array;
 import java.sql.Blob;
@@ -90,10 +85,10 @@ public class MonetResultSet
        // they are accessed from MonetVirtualResultSet.absolute()
        /** The current line of the buffer split in columns */
        protected final TupleLineParser tlp;
+       /** The number of rows in this ResultSet */
+       protected final int tupleCount;
        /** The current position of the cursor for this ResultSet object */
        protected int curRow = 0;
-       /** The number of rows in this ResultSet */
-       protected final int tupleCount;
 
        /** The type of this ResultSet (forward or scrollable) */
        private int type = DEF_RESULTSETTYPE;
@@ -115,8 +110,8 @@ public class MonetResultSet
         * @throws SQLException is a protocol error occurs
         */
        MonetResultSet(
-               Statement statement,
-               MonetConnection.ResultSetResponse header)
+               final Statement statement,
+               final MonetConnection.ResultSetResponse header)
                throws SQLException
        {
                if (statement == null) {
@@ -161,23 +156,20 @@ public class MonetResultSet
         * @throws SQLException is a protocol error occurs
         */
        MonetResultSet(
-               Statement statement,
-               String[] columns,
-               String[] types,
-               int results
-               ) throws IllegalArgumentException
+               final Statement statement,
+               final String[] columns,
+               final String[] types,
+               final int results)
+               throws IllegalArgumentException
        {
-               if (statement == null) {
-                       throw new IllegalArgumentException("Statement may not 
be null!");
-               }
-               if (columns == null || types == null) {
-                       throw new IllegalArgumentException("One of the given 
arguments is null!");
+               if (statement == null || columns == null || types == null) {
+                       throw new IllegalArgumentException("One of the given 
arguments is null");
                }
                if (columns.length != types.length) {
-                       throw new IllegalArgumentException("Given arguments are 
not the same size!");
+                       throw new IllegalArgumentException("Given arrays are 
not the same size");
                }
                if (results < 0) {
-                       throw new IllegalArgumentException("Negative rowcount 
not allowed!");
+                       throw new IllegalArgumentException("Negative rowcount 
not allowed");
                }
 
                this.statement = statement;
@@ -199,10 +191,10 @@ public class MonetResultSet
         * By doing it once (in the constructor) we can avoid doing this in 
many getXyz()
         * methods again and again thereby improving getXyz() method 
performance.
         */
-       private void populateJdbcSQLtypesArray() {
+       private final void populateJdbcSQLtypesArray() {
                MonetConnection connection = null;
                try {
-                       connection = (MonetConnection)statement.getConnection();
+                       connection = (MonetConnection) 
statement.getConnection();
                } catch (SQLException se) { /* ignore it */ }
 
                for (int i = 0; i < types.length; i++) {
@@ -269,7 +261,7 @@ public class MonetResultSet
                // store it
                curRow = row;
 
-               String tmpLine = (header != null) ? header.getLine(row - 1) : 
null;
+               final String tmpLine = (header != null) ? header.getLine(row - 
1) : null;
                if (tmpLine == null)
                        return false;
 
@@ -343,7 +335,7 @@ public class MonetResultSet
         *      a database access error occurs or this method is called on a 
closed result set
         */
        @Override
-       public int findColumn(String columnLabel) throws SQLException {
+       public int findColumn(final String columnLabel) throws SQLException {
                checkNotClosed();
                if (columnLabel != null) {
                        final int array_size = columns.length;
@@ -374,21 +366,21 @@ public class MonetResultSet
        }
 
        @Override
-       public Array getArray(int columnIndex) throws SQLException {
+       public Array getArray(final int columnIndex) throws SQLException {
                throw newSQLFeatureNotSupportedException("getArray");
        }
        @Override
-       public Array getArray(String columnLabel) throws SQLException {
+       public Array getArray(final String columnLabel) throws SQLException {
                throw newSQLFeatureNotSupportedException("getArray");
        }
 
        /* Mapi doesn't allow something for streams at the moment, thus all not 
implemented for now */
        @Override
-       public InputStream getAsciiStream(int columnIndex) throws SQLException {
+       public InputStream getAsciiStream(final int columnIndex) throws 
SQLException {
                throw newSQLFeatureNotSupportedException("getAsciiStream");
        }
        @Override
-       public InputStream getAsciiStream(String columnLabel) throws 
SQLException {
+       public InputStream getAsciiStream(final String columnLabel) throws 
SQLException {
                throw newSQLFeatureNotSupportedException("getAsciiStream");
        }
 
@@ -423,22 +415,22 @@ public class MonetResultSet
         * database access error occurs or this method is called on a closed 
result set
         */
        @Override
-       public InputStream getBinaryStream(int columnIndex) throws SQLException 
{
+       public InputStream getBinaryStream(final int columnIndex) throws 
SQLException {
                checkNotClosed();
                try {
                        switch (JdbcSQLTypes[columnIndex - 1]) {
                                case Types.BLOB:
-                                       Blob blob = getBlob(columnIndex);
+                                       final Blob blob = getBlob(columnIndex);
                                        if (blob == null)
                                                return null;
                                        return blob.getBinaryStream();
                                case Types.BINARY:
                                case Types.VARBINARY:
                                case Types.LONGVARBINARY:
-                                       byte[] bte = getBytes(columnIndex);
+                                       final byte[] bte = 
getBytes(columnIndex);
                                        if (bte == null)
                                                return null;
-                                       return new ByteArrayInputStream(bte);
+                                       return new 
java.io.ByteArrayInputStream(bte);
                        }
                        throw new SQLException("Cannot operate on " + 
types[columnIndex - 1] + " type", "M1M05");
                } catch (IndexOutOfBoundsException e) {
@@ -468,7 +460,7 @@ public class MonetResultSet
         * database access error occurs or this method is called on a closed 
result set
         */
        @Override
-       public InputStream getBinaryStream(String columnLabel) throws 
SQLException {
+       public InputStream getBinaryStream(final String columnLabel) throws 
SQLException {
                return getBinaryStream(findColumn(columnLabel));
        }
 
@@ -483,16 +475,16 @@ public class MonetResultSet
         * @throws SQLException if a database access error occurs or this 
method is called on a closed result set
         */
        @Override
-       public Reader getCharacterStream(int columnIndex) throws SQLException {
+       public Reader getCharacterStream(final int columnIndex) throws 
SQLException {
                checkNotClosed();
                try {
-                       String val = tlp.values[columnIndex - 1];
+                       final String val = tlp.values[columnIndex - 1];
                        if (val == null) {
                                lastReadWasNull = true;
                                return null;
                        }
                        lastReadWasNull = false;
-                       return new StringReader(val);
+                       return new java.io.StringReader(val);
                } catch (IndexOutOfBoundsException e) {
                        throw newSQLInvalidColumnIndexException(columnIndex);
                }
@@ -509,7 +501,7 @@ public class MonetResultSet
         * @throws SQLException if a database access error occurs
         */
        @Override
-       public Reader getCharacterStream(String columnLabel) throws 
SQLException {
+       public Reader getCharacterStream(final String columnLabel) throws 
SQLException {
                return getCharacterStream(findColumn(columnLabel));
        }
 
@@ -526,7 +518,7 @@ public class MonetResultSet
         * @throws SQLException if a database access error occurs
         */
        @Override
-       public Reader getNCharacterStream(int columnIndex) throws SQLException {
+       public Reader getNCharacterStream(final int columnIndex) throws 
SQLException {
                return getCharacterStream(columnIndex);
        }
 
@@ -543,7 +535,7 @@ public class MonetResultSet
         * @throws SQLException if a database access error occurs
         */
        @Override
-       public Reader getNCharacterStream(String columnLabel) throws 
SQLException {
+       public Reader getNCharacterStream(final String columnLabel) throws 
SQLException {
                return getCharacterStream(findColumn(columnLabel));
        }
 
@@ -558,10 +550,10 @@ public class MonetResultSet
         * @throws SQLException if a database access error occurs or this 
method is called on a closed result set
         */
        @Override
-       public Blob getBlob(int columnIndex) throws SQLException {
+       public Blob getBlob(final int columnIndex) throws SQLException {
                checkNotClosed();
                try {
-                       String val = tlp.values[columnIndex - 1];
+                       final String val = tlp.values[columnIndex - 1];
                        if (val == null) {
                                lastReadWasNull = true;
                                return null;
@@ -585,7 +577,7 @@ public class MonetResultSet
         * @throws SQLException if a database access error occurs
         */
        @Override
-       public Blob getBlob(String columnLabel) throws SQLException {
+       public Blob getBlob(final String columnLabel) throws SQLException {
                return getBlob(findColumn(columnLabel));
        }
 
@@ -600,10 +592,10 @@ public class MonetResultSet
         * @throws SQLException if a database access error occurs or this 
method is called on a closed result set
         */
        @Override
-       public Clob getClob(int columnIndex) throws SQLException {
+       public Clob getClob(final int columnIndex) throws SQLException {
                checkNotClosed();
                try {
-                       String val = tlp.values[columnIndex - 1];
+                       final String val = tlp.values[columnIndex - 1];
                        if (val == null) {
                                lastReadWasNull = true;
                                return null;
@@ -627,7 +619,7 @@ public class MonetResultSet
         * @throws SQLException if a database access error occurs
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to