db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r1058554 - in /db/derby/code/trunk/java: client/org/apache/derby/client/am/ client/org/apache/derby/client/net/ engine/org/apache/derby/impl/jdbc/
Date Thu, 13 Jan 2011 13:44:13 GMT
Author: rhillegas
Date: Thu Jan 13 13:44:13 2011
New Revision: 1058554

URL: http://svn.apache.org/viewvc?rev=1058554&view=rev
Log:
DERBY-4869: Eliminate a try-catch block in the getObject(Class) overloads.

Modified:
    db/derby/code/trunk/java/client/org/apache/derby/client/am/CallableStatement40.java
    db/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSet40.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement40.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet40.java

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/CallableStatement40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/CallableStatement40.java?rev=1058554&r1=1058553&r2=1058554&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/CallableStatement40.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/CallableStatement40.java Thu
Jan 13 13:44:13 2011
@@ -342,35 +342,29 @@ public class CallableStatement40 extends
             throw mismatchException( "NULL", parameterIndex );
         }
 
-        try {
-            Object   retval;
+        Object   retval;
             
-            if ( String.class.equals( type ) ) { retval = getString( parameterIndex ); }
-            else if ( BigDecimal.class.equals( type ) ) { retval = getBigDecimal( parameterIndex
); }
-            else if ( Boolean.class.equals( type ) ) { retval = Boolean.valueOf( getBoolean(parameterIndex
) ); }
-            else if ( Byte.class.equals( type ) ) { retval = Byte.valueOf( getByte( parameterIndex
) ); }
-            else if ( Short.class.equals( type ) ) { retval = Short.valueOf( getShort( parameterIndex
) ); }
-            else if ( Integer.class.equals( type ) ) { retval = Integer.valueOf( getInt(
parameterIndex ) ); }
-            else if ( Long.class.equals( type ) ) { retval = Long.valueOf( getLong( parameterIndex
) ); }
-            else if ( Float.class.equals( type ) ) { retval = Float.valueOf( getFloat( parameterIndex
) ); }
-            else if ( Double.class.equals( type ) ) { retval = Double.valueOf( getDouble(
parameterIndex ) ); }
-            else if ( Date.class.equals( type ) ) { retval = getDate( parameterIndex ); }
-            else if ( Time.class.equals( type ) ) { retval = getTime( parameterIndex ); }
-            else if ( Timestamp.class.equals( type ) ) { retval = getTimestamp( parameterIndex
); }
-            else if ( Blob.class.equals( type ) ) { retval = getBlob( parameterIndex ); }
-            else if ( Clob.class.equals( type ) ) { retval = getClob( parameterIndex ); }
-            else if ( type.isArray() && type.getComponentType().equals( byte.class
) ) { retval = getBytes( parameterIndex ); }
-            else
-            {
-                retval = type.cast( getObject( parameterIndex ) );
-            }
+        if ( String.class.equals( type ) ) { retval = getString( parameterIndex ); }
+        else if ( BigDecimal.class.equals( type ) ) { retval = getBigDecimal( parameterIndex
); }
+        else if ( Boolean.class.equals( type ) ) { retval = Boolean.valueOf( getBoolean(parameterIndex
) ); }
+        else if ( Byte.class.equals( type ) ) { retval = Byte.valueOf( getByte( parameterIndex
) ); }
+        else if ( Short.class.equals( type ) ) { retval = Short.valueOf( getShort( parameterIndex
) ); }
+        else if ( Integer.class.equals( type ) ) { retval = Integer.valueOf( getInt( parameterIndex
) ); }
+        else if ( Long.class.equals( type ) ) { retval = Long.valueOf( getLong( parameterIndex
) ); }
+        else if ( Float.class.equals( type ) ) { retval = Float.valueOf( getFloat( parameterIndex
) ); }
+        else if ( Double.class.equals( type ) ) { retval = Double.valueOf( getDouble( parameterIndex
) ); }
+        else if ( Date.class.equals( type ) ) { retval = getDate( parameterIndex ); }
+        else if ( Time.class.equals( type ) ) { retval = getTime( parameterIndex ); }
+        else if ( Timestamp.class.equals( type ) ) { retval = getTimestamp( parameterIndex
); }
+        else if ( Blob.class.equals( type ) ) { retval = getBlob( parameterIndex ); }
+        else if ( Clob.class.equals( type ) ) { retval = getClob( parameterIndex ); }
+        else if ( type.isArray() && type.getComponentType().equals( byte.class )
) { retval = getBytes( parameterIndex ); }
+        else { retval = getObject( parameterIndex ); }
 
-            if ( wasNull() ) { retval = null; }
+        if ( wasNull() ) { retval = null; }
 
-            return type.cast( retval );
-        }
-        catch (ClassCastException e) {}
-        
+        if ( (retval == null) || (type.isInstance( retval )) ) { return type.cast( retval
); }
+                
         throw mismatchException( type.getName(), parameterIndex );
     }
     private SQLException    mismatchException( String targetTypeName, int parameterIndex
)

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSet40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSet40.java?rev=1058554&r1=1058553&r2=1058554&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSet40.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSet40.java Thu Jan
13 13:44:13 2011
@@ -277,34 +277,28 @@ public class NetResultSet40 extends NetR
             throw mismatchException( "NULL", columnIndex );
         }
 
-        try {
-            Object   retval;
+        Object   retval;
             
-            if ( String.class.equals( type ) ) { retval = getString( columnIndex ); }
-            else if ( BigDecimal.class.equals( type ) ) { retval = getBigDecimal( columnIndex
); }
-            else if ( Boolean.class.equals( type ) ) { retval = Boolean.valueOf( getBoolean(columnIndex
) ); }
-            else if ( Byte.class.equals( type ) ) { retval = Byte.valueOf( getByte( columnIndex
) ); }
-            else if ( Short.class.equals( type ) ) { retval = Short.valueOf( getShort( columnIndex
) ); }
-            else if ( Integer.class.equals( type ) ) { retval = Integer.valueOf( getInt(
columnIndex ) ); }
-            else if ( Long.class.equals( type ) ) { retval = Long.valueOf( getLong( columnIndex
) ); }
-            else if ( Float.class.equals( type ) ) { retval = Float.valueOf( getFloat( columnIndex
) ); }
-            else if ( Double.class.equals( type ) ) { retval = Double.valueOf( getDouble(
columnIndex ) ); }
-            else if ( Date.class.equals( type ) ) { retval = getDate( columnIndex ); }
-            else if ( Time.class.equals( type ) ) { retval = getTime( columnIndex ); }
-            else if ( Timestamp.class.equals( type ) ) { retval = getTimestamp( columnIndex
); }
-            else if ( Blob.class.equals( type ) ) { retval = getBlob( columnIndex ); }
-            else if ( Clob.class.equals( type ) ) { retval = getClob( columnIndex ); }
-            else if ( type.isArray() && type.getComponentType().equals( byte.class
) ) { retval = getBytes( columnIndex ); }
-            else
-            {
-                retval = type.cast( getObject( columnIndex ) );
-            }
+        if ( String.class.equals( type ) ) { retval = getString( columnIndex ); }
+        else if ( BigDecimal.class.equals( type ) ) { retval = getBigDecimal( columnIndex
); }
+        else if ( Boolean.class.equals( type ) ) { retval = Boolean.valueOf( getBoolean(columnIndex
) ); }
+        else if ( Byte.class.equals( type ) ) { retval = Byte.valueOf( getByte( columnIndex
) ); }
+        else if ( Short.class.equals( type ) ) { retval = Short.valueOf( getShort( columnIndex
) ); }
+        else if ( Integer.class.equals( type ) ) { retval = Integer.valueOf( getInt( columnIndex
) ); }
+        else if ( Long.class.equals( type ) ) { retval = Long.valueOf( getLong( columnIndex
) ); }
+        else if ( Float.class.equals( type ) ) { retval = Float.valueOf( getFloat( columnIndex
) ); }
+        else if ( Double.class.equals( type ) ) { retval = Double.valueOf( getDouble( columnIndex
) ); }
+        else if ( Date.class.equals( type ) ) { retval = getDate( columnIndex ); }
+        else if ( Time.class.equals( type ) ) { retval = getTime( columnIndex ); }
+        else if ( Timestamp.class.equals( type ) ) { retval = getTimestamp( columnIndex );
}
+        else if ( Blob.class.equals( type ) ) { retval = getBlob( columnIndex ); }
+        else if ( Clob.class.equals( type ) ) { retval = getClob( columnIndex ); }
+        else if ( type.isArray() && type.getComponentType().equals( byte.class )
) { retval = getBytes( columnIndex ); }
+        else { retval = getObject( columnIndex ); }
 
-            if ( wasNull() ) { retval = null; }
+        if ( wasNull() ) { retval = null; }
 
-            return type.cast( retval );
-        }
-        catch (ClassCastException e) {}
+        if ( (retval == null) || (type.isInstance( retval )) ) { return type.cast( retval
); }
         
         throw mismatchException( type.getName(), columnIndex );
     }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement40.java?rev=1058554&r1=1058553&r2=1058554&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement40.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement40.java
Thu Jan 13 13:44:13 2011
@@ -344,34 +344,28 @@ public class EmbedCallableStatement40 ex
             throw mismatchException( "NULL", parameterIndex );
         }
 
-        try {
-            Object   retval;
+        Object   retval;
             
-            if ( String.class.equals( type ) ) { retval = getString( parameterIndex ); }
-            else if ( BigDecimal.class.equals( type ) ) { retval = getBigDecimal( parameterIndex
); }
-            else if ( Boolean.class.equals( type ) ) { retval = Boolean.valueOf( getBoolean(parameterIndex
) ); }
-            else if ( Byte.class.equals( type ) ) { retval = Byte.valueOf( getByte( parameterIndex
) ); }
-            else if ( Short.class.equals( type ) ) { retval = Short.valueOf( getShort( parameterIndex
) ); }
-            else if ( Integer.class.equals( type ) ) { retval = Integer.valueOf( getInt(
parameterIndex ) ); }
-            else if ( Long.class.equals( type ) ) { retval = Long.valueOf( getLong( parameterIndex
) ); }
-            else if ( Float.class.equals( type ) ) { retval = Float.valueOf( getFloat( parameterIndex
) ); }
-            else if ( Double.class.equals( type ) ) { retval = Double.valueOf( getDouble(
parameterIndex ) ); }
-            else if ( Date.class.equals( type ) ) { retval = getDate( parameterIndex ); }
-            else if ( Time.class.equals( type ) ) { retval = getTime( parameterIndex ); }
-            else if ( Timestamp.class.equals( type ) ) { retval = getTimestamp( parameterIndex
); }
-            else if ( Blob.class.equals( type ) ) { retval = getBlob( parameterIndex ); }
-            else if ( Clob.class.equals( type ) ) { retval = getClob( parameterIndex ); }
-            else if ( type.isArray() && type.getComponentType().equals( byte.class
) ) { retval = getBytes( parameterIndex ); }
-            else
-            {
-                retval = type.cast( getObject( parameterIndex ) );
-            }
+        if ( String.class.equals( type ) ) { retval = getString( parameterIndex ); }
+        else if ( BigDecimal.class.equals( type ) ) { retval = getBigDecimal( parameterIndex
); }
+        else if ( Boolean.class.equals( type ) ) { retval = Boolean.valueOf( getBoolean(parameterIndex
) ); }
+        else if ( Byte.class.equals( type ) ) { retval = Byte.valueOf( getByte( parameterIndex
) ); }
+        else if ( Short.class.equals( type ) ) { retval = Short.valueOf( getShort( parameterIndex
) ); }
+        else if ( Integer.class.equals( type ) ) { retval = Integer.valueOf( getInt( parameterIndex
) ); }
+        else if ( Long.class.equals( type ) ) { retval = Long.valueOf( getLong( parameterIndex
) ); }
+        else if ( Float.class.equals( type ) ) { retval = Float.valueOf( getFloat( parameterIndex
) ); }
+        else if ( Double.class.equals( type ) ) { retval = Double.valueOf( getDouble( parameterIndex
) ); }
+        else if ( Date.class.equals( type ) ) { retval = getDate( parameterIndex ); }
+        else if ( Time.class.equals( type ) ) { retval = getTime( parameterIndex ); }
+        else if ( Timestamp.class.equals( type ) ) { retval = getTimestamp( parameterIndex
); }
+        else if ( Blob.class.equals( type ) ) { retval = getBlob( parameterIndex ); }
+        else if ( Clob.class.equals( type ) ) { retval = getClob( parameterIndex ); }
+        else if ( type.isArray() && type.getComponentType().equals( byte.class )
) { retval = getBytes( parameterIndex ); }
+        else { retval = getObject( parameterIndex ); }
 
-            if ( wasNull() ) { retval = null; }
+        if ( wasNull() ) { retval = null; }
 
-            return type.cast( retval );
-        }
-        catch (ClassCastException e) {}
+        if ( (retval == null) || (type.isInstance( retval )) ) { return type.cast( retval
); }
         
         throw mismatchException( type.getName(), parameterIndex );
     }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet40.java?rev=1058554&r1=1058553&r2=1058554&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet40.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet40.java Thu Jan
13 13:44:13 2011
@@ -260,34 +260,28 @@ public class EmbedResultSet40 extends or
             throw mismatchException( "NULL", columnIndex );
         }
 
-        try {
-            Object   retval;
+        Object   retval;
             
-            if ( String.class.equals( type ) ) { retval = getString( columnIndex ); }
-            else if ( BigDecimal.class.equals( type ) ) { retval = getBigDecimal( columnIndex
); }
-            else if ( Boolean.class.equals( type ) ) { retval = Boolean.valueOf( getBoolean(columnIndex
) ); }
-            else if ( Byte.class.equals( type ) ) { retval = Byte.valueOf( getByte( columnIndex
) ); }
-            else if ( Short.class.equals( type ) ) { retval = Short.valueOf( getShort( columnIndex
) ); }
-            else if ( Integer.class.equals( type ) ) { retval = Integer.valueOf( getInt(
columnIndex ) ); }
-            else if ( Long.class.equals( type ) ) { retval = Long.valueOf( getLong( columnIndex
) ); }
-            else if ( Float.class.equals( type ) ) { retval = Float.valueOf( getFloat( columnIndex
) ); }
-            else if ( Double.class.equals( type ) ) { retval = Double.valueOf( getDouble(
columnIndex ) ); }
-            else if ( Date.class.equals( type ) ) { retval = getDate( columnIndex ); }
-            else if ( Time.class.equals( type ) ) { retval = getTime( columnIndex ); }
-            else if ( Timestamp.class.equals( type ) ) { retval = getTimestamp( columnIndex
); }
-            else if ( Blob.class.equals( type ) ) { retval = getBlob( columnIndex ); }
-            else if ( Clob.class.equals( type ) ) { retval = getClob( columnIndex ); }
-            else if ( type.isArray() && type.getComponentType().equals( byte.class
) ) { retval = getBytes( columnIndex ); }
-            else
-            {
-                retval = type.cast( getObject( columnIndex ) );
-            }
+        if ( String.class.equals( type ) ) { retval = getString( columnIndex ); }
+        else if ( BigDecimal.class.equals( type ) ) { retval = getBigDecimal( columnIndex
); }
+        else if ( Boolean.class.equals( type ) ) { retval = Boolean.valueOf( getBoolean(columnIndex
) ); }
+        else if ( Byte.class.equals( type ) ) { retval = Byte.valueOf( getByte( columnIndex
) ); }
+        else if ( Short.class.equals( type ) ) { retval = Short.valueOf( getShort( columnIndex
) ); }
+        else if ( Integer.class.equals( type ) ) { retval = Integer.valueOf( getInt( columnIndex
) ); }
+        else if ( Long.class.equals( type ) ) { retval = Long.valueOf( getLong( columnIndex
) ); }
+        else if ( Float.class.equals( type ) ) { retval = Float.valueOf( getFloat( columnIndex
) ); }
+        else if ( Double.class.equals( type ) ) { retval = Double.valueOf( getDouble( columnIndex
) ); }
+        else if ( Date.class.equals( type ) ) { retval = getDate( columnIndex ); }
+        else if ( Time.class.equals( type ) ) { retval = getTime( columnIndex ); }
+        else if ( Timestamp.class.equals( type ) ) { retval = getTimestamp( columnIndex );
}
+        else if ( Blob.class.equals( type ) ) { retval = getBlob( columnIndex ); }
+        else if ( Clob.class.equals( type ) ) { retval = getClob( columnIndex ); }
+        else if ( type.isArray() && type.getComponentType().equals( byte.class )
) { retval = getBytes( columnIndex ); }
+        else { retval = getObject( columnIndex ); }
 
-            if ( wasNull() ) { retval = null; }
+        if ( wasNull() ) { retval = null; }
 
-            return type.cast( retval );
-        }
-        catch (ClassCastException e) {}
+        if ( (retval == null) || (type.isInstance( retval )) ) { return type.cast( retval
); }
         
         throw mismatchException( type.getName(), columnIndex );
     }



Mime
View raw message