You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ka...@apache.org on 2013/05/22 08:13:15 UTC

svn commit: r1485076 - /db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/

Author: kahatlen
Date: Wed May 22 06:13:15 2013
New Revision: 1485076

URL: http://svn.apache.org/r1485076
Log:
DERBY-5840: Clean up compiler warnings introduced by using Java 5 language features

Make DataValueDescriptor.setBigDecimal() take a BigDecimal instead of
a Number. The argument is always null or a BigDecimal instance, but
its declared type had to be Number in order to compile on CDC, which
is no longer supported.

By making the declared type BigDecimal, we avoid an unchecked cast to
Comparable in NumberDataType's implementation of the method.

Also remove the classes that contain the CDC-specific implementation
of the DECIMAL data type.

Removed:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/BigIntegerDecimal.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/BinaryDecimal.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/CDCDataValueFactory.java
Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataType.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueDescriptor.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/NumberDataType.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBoolean.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLChar.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLClob.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDecimal.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDouble.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLReal.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/UserType.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataType.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataType.java?rev=1485076&r1=1485075&r2=1485076&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataType.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataType.java Wed May 22 06:13:15 2013
@@ -28,6 +28,7 @@ import org.apache.derby.iapi.services.sa
 
 import java.io.InputStream;
 import java.io.IOException;
+import java.math.BigDecimal;
 import java.sql.Blob;
 import java.sql.Clob;
 import java.sql.Date;
@@ -525,7 +526,7 @@ public abstract class DataType
 	/**
 		Only to be called when the application sets a value using BigDecimal
 	*/
-	public void setBigDecimal(Number bigDecimal) throws StandardException
+	public void setBigDecimal(BigDecimal bigDecimal) throws StandardException
 	{
 		throwLangSetMismatch("java.math.BigDecimal");
 	}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueDescriptor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueDescriptor.java?rev=1485076&r1=1485075&r2=1485076&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueDescriptor.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueDescriptor.java Wed May 22 06:13:15 2013
@@ -24,11 +24,11 @@ package org.apache.derby.iapi.types;
 import org.apache.derby.iapi.services.io.ArrayInputStream;
 
 import org.apache.derby.iapi.error.StandardException;
-import org.apache.derby.iapi.types.Orderable;
 import org.apache.derby.iapi.services.io.Storable;
 
 import java.io.InputStream;
 import java.io.IOException;
+import java.math.BigDecimal;
 import java.sql.Blob;
 import java.sql.Clob;
 import java.sql.Date;
@@ -489,13 +489,10 @@ public interface DataValueDescriptor ext
 		This is to support the PreparedStatement.setBigDecimal method and
 		similar JDBC methods that allow an application to pass in a BigDecimal
 		to any SQL type.
-		Parameter is declared as java.lang.Number to allow compilation
-		under J2ME/CDC/Foundation. This method will not be called in
-		any environment that does not support java.math.BigDecimal.
 
 		@param bigDecimal required to be a BigDecimal or null.
 	 */
-	public void setBigDecimal(Number bigDecimal) throws StandardException;
+	public void setBigDecimal(BigDecimal bigDecimal) throws StandardException;
 
 	/**
 	 * Set the value of this DataValueDescriptor.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/NumberDataType.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/NumberDataType.java?rev=1485076&r1=1485075&r2=1485076&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/NumberDataType.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/NumberDataType.java Wed May 22 06:13:15 2013
@@ -26,7 +26,6 @@ import java.math.BigDecimal;
 import org.apache.derby.iapi.error.StandardException;
 import org.apache.derby.iapi.services.context.ContextService;
 import org.apache.derby.iapi.services.sanity.SanityManager;
-import org.apache.derby.iapi.services.io.Storable;
 import org.apache.derby.iapi.reference.SQLState;
 import org.apache.derby.iapi.reference.Limits;
 import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
@@ -418,19 +417,15 @@ public abstract class NumberDataType ext
 		setValue for integral exact numerics. Converts the BigDecimal
 		to a long to preserve precision
 	*/
-    @SuppressWarnings("unchecked")
-	public void setBigDecimal(Number bigDecimal) throws StandardException
+	public void setBigDecimal(BigDecimal bigDecimal) throws StandardException
 	{
 		if (objectNull(bigDecimal))
 			return;
 
-		Comparable  bdc = (Comparable) bigDecimal;
-
-
 		// See comment in SQLDecimal.getLong()
 
-		if (   (bdc.compareTo(NumberDataType.MINLONG_MINUS_ONE) == 1)
-			&& (bdc.compareTo(NumberDataType.MAXLONG_PLUS_ONE) == -1)) {
+		if (   (bigDecimal.compareTo(NumberDataType.MINLONG_MINUS_ONE) == 1)
+			&& (bigDecimal.compareTo(NumberDataType.MAXLONG_PLUS_ONE) == -1)) {
 
 			setValue(bigDecimal.longValue());
 		} else {

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBoolean.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBoolean.java?rev=1485076&r1=1485075&r2=1485076&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBoolean.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBoolean.java Wed May 22 06:13:15 2013
@@ -35,6 +35,7 @@ import org.apache.derby.iapi.util.String
 import java.io.ObjectOutput;
 import java.io.ObjectInput;
 import java.io.IOException;
+import java.math.BigDecimal;
 
 import java.sql.ResultSet;
 import java.sql.PreparedStatement;
@@ -482,7 +483,7 @@ public final class SQLBoolean
 
 	}
 
-	public void setBigDecimal(Number bigDecimal) throws StandardException
+	public void setBigDecimal(BigDecimal bigDecimal) throws StandardException
 	{
 		if (SanityManager.DEBUG)
 			SanityManager.ASSERT( ! immutable,

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLChar.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLChar.java?rev=1485076&r1=1485075&r2=1485076&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLChar.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLChar.java Wed May 22 06:13:15 2013
@@ -55,6 +55,7 @@ import java.io.IOException;
 import java.io.UTFDataFormatException;
 import java.io.EOFException;
 import java.io.Reader;
+import java.math.BigDecimal;
 import java.sql.Clob;
 import java.sql.DataTruncation;
 import java.sql.Date;
@@ -1581,7 +1582,7 @@ readingLoop:
         Only to be called when an application through JDBC is setting a
         SQLChar to a java.math.BigDecimal.
     */
-    public void setBigDecimal(Number bigDecimal)  throws StandardException
+    public void setBigDecimal(BigDecimal bigDecimal)  throws StandardException
     {
         if (bigDecimal == null)
             setToNull();

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLClob.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLClob.java?rev=1485076&r1=1485075&r2=1485076&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLClob.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLClob.java Wed May 22 06:13:15 2013
@@ -41,6 +41,7 @@ import java.io.InputStream;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.io.PushbackInputStream;
+import java.math.BigDecimal;
 import java.sql.Clob;
 import java.sql.Date;
 import java.sql.SQLException;
@@ -543,7 +544,7 @@ public class SQLClob
 		throwLangSetMismatch("java.sql.Date");
 	}
 	
-	public void setBigDecimal(Number bigDecimal) throws StandardException
+	public void setBigDecimal(BigDecimal bigDecimal) throws StandardException
 	{
 		throwLangSetMismatch("java.math.BigDecimal");
 	}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDecimal.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDecimal.java?rev=1485076&r1=1485075&r2=1485076&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDecimal.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDecimal.java Wed May 22 06:13:15 2013
@@ -640,9 +640,9 @@ public final class SQLDecimal extends Nu
 		Only to be called when the application sets a value using BigDecimal
 		through setBigDecimal calls.
 	*/
-	public void setBigDecimal(Number theValue) throws StandardException
+	public void setBigDecimal(BigDecimal theValue) throws StandardException
 	{
-		setCoreValue((BigDecimal) theValue);
+		setCoreValue(theValue);
 	}
 
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDouble.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDouble.java?rev=1485076&r1=1485075&r2=1485076&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDouble.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDouble.java Wed May 22 06:13:15 2013
@@ -435,7 +435,7 @@ public final class SQLDouble extends Num
 	/**
 		Called for an application setting this value using a BigDecimal 
 	*/
-	public  void setBigDecimal(Number bigDecimal) throws StandardException
+	public  void setBigDecimal(BigDecimal bigDecimal) throws StandardException
 	{
 		if (objectNull(bigDecimal)) 
 			return;
@@ -449,8 +449,7 @@ public final class SQLDouble extends Num
         if (v == 0) {
             // We need to catch underflow here, since BigDecimal#doubleValue it
             // just returns 0 (i.e. no exception).
-            boolean isZero =
-                ((BigDecimal) bigDecimal).compareTo(BigDecimal.ZERO) == 0;
+            boolean isZero = bigDecimal.compareTo(BigDecimal.ZERO) == 0;
 
             if (!isZero) {
                 throw StandardException.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLReal.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLReal.java?rev=1485076&r1=1485075&r2=1485076&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLReal.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLReal.java Wed May 22 06:13:15 2013
@@ -392,7 +392,7 @@ public final class SQLReal
 	/**
 		Called for an application setting this value using a BigDecimal 
 	*/
-	public  void setBigDecimal(Number bigDecimal) throws StandardException
+	public  void setBigDecimal(BigDecimal bigDecimal) throws StandardException
 	{
 		if (objectNull(bigDecimal)) 
 			return;
@@ -406,8 +406,7 @@ public final class SQLReal
         if (v == 0) {
             // We need to catch underflow here, since BigDecimal#floatValue it
             // just returns 0 (i.e. no exception).
-            boolean isZero =
-                ((BigDecimal) bigDecimal).compareTo(BigDecimal.ZERO) == 0;
+            boolean isZero = bigDecimal.compareTo(BigDecimal.ZERO) == 0;
 
             if (!isZero) {
                 throw StandardException.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/UserType.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/UserType.java?rev=1485076&r1=1485075&r2=1485076&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/UserType.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/UserType.java Wed May 22 06:13:15 2013
@@ -41,6 +41,8 @@ import java.io.ObjectOutput;
 import java.io.ObjectInput;
 import java.io.IOException;
 
+import java.math.BigDecimal;
+
 import java.sql.ResultSet;
 import java.sql.SQLException;
 
@@ -479,7 +481,7 @@ public class UserType extends DataType
 	 * @see UserDataValue#setValue
 	 *
 	 */
-	public void setBigDecimal(Number theValue)
+	public void setBigDecimal(BigDecimal theValue)
 	{
 		// needed to allow serializable BigDecimal
 		setValue((Object) theValue);