db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1516715 - in /db/derby/code/trunk: ./ java/drda/org/apache/derby/impl/drda/ java/engine/org/apache/derby/ java/engine/org/apache/derby/iapi/services/io/ java/engine/org/apache/derby/iapi/types/ java/engine/org/apache/derby/impl/jdbc/ java/...
Date Fri, 23 Aug 2013 07:16:59 GMT
Author: kahatlen
Date: Fri Aug 23 07:16:58 2013
New Revision: 1516715

URL: http://svn.apache.org/r1516715
Log:
DERBY-6213: Deprecate support for Java 5 and CDC

Remove reflection code that guards access to the BigDecimal class,
which is now available on all supported platforms.

Remove J2SEDataValueFactory and move all functionality to the base
class DataValueFactoryImpl.

Remove initalization code for DECIMAL in DataValueFactory.boot(), no
longer needed since there is just a single implementation of the
DECIMAL type.

Make the parser represent DECIMAL literals as BigDecimals instead of
Strings.

Remove now unused methods in DataValueFactory for constructing
SQLDecimal values from String values.

Clean up references to CDC in comments.

Removed:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/J2SEDataValueFactory.java
Modified:
    db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/RegisteredFormatIds.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DTSClassInfo.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactory.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactoryImpl.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/NumberDataValue.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/SQLDecimal.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/TypeId.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericConstantNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericTypeCompiler.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AvgAggregator.java
    db/derby/code/trunk/java/engine/org/apache/derby/modules.properties
    db/derby/code/trunk/java/tools/org/apache/derby/iapi/tools/i18n/LocalizedResource.java
    db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/util.java
    db/derby/code/trunk/published_api_overview.html

Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java?rev=1516715&r1=1516714&r2=1516715&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
(original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
Fri Aug 23 07:16:58 2013
@@ -1193,9 +1193,6 @@ public final class NetworkServerControlI
         try {
             final Permission sp  = new SystemPermission(
                   SystemPermission.SERVER, SystemPermission.SHUTDOWN);
-            // For porting the network server to J2ME/CDC, consider calling
-            // abstract method InternalDriver.checkShutdownPrivileges(user)
-            // instead of static SecurityUtil.checkUserHasPermission().
             // SecurityUtil.checkUserHasPermission(userArg, sp);
         } catch (AccessControlException ace) {
             throw Util.generateCsSQLException(

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/RegisteredFormatIds.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/RegisteredFormatIds.java?rev=1516715&r1=1516714&r2=1516715&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/RegisteredFormatIds.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/io/RegisteredFormatIds.java
Fri Aug 23 07:16:58 2013
@@ -249,7 +249,7 @@ private static final    String[] TwoByte
         /* 197 */       null,
         /* 198 */       "org.apache.derby.catalog.types.TypesImplInstanceGetter",
         /* 199 */       "org.apache.derby.iapi.types.DTSClassInfo", //InstanceGetter,
-        /* 200 */       null, // DECIMAL - register dynamically by DataValueFactory implementation
+        /* 200 */       "org.apache.derby.iapi.types.DTSClassInfo", //InstanceGetter
         /* 201 */       null,
         /* 202 */       "org.apache.derby.iapi.types.UserType",
         /* 203 */       null,
@@ -541,13 +541,4 @@ private static final    String[] TwoByte
 
     /** Return the class name bound to an index into TwoByte */
     public  static  String  classNameForTwoByteID( int idx ) { return TwoByte[ idx ]; }
-
-    /**
-     * Set the class name associated with the DECIMAL datatype. When we
-     * stop supporting CDC, we can remove this method.
-     */
-    public  static  void    setDecimalClassName( String decimalClassName )
-    {
-        TwoByte[ StoredFormatIds.SQL_DECIMAL_ID ] = decimalClassName;
-    }
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DTSClassInfo.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DTSClassInfo.java?rev=1516715&r1=1516714&r2=1516715&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DTSClassInfo.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DTSClassInfo.java Fri Aug
23 07:16:58 2013
@@ -27,9 +27,6 @@ public class DTSClassInfo extends Format
 
         public Object getNewInstance() {
         	
-        	// Does not handle StoredFormatIds.SQL_DECIMAL_ID as different
-        	// implementations are required for different VMs.
-
         	//The format id for DVDs are handled first.  
         	Object returnObject = DataValueFactoryImpl.getNullDVDWithUCS_BASICcollation(fmtId);
         	return returnObject;

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactory.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactory.java?rev=1516715&r1=1516714&r2=1516715&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactory.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactory.java Fri
Aug 23 07:16:58 2013
@@ -21,7 +21,6 @@
 
 package org.apache.derby.iapi.types;
 
-import org.apache.derby.iapi.types.RowLocation;
 
 import org.apache.derby.iapi.error.StandardException;
 
@@ -321,37 +320,16 @@ public interface DataValueFactory
                                                         throws StandardException;
 
         /**
-         * Get a SQL DECIMAL with the given value.  The second form re-uses the
+         * Get a SQL DECIMAL with the given value. Uses the
          * previous value, if non-null, as the data holder to return.
          *
          * @exception StandardException         Thrown on error
          */
-        NumberDataValue         getDecimalDataValue(Number value) throws StandardException;
         NumberDataValue         getDecimalDataValue(Number value, NumberDataValue previous)
                                                         throws StandardException;
 
 
         /**
-         * Get a SQL DECIMAL with the given value.
-         *
-         * @exception StandardException         Thrown on error
-         */
-        NumberDataValue         getDecimalDataValue(Long value, NumberDataValue previous)
-                                                        throws StandardException;
-
-
-        /**
-         * Get a SQL DECIMAL with the given value.  The second form re-uses the
-         * previous value, if non-null, as the data holder to return.
-         *
-         * @exception StandardException         Thrown on error
-         */
-        NumberDataValue         getDecimalDataValue(String value) throws StandardException;
-        NumberDataValue         getDecimalDataValue(String value,
-                                                                                        NumberDataValue
previous)
-                                                        throws StandardException;
-
-        /**
          * Get a SQL boolean with the given value.  The second arg re-uses the
          * previous value, if non-null, as the data holder to return.
          *

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactoryImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactoryImpl.java?rev=1516715&r1=1516714&r2=1516715&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactoryImpl.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactoryImpl.java
Fri Aug 23 07:16:58 2013
@@ -21,43 +21,22 @@
 
 package org.apache.derby.iapi.types;
 
-import org.apache.derby.iapi.types.NumberDataValue;
-import org.apache.derby.iapi.types.BooleanDataValue;
-import org.apache.derby.iapi.types.BitDataValue;
-import org.apache.derby.iapi.types.DateTimeDataValue;
-import org.apache.derby.iapi.types.StringDataValue;
-import org.apache.derby.iapi.types.UserDataValue;
-import org.apache.derby.iapi.types.RefDataValue;
-
-import org.apache.derby.iapi.types.DataValueFactory;
-import org.apache.derby.iapi.types.DataValueDescriptor;
-
-import org.apache.derby.iapi.types.RowLocation;
-
 import org.apache.derby.iapi.error.StandardException;
 
 import org.apache.derby.shared.common.sanity.SanityManager;
 
 import org.apache.derby.iapi.services.i18n.LocaleFinder;
-import org.apache.derby.iapi.services.io.FormatableInstanceGetter;
-import org.apache.derby.iapi.services.io.FormatIdUtil;
-import org.apache.derby.iapi.services.io.RegisteredFormatIds;
 import org.apache.derby.iapi.services.io.StoredFormatIds;
 import org.apache.derby.iapi.services.monitor.ModuleControl;
 import org.apache.derby.iapi.services.monitor.ModuleFactory;
 import org.apache.derby.iapi.services.monitor.Monitor;
 
-import org.apache.derby.iapi.services.loader.ClassInfo;
-import org.apache.derby.iapi.services.loader.InstanceGetter;
-
 import org.apache.derby.iapi.reference.Attribute;
-import org.apache.derby.iapi.reference.Property;
 import org.apache.derby.iapi.reference.SQLState;
 
 import java.sql.Blob;
 import java.sql.Clob;
 import java.sql.Date;
-import java.sql.SQLException;
 import java.sql.Time;
 import java.sql.Timestamp;
 
@@ -71,25 +50,19 @@ import org.apache.derby.iapi.db.Database
 import org.apache.derby.iapi.services.context.ContextService;
 
 /**
- * Core implementation of DataValueFactory. Does not implement
- * methods required to generate DataValueDescriptor implementations
- * for the DECIMAL datatype. J2ME and J2SE require different implementations.
+ * Core implementation of DataValueFactory.
  *
  * @see DataValueFactory
  */
-abstract class DataValueFactoryImpl implements DataValueFactory, ModuleControl
+public final class DataValueFactoryImpl implements DataValueFactory, ModuleControl
 {
-        LocaleFinder localeFinder;
+        private LocaleFinder localeFinder;
         //BasicDatabase first boots DVF in it's boot method and then sets 
         //this databaseLocale in DVF.
     	private Locale databaseLocale;
     	//Following Collator object will be initialized using databaseLocale.  
     	private RuleBasedCollator collatorForCharacterTypes;
 
-        DataValueFactoryImpl()
-        {
-        }
-        
         /*
          ** ModuleControl methods.
          */
@@ -99,16 +72,6 @@ abstract class DataValueFactoryImpl impl
     	 */
     	public void boot(boolean create, Properties properties) throws StandardException {
     		
-    		DataValueDescriptor decimalImplementation = getNullDecimal(null);
-    		
-    		TypeId.decimalImplementation = decimalImplementation;
-    		RegisteredFormatIds.setDecimalClassName( decimalImplementation.getClass().getName()
);
-    		    		
-    		// Generate a DECIMAL value represetentation of 0
-    		decimalImplementation = decimalImplementation.getNewNull();
-    		decimalImplementation.setValue(0L);
-    		NumberDataType.ZERO_DECIMAL = decimalImplementation;    		
-
     		ModuleFactory monitor = Monitor.getMonitor();
     		//The Locale on monitor has already been set by the boot code in
     		//BasicDatabase so we can simply do a get here.
@@ -294,33 +257,14 @@ abstract class DataValueFactoryImpl impl
                 previous.setValue(value);
                 return previous;
         }
-        public final NumberDataValue getDecimalDataValue(Number value)
-			throws StandardException
-        {
-			NumberDataValue ndv = getNullDecimal((NumberDataValue) null);
-			ndv.setValue(value);
-			return ndv;
-        }
 
         public final NumberDataValue getDecimalDataValue(Number value, NumberDataValue previous)
                         throws StandardException
         {
-                if (previous == null)
-                        return getDecimalDataValue(value);
-
-                previous.setValue(value);
-                return previous;
-        }
-
-        public final NumberDataValue getDecimalDataValue(String value,
-                                                                                        
       NumberDataValue previous)
-                        throws StandardException
-        {
-                if (previous == null)
-                        return getDecimalDataValue(value);
-
-                previous.setValue(value);
-                return previous;
+            NumberDataValue retValue =
+                    (previous == null) ? getNullDecimal(null) : previous;
+            retValue.setValue(value);
+            return retValue;
         }
 
         public BooleanDataValue getDataValue(boolean value,
@@ -708,6 +652,16 @@ abstract class DataValueFactoryImpl impl
                 }
         }
 
+        public final NumberDataValue getNullDecimal(NumberDataValue dataValue)
+        {
+            if (dataValue == null) {
+                return new SQLDecimal();
+            }
+
+            dataValue.setToNull();
+            return dataValue;
+        }
+
         public BooleanDataValue getNullBoolean(BooleanDataValue dataValue)
         {
                 if (dataValue == null)
@@ -1111,28 +1065,26 @@ abstract class DataValueFactoryImpl impl
     public DataValueDescriptor getNull(int formatId, int collationType) 
     throws StandardException {
 
-    	//For StoredFormatIds.SQL_DECIMAL_ID, different implementations are 
-    	//required for different VMs. getNullDecimal method is not static and 
-    	//hence can't be called in the static getNullDVDWithUCS_BASICcollation
-    	//method in this class. That is why StoredFormatIds.SQL_DECIMAL_ID is 
-    	//getting handled here.
-    	if (formatId == StoredFormatIds.SQL_DECIMAL_ID)
-    		return getNullDecimal(null);
-		else {
-			DataValueDescriptor returnDVD = 
-				DataValueFactoryImpl.getNullDVDWithUCS_BASICcollation(formatId);
-			//If we are dealing with default collation, then we have got the
-			//right DVD already. Just return it.
-			if (collationType == StringDataValue.COLLATION_TYPE_UCS_BASIC)
-				return returnDVD;			
-			//If we are dealing with territory based collation and returnDVD is 
-			//of type StringDataValue, then we need to return a StringDataValue   
-			//with territory based collation.
-			if (returnDVD instanceof StringDataValue) 
-				return ((StringDataValue)returnDVD).getValue(getCharacterCollator(collationType));
-			else
-				return returnDVD;			
-		}
+        DataValueDescriptor returnDVD =
+            DataValueFactoryImpl.getNullDVDWithUCS_BASICcollation(formatId);
+
+        // If we are dealing with default collation, then we have got the
+        // right DVD already. Just return it.
+        if (collationType == StringDataValue.COLLATION_TYPE_UCS_BASIC) {
+            return returnDVD;
+        }
+
+        // If we are dealing with territory based collation and returnDVD is
+        // of type StringDataValue, then we need to return a StringDataValue
+        // with territory based collation.
+        if (returnDVD instanceof StringDataValue) {
+            return ((StringDataValue) returnDVD)
+                    .getValue(getCharacterCollator(collationType));
+        }
+
+        // Otherwise, it's not a StringDataValue, and it can be returned
+        // as it is.
+        return returnDVD;
     }
     
     /**
@@ -1140,16 +1092,10 @@ abstract class DataValueFactoryImpl impl
      * into account the collation that should be associated with collation
      * sensitive DVDs, which are all the character type DVDs. Such DVDs 
      * returned from this method have default UCS_BASIC collation associated
-     * with them. If collation associated should be terriotry based, then that
+     * with them. If collation associated should be territory based, then that
      * needs to be handled by the caller of this method. An example of such 
      * code in the caller can be seen in DataValueFactory.getNull method.
      * 
-     * Another thing to note is this method does not deal with format id
-     * associated with decimal. This is because different implementation are
-     * required for different VMs. This is again something that needs to be
-     * handled by the caller. An example of such code in the caller can be 
-     * seen in DataValueFactory.getNull method.
-     *  
      * @param formatId Return a DVD based on the format id
      * @return DataValueDescriptor with default collation of UCS_BASIC 
      */
@@ -1162,6 +1108,7 @@ abstract class DataValueFactoryImpl impl
         case StoredFormatIds.SQL_BOOLEAN_ID: return new SQLBoolean();
         case StoredFormatIds.SQL_CHAR_ID: return new SQLChar();
         case StoredFormatIds.SQL_DATE_ID: return new SQLDate();
+        case StoredFormatIds.SQL_DECIMAL_ID: return new SQLDecimal();
         case StoredFormatIds.SQL_DOUBLE_ID: return new SQLDouble();
         case StoredFormatIds.SQL_INTEGER_ID: return new SQLInteger();
         case StoredFormatIds.SQL_LONGINT_ID: return new SQLLongint();

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=1516715&r1=1516714&r2=1516715&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 Fri Aug
23 07:16:58 2013
@@ -42,16 +42,10 @@ import org.apache.derby.iapi.sql.diction
 public abstract class NumberDataType extends DataType 
 									 implements NumberDataValue
 {
-	/**
-	 * Set by the booting DataValueFactory implementation.
-	 */
-	static DataValueDescriptor ZERO_DECIMAL;
-	
-	static final BigDecimal ZERO = BigDecimal.valueOf(0L);
-	static final BigDecimal ONE = BigDecimal.valueOf(1L);
-	static final BigDecimal MAXLONG_PLUS_ONE = BigDecimal.valueOf(Long.MAX_VALUE).add(ONE);
-	static final BigDecimal MINLONG_MINUS_ONE = BigDecimal.valueOf(Long.MIN_VALUE).subtract(ONE);
-
+    static final BigDecimal MAXLONG_PLUS_ONE =
+            BigDecimal.valueOf(Long.MAX_VALUE).add(BigDecimal.ONE);
+    static final BigDecimal MINLONG_MINUS_ONE =
+            BigDecimal.valueOf(Long.MIN_VALUE).subtract(BigDecimal.ONE);
 
     /**
      * Numbers check for isNegative first and negate it if negative.
@@ -441,26 +435,7 @@ public abstract class NumberDataType ext
 	{
 		return java.sql.Types.BIGINT;
 	}
-	/**
-		Return the precision of this specific DECIMAL value.
-		If the value does not represent a SQL DECIMAL then
-		the return is undefined.
-	*/
-	public int getDecimalValuePrecision()
-	{
-		return -1;
-	}
 
-	/**
-		Return the scale of this specific DECIMAL value.
-		If the value does not represent a SQL DECIMAL then
-		the return is undefined.
-	*/
-	public int getDecimalValueScale()
- 	{
-		return -1;
-	}
-   
 	protected final boolean objectNull(Object o) 
 	{
 		if (o == null) 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/NumberDataValue.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/NumberDataValue.java?rev=1516715&r1=1516714&r2=1516715&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/NumberDataValue.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/NumberDataValue.java Fri Aug
23 07:16:58 2013
@@ -193,24 +193,6 @@ public interface NumberDataValue extends
 	 *
 	 */
 	public void setValue(Number theValue) throws StandardException;
-
-	/**
-		Return the SQL precision of this specific DECIMAL value.
-		This does not match the return from BigDecimal.precision()
-		added in J2SE 5.0, which represents the precision of the unscaled value.
-		If the value does not represent a SQL DECIMAL then
-		the return is undefined.
-	*/
-	public int getDecimalValuePrecision();
-
-	/**
-		Return the SQL scale of this specific DECIMAL value.
-		This does not match the return from BigDecimal.scale()
-		since in J2SE 5.0 onwards that can return negative scales.
-		If the value does not represent a SQL DECIMAL then
-		the return is undefined.
-	*/
-	public int getDecimalValueScale();
 }
 
 

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=1516715&r1=1516714&r2=1516715&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 Fri Aug 23
07:16:58 2013
@@ -495,9 +495,7 @@ public final class SQLBoolean
 		}
 		else
 		{
-			DataValueDescriptor tempDecimal = NumberDataType.ZERO_DECIMAL.getNewNull();
-			tempDecimal.setBigDecimal(bigDecimal);
-			value = NumberDataType.ZERO_DECIMAL.compare(tempDecimal) != 0;
+            value = BigDecimal.ZERO.compareTo(bigDecimal) != 0;
 			isnull = false;
 		}
 

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=1516715&r1=1516714&r2=1516715&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 Fri Aug 23
07:16:58 2013
@@ -298,7 +298,7 @@ public final class SQLDecimal extends Nu
 		if (localValue == null)
 			return false;
 
-		return localValue.compareTo(ZERO) != 0;
+		return localValue.compareTo(BigDecimal.ZERO) != 0;
 	}
 
 	public String	getString()
@@ -673,7 +673,7 @@ public final class SQLDecimal extends Nu
 	 */
 	public void setValue(boolean theValue)
 	{
-		setCoreValue(theValue ? ONE : ZERO);
+		setCoreValue(theValue ? BigDecimal.ONE : BigDecimal.ZERO);
 	}
 
 	/*
@@ -885,7 +885,7 @@ public final class SQLDecimal extends Nu
 
 		BigDecimal divisorBigDecimal = SQLDecimal.getBigDecimal(divisor);
 
-		if (divisorBigDecimal.compareTo(ZERO) == 0)
+		if (divisorBigDecimal.compareTo(BigDecimal.ZERO) == 0)
 		{
 			throw  StandardException.newException(SQLState.LANG_DIVIDE_BY_ZERO);
 		}
@@ -948,7 +948,7 @@ public final class SQLDecimal extends Nu
 
     protected boolean isNegative()
     {
-        return !isNull() && (getBigDecimal().compareTo(ZERO) == -1);
+        return !isNull() && (getBigDecimal().compareTo(BigDecimal.ZERO) == -1);
     }
     
 	/*
@@ -1117,7 +1117,7 @@ public final class SQLDecimal extends Nu
          * if ONE > abs(value) then the number of whole digits is 0
          */
         decimalValue = decimalValue.abs();
-        if (ONE.compareTo(decimalValue) == 1)
+        if (BigDecimal.ONE.compareTo(decimalValue) == 1)
         {
             return 0;
         }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/TypeId.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/TypeId.java?rev=1516715&r1=1516714&r2=1516715&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/TypeId.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/TypeId.java Fri Aug 23 07:16:58
2013
@@ -335,12 +335,6 @@ public final class TypeId
         XML_ID,
     };
 
-        /**
-         * Implementation of DECIMAL datatype for generating holders through getNull.
-         * Set by the booted DataValueFactory implementation.
-         */
-        static DataValueDescriptor		decimalImplementation;
-
         /*
         ** Static methods to obtain TypeIds
         */
@@ -1427,7 +1421,7 @@ public final class TypeId
 
                         // Implementation of DECIMAL can change.
                         case StoredFormatIds.DECIMAL_TYPE_ID:
-                        	return decimalImplementation.getNewNull();
+                            return new SQLDecimal();
 
                         case StoredFormatIds.DOUBLE_TYPE_ID:
                                 return new SQLDouble();

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement.java?rev=1516715&r1=1516714&r2=1516715&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement.java
Fri Aug 23 07:16:58 2013
@@ -363,10 +363,6 @@ public class EmbedCallableStatement exte
 
 	}
 
-	/*
-	** Methods using BigDecimal, moved back into EmbedCallableStatement
-    ** because our small device implementation now requires CDC/FP 1.1.
-	*/
     /**
      * JDBC 2.0
      *

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java?rev=1516715&r1=1516714&r2=1516715&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java
Fri Aug 23 07:16:58 2013
@@ -455,11 +455,6 @@ public class EmbedPreparedStatement exte
 
 	}
 
-	/*
-	** Methods using BigDecimal, moved back into EmbedPreparedStatement
-	** since our small device implementation now requires CDC/FP 1.1, which
-    ** supports BigDecimal.
-	*/
 	/**
      * Set a parameter to a java.lang.BigDecimal value.  
      * The driver converts this to a SQL NUMERIC value when

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericConstantNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericConstantNode.java?rev=1516715&r1=1516714&r2=1516715&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericConstantNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericConstantNode.java
Fri Aug 23 07:16:58 2013
@@ -21,6 +21,7 @@
 
 package	org.apache.derby.impl.sql.compile;
 
+import java.math.BigDecimal;
 import java.sql.Types;
 import org.apache.derby.iapi.error.StandardException;
 import org.apache.derby.iapi.services.compiler.MethodBuilder;
@@ -28,6 +29,7 @@ import org.apache.derby.iapi.services.co
 import org.apache.derby.shared.common.sanity.SanityManager;
 import org.apache.derby.iapi.types.DataTypeUtilities;
 import org.apache.derby.iapi.types.NumberDataValue;
+import org.apache.derby.iapi.types.SQLDecimal;
 import org.apache.derby.iapi.types.SQLDouble;
 import org.apache.derby.iapi.types.SQLInteger;
 import org.apache.derby.iapi.types.SQLLongint;
@@ -77,7 +79,7 @@ public final class NumericConstantNode e
      * @param cm context manager
      * @throws StandardException
      */
-    NumericConstantNode(TypeId t, Object value, ContextManager cm)
+    NumericConstantNode(TypeId t, Number value, ContextManager cm)
             throws StandardException {
         super(cm);
         kind = getKind(t);
@@ -89,7 +91,7 @@ public final class NumericConstantNode e
         setValue(t, value);
     }
 
-    private int getPrecision(TypeId t, Object val) throws StandardException {
+    private int getPrecision(TypeId t, Number val) throws StandardException {
 
         switch (t.getJDBCTypeId()) {
 
@@ -103,8 +105,7 @@ public final class NumericConstantNode e
             return TypeId.LONGINT_PRECISION;
         case Types.DECIMAL:
             if (val != null) {
-                NumberDataValue constantDecimal =
-                    getDataValueFactory().getDecimalDataValue((String)val);
+                SQLDecimal constantDecimal = new SQLDecimal((BigDecimal) val);
                 return constantDecimal.getDecimalValuePrecision();
             } else {
                 return TypeId.DECIMAL_PRECISION;
@@ -133,8 +134,7 @@ public final class NumericConstantNode e
             return TypeId.LONGINT_SCALE;
         case Types.DECIMAL:
             if (val != null) {
-                NumberDataValue constantDecimal =
-                    getDataValueFactory().getDecimalDataValue((String)val);
+                SQLDecimal constantDecimal = new SQLDecimal((BigDecimal) val);
                 return constantDecimal.getDecimalValueScale();
             } else {
                 return TypeId.DECIMAL_SCALE;
@@ -163,8 +163,7 @@ public final class NumericConstantNode e
            return val != null ? TypeId.LONGINT_MAXWIDTH: 0;
        case Types.DECIMAL:
             if (val != null) {
-               NumberDataValue constantDecimal =
-                        getDataValueFactory().getDecimalDataValue((String) val);
+               SQLDecimal constantDecimal = new SQLDecimal((BigDecimal) val);
                int precision = constantDecimal.getDecimalValuePrecision();
                int scal = constantDecimal.getDecimalValueScale();
                /* be consistent with our convention on maxwidth, see also
@@ -210,7 +209,7 @@ public final class NumericConstantNode e
        }
     }
 
-    private void setValue(TypeId t, Object value ) throws StandardException {
+    private void setValue(TypeId t, Number value ) throws StandardException {
        switch (t.getJDBCTypeId()) {
        case Types.TINYINT:
            setValue(new SQLTinyint((Byte)value));
@@ -225,9 +224,7 @@ public final class NumericConstantNode e
            setValue(new SQLLongint((Long)value));
             break;
        case Types.DECIMAL:
-            NumberDataValue constantDecimal =
-                    getDataValueFactory().getDecimalDataValue((String)value);
-            setValue(constantDecimal);
+           setValue(new SQLDecimal((BigDecimal)value));
             break;
        case Types.DOUBLE:
            setValue(new SQLDouble((Double)value));

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericTypeCompiler.java?rev=1516715&r1=1516714&r2=1516715&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericTypeCompiler.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericTypeCompiler.java
Fri Aug 23 07:16:58 2013
@@ -317,10 +317,12 @@ public final class NumericTypeCompiler e
 		return numberStorable(getTypeId(), otherType, cf);
 	}
 
-	/**
-		Return the method name to get a Derby DataValueDescriptor
-		object of the correct type. This implementation returns "getDataValue".
-	*/
+    /**
+     * Return the method name to get a Derby DataValueDescriptor object of the
+     * correct type. This implementation returns {@code "getDataValue"}, unless
+     * the type is {@code DECIMAL}, in which case {@code "getDecimalDataValue"}
+     * is returned.
+     */
     @Override
 	String dataValueMethodName()
 	{
@@ -522,7 +524,9 @@ public final class NumericTypeCompiler e
 	{
         if (getTypeId().isDecimalTypeId())
 		{
-			// cast the value to a Number (from BigDecimal) for method resolution
+            // Cast the value to a Number for method resolution. It is most
+            // frequently a BigDecimal, but it could also be an instance of
+            // other subclasses of Number, such as Long.
 			mb.upCast("java.lang.Number");
 		}
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj?rev=1516715&r1=1516714&r2=1516715&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj Fri Aug
23 07:16:58 2013
@@ -39,6 +39,7 @@ PARSER_BEGIN(SQLParser)
 
 package org.apache.derby.impl.sql.compile;
 
+import java.math.BigDecimal;
 import java.sql.ParameterMetaData;
 import java.sql.Types;
 import java.util.ArrayList;
@@ -541,7 +542,7 @@ public class SQLParser
 		}
 
        return new NumericConstantNode(
-           TypeId.getBuiltInTypeId(Types.DECIMAL), num, cm);
+           TypeId.getBuiltInTypeId(Types.DECIMAL), new BigDecimal(num), cm);
 	}
 	/**
 	 * Determine whether the current token represents one of

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AvgAggregator.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AvgAggregator.java?rev=1516715&r1=1516714&r2=1516715&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AvgAggregator.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AvgAggregator.java Fri
Aug 23 07:16:58 2013
@@ -21,11 +21,11 @@
 
 package org.apache.derby.impl.sql.execute;
 
-import org.apache.derby.shared.common.sanity.SanityManager;
 import org.apache.derby.iapi.types.NumberDataValue;
 import org.apache.derby.iapi.error.StandardException;
 import org.apache.derby.iapi.sql.execute.ExecAggregator;
 import org.apache.derby.iapi.types.DataValueDescriptor;
+import org.apache.derby.iapi.types.SQLDecimal;
 import org.apache.derby.iapi.types.TypeId;
 
 import org.apache.derby.iapi.services.io.StoredFormatIds;
@@ -70,7 +70,7 @@ public final class AvgAggregator extends
 				scale = TypeId.DECIMAL_SCALE;
 			} else {
 				// DECIMAL
-				scale = ((NumberDataValue) addend).getDecimalValueScale();
+				scale = ((SQLDecimal) addend).getDecimalValueScale();
 				if (scale < NumberDataValue.MIN_DECIMAL_DIVIDE_SCALE)
 					scale = NumberDataValue.MIN_DECIMAL_DIVIDE_SCALE;
 			}
@@ -115,8 +115,7 @@ public final class AvgAggregator extends
 		} else if (typeName.equals(TypeId.REAL_NAME)) {
 			newValue = new org.apache.derby.iapi.types.SQLDouble();
 		} else {
-			TypeId decimalTypeId = TypeId.getBuiltInTypeId(java.sql.Types.DECIMAL);
-			newValue = decimalTypeId.getNull();
+            newValue = new SQLDecimal();
 		}
 		
 		newValue.setValue(value);

Modified: db/derby/code/trunk/java/engine/org/apache/derby/modules.properties
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/modules.properties?rev=1516715&r1=1516714&r2=1516715&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/modules.properties (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/modules.properties Fri Aug 23 07:16:58
2013
@@ -330,7 +330,7 @@ cloudscape.config.netServer.autoStart=de
 
 
 # DataValueFactory implementations
-derby.module.dvfJ2=org.apache.derby.iapi.types.J2SEDataValueFactory
+derby.module.dvfJ2=org.apache.derby.iapi.types.DataValueFactoryImpl
 derby.env.jdk.dvfJ2=2
 derby.env.classes.dvfJ2=java.math.BigDecimal,java.sql.Driver
 cloudscape.config.dvfJ2=derby

Modified: db/derby/code/trunk/java/tools/org/apache/derby/iapi/tools/i18n/LocalizedResource.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/iapi/tools/i18n/LocalizedResource.java?rev=1516715&r1=1516714&r2=1516715&view=diff
==============================================================================
--- db/derby/code/trunk/java/tools/org/apache/derby/iapi/tools/i18n/LocalizedResource.java
(original)
+++ db/derby/code/trunk/java/tools/org/apache/derby/iapi/tools/i18n/LocalizedResource.java
Fri Aug 23 07:16:58 2013
@@ -23,7 +23,6 @@ package org.apache.derby.iapi.tools.i18n
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.UnsupportedEncodingException;
-import java.lang.reflect.Method;
 
 import java.util.ResourceBundle;
 import java.util.Date;
@@ -46,26 +45,6 @@ import java.sql.Types;
 
 public final class LocalizedResource  implements java.security.PrivilegedAction<String>
{
 
-	private static final boolean SUPPORTS_BIG_DECIMAL_CALLS;
-	
-	static {
-		boolean supportsBigDecimalCalls;
-		try {
-			// This class attempts to make a call to a 
-			// ResultSet.getBigDecimal method, which may not be available.
-			// For instance, java.math.BigDecimal is not available with
-			// J2ME/CDC/Foundation 1.0 profile.
-			Class.forName("java.math.BigDecimal");
-			supportsBigDecimalCalls = true;
-			// And no methods using BigDecimal are available with JSR169 spec.
-			Method getbd = ResultSet.class.getMethod("getBigDecimal", new Class[] {int.class});
-			supportsBigDecimalCalls = true;
-		} catch (Throwable t) {
-			supportsBigDecimalCalls = false;
-		}
-		SUPPORTS_BIG_DECIMAL_CALLS = supportsBigDecimalCalls;
-	}
-	
 	private ResourceBundle res;
 	private Locale locale;
 	private String encode;
@@ -77,7 +56,6 @@ public final class LocalizedResource  im
 	private LocalizedOutput out;
 	private LocalizedInput in;
 	private boolean enableLocalized;
-	private boolean unicodeEscape;
 	private static LocalizedResource local;
 	private int dateSize;
 	private int timeSize;
@@ -318,11 +296,8 @@ public final class LocalizedResource  im
 					type == Types.DOUBLE ) {
 				return getNumberAsString(rs.getDouble(columnNumber));
 			}
-			else if (SUPPORTS_BIG_DECIMAL_CALLS && (type == Types.NUMERIC || type == Types.DECIMAL))
{
-				// BigDecimal JDBC calls are supported on this platform, but
-				// use getObject() so that the class can be compiled against
-				// the JSR-169 libraries.
-				return getNumberAsString(rs.getObject(columnNumber));
+            else if (type == Types.NUMERIC || type == Types.DECIMAL) {
+                return getNumberAsString(rs.getBigDecimal(columnNumber));
 			}
 			else if (type == Types.TIME ) {
 				return getTimeAsString(rs.getTime(columnNumber));

Modified: db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/util.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/util.java?rev=1516715&r1=1516714&r2=1516715&view=diff
==============================================================================
--- db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/util.java (original)
+++ db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/util.java Fri Aug 23 07:16:58
2013
@@ -26,7 +26,6 @@ import org.apache.derby.iapi.tools.i18n.
 
 import java.io.BufferedInputStream;
 import java.io.FileInputStream;
-import java.io.FileNotFoundException;
 import java.io.InputStream;
 import java.io.IOException;
 import java.lang.reflect.InvocationTargetException;
@@ -36,7 +35,6 @@ import java.security.PrivilegedAction;
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.SQLException;
-import java.sql.SQLWarning;
 import java.sql.Statement;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
@@ -55,23 +53,6 @@ import java.util.Locale;
  */
 public final class util implements java.security.PrivilegedAction<String> {
 	
-	private static boolean IS_AT_LEAST_JDBC2;
-	
-	{
-		boolean isAtLeastJDBC2;
-		try {
-            // Need to test to see if this is
-            // currently JDBC 2 or JSR169.
-            // Checking for BigDecimal doesn't work because
-            // BigDecimal exists in J2ME/CDC/Foundation 1.1
-            Class.forName("java.sql.Driver");
-			isAtLeastJDBC2 = true;
-		} catch (Throwable t) {
-			isAtLeastJDBC2 = false;
-		}
-		IS_AT_LEAST_JDBC2 = isAtLeastJDBC2;
-	}
-	
 	private static final Class[] DS_GET_CONN_TYPES = {"".getClass(), "".getClass()};
 	private util() {}
 
@@ -424,12 +405,12 @@ public final class util implements java.
         driverName = util.getSystemProperty("driver");
         if (driverName == null) driverName = util.getSystemProperty("ij.driver");
 	if (driverName == null || driverName.length()==0) driverName = defaultDriver;
-        if (driverName != null && IS_AT_LEAST_JDBC2) {
+        if (driverName != null) {
 	    util.loadDriver(driverName);
 	}
 
 	String jdbcProtocol = util.getSystemProperty("ij.protocol");
-	if (jdbcProtocol != null && IS_AT_LEAST_JDBC2)
+	if (jdbcProtocol != null)
 	    util.loadDriverIfKnown(jdbcProtocol);
 	
     String user = util.getSystemProperty("ij.user");
@@ -439,7 +420,7 @@ public final class util implements java.
 	databaseURL = util.getSystemProperty("database");
 	if (databaseURL == null) databaseURL = util.getSystemProperty("ij.database");
 	if (databaseURL == null || databaseURL.length()==0) databaseURL = defaultURL;
-	if (databaseURL != null && IS_AT_LEAST_JDBC2) {
+	if (databaseURL != null) {
 	    // add protocol if might help find driver.
 		// if have full URL, load driver for it
 		if (databaseURL.startsWith("jdbc:"))
@@ -617,36 +598,7 @@ AppUI.out.println("SIZE="+l);
 				
 				if (sqlType == Types.DECIMAL)
 				{
-					if (util.IS_AT_LEAST_JDBC2)
-					{
-						ps.setObject(c,rs.getObject(c),
-								 sqlType,
-								 rsmd.getScale(c));							
-					}
-					else
-					{
-						// In J2ME there is no object that represents
-						// a DECIMAL value. By default use String to
-						// pass values around, but for integral types
-						// first convert to a integral type from the DECIMAL
-						// because strings like 3.4 are not convertible to
-						// an integral type. Of course in JSR169 we have
-                        // no way to determine the parameter types,
-                        // ParameterMetaData is not supported.
-                        // So convert as string, and on a conversion error
-                        // try as a long.
-                        
-                        try {
-                            ps.setString(c, rs.getString(c));
-                        } catch (SQLException e) {
-                            // 22018 - invalid format
-                            if ("22018".equals(e.getSQLState()))
-                                ps.setLong(c, rs.getLong(c));
-                            else
-                                throw e;
-                        }						
-					}
-					
+                    ps.setObject(c, rs.getObject(c), sqlType, rsmd.getScale(c));
 				}
 				else
 				{

Modified: db/derby/code/trunk/published_api_overview.html
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/published_api_overview.html?rev=1516715&r1=1516714&r2=1516715&view=diff
==============================================================================
--- db/derby/code/trunk/published_api_overview.html (original)
+++ db/derby/code/trunk/published_api_overview.html Fri Aug 23 07:16:58 2013
@@ -19,9 +19,8 @@ Apache Derby is a pure Java, standards-b
 Derby provides an easy to use data management solution for
 software developers with zero administration for end users.
 <p>
-Derby runs on any Java SE 5 platform or higher with JDBC 3.0, 4.0, 4.1,
-and 4.2 and also supports Java ME/CDC/Foundation Profile 1.1 with JDBC
-through JSR 169. For Java 8, Derby can also run on constrained devices
+Derby runs on any Java SE 6 platform or higher with 4.0, 4.1, and 4.2.
+For Java 8, Derby can also run on constrained devices
 with a runtime as specified by OpenJDK JEP 161, i.e. Compact Profile 2
 or higher.
 </p>



Mime
View raw message