db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r154373 - in incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types: CDCDataValueFactory.java DataValueFactoryImpl.java J2SEDataValueFactory.java NumberDataType.java SQLBoolean.java SQLDecimal.java
Date Sat, 19 Feb 2005 00:50:46 GMT
Author: djd
Date: Fri Feb 18 16:50:43 2005
New Revision: 154373

URL: http://svn.apache.org/viewcvs?view=rev&rev=154373
Log:
Remove final uses of BigDecimal from classes required by JSR 169.

Added:
    incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/CDCDataValueFactory.java
  (with props)
Modified:
    incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactoryImpl.java
    incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/J2SEDataValueFactory.java
    incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/NumberDataType.java
    incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBoolean.java
    incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDecimal.java

Added: incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/CDCDataValueFactory.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/CDCDataValueFactory.java?view=auto&rev=154373
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/CDCDataValueFactory.java
(added)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/CDCDataValueFactory.java
Fri Feb 18 16:50:43 2005
@@ -0,0 +1,87 @@
+/*
+
+   Derby - Class org.apache.derby.iapi.types.CDCDataValueFactory
+
+   Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+
+package org.apache.derby.iapi.types;
+
+import java.util.Properties;
+import org.apache.derby.iapi.services.info.JVMInfo;
+import org.apache.derby.iapi.services.monitor.ModuleSupportable;
+import org.apache.derby.iapi.error.StandardException;
+
+/**
+/**
+ * DataValueFactory implementation for J2ME/CDC/Foundation.
+ * Cannot use SQLDecimal since that requires java.math.BigDecimal.
+ * 
+ * THIS IS A TEMPORARY IMPLEMENTATION THAT USES SQLDouble for DECIMAL
+ * WHICH IS NOT PRECISE. IS IT A STEP IN THE WAY TO A COMPLETE IMPLEMENTAION
+ * FOR J2ME.
+ *
+ * @see DataValueFactory
+ */
+
+public class CDCDataValueFactory extends DataValueFactoryImpl
+	implements ModuleSupportable
+{
+     /**
+	 *     Make the constructor public.
+	 *
+	 */
+	public CDCDataValueFactory() {
+	}
+	
+   	public void boot(boolean create, Properties properties) throws StandardException {
+   		System.out.println("WARNING - Experimental J2ME/CDC/Foundation/JSR 169 Derby implementation");
+   		System.out.println("WARNING - NOT FOR USE IN PRODUCTION");
+    	super.boot(create, properties);
+   	}
+	
+	/* (non-Javadoc)
+	 * @see org.apache.derby.iapi.services.monitor.ModuleSupportable#canSupport(java.util.Properties)
+	 */
+	public boolean canSupport(Properties properties) {
+		return JVMInfo.J2ME;
+	}
+	public NumberDataValue getDecimalDataValue(Long value,
+			NumberDataValue previous) throws StandardException {
+		if (previous == null)
+			previous = new SQLDouble(); // CDCDecimal();
+
+		previous.setValue(value);
+		return previous;
+	}
+
+	public NumberDataValue getDecimalDataValue(String value)
+			throws StandardException {
+		NumberDataValue ndv = new SQLDouble(); // CDCDecimal();
+
+		ndv.setValue(value);
+		return ndv;
+	}
+
+	public NumberDataValue getNullDecimal(NumberDataValue dataValue) {
+		if (dataValue == null) {
+			return new SQLDouble(); // CDCDecimal();
+		} else {
+			dataValue.setToNull();
+			return dataValue;
+		}
+	}
+}

Propchange: incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/CDCDataValueFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactoryImpl.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactoryImpl.java?view=diff&r1=154372&r2=154373
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactoryImpl.java
(original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactoryImpl.java
Fri Feb 18 16:50:43 2005
@@ -81,6 +81,14 @@
     		RegisteredFormatIds.TwoByte[StoredFormatIds.SQL_DECIMAL_ID]
     									= decimalImplementation.getClass().getName();
     		
+    		
+    		// Generate a DECIMAL value represetentation of 0
+    		decimalImplementation = decimalImplementation.getNewNull();
+    		decimalImplementation.setValue(0L);
+    		NumberDataType.ZERO_DECIMAL = decimalImplementation;
+    		
+    		
+    		
     	}
 
     	/* (non-Javadoc)

Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/J2SEDataValueFactory.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/J2SEDataValueFactory.java?view=diff&r1=154372&r2=154373
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/J2SEDataValueFactory.java
(original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/J2SEDataValueFactory.java
Fri Feb 18 16:50:43 2005
@@ -20,6 +20,8 @@
 
 package org.apache.derby.iapi.types;
 
+import java.util.Properties;
+
 import org.apache.derby.iapi.error.StandardException;
 
 /**
@@ -34,6 +36,14 @@
 	public J2SEDataValueFactory() {
 	}
 
+   	public void boot(boolean create, Properties properties) throws StandardException {
+   		
+   		NumberDataType.MINLONG_MINUS_ONE = SQLDecimal.MINLONG_MINUS_ONE;
+   		NumberDataType.MAXLONG_PLUS_ONE = SQLDecimal.MAXLONG_PLUS_ONE;
+
+    	super.boot(create, properties);
+   	}
+	
 	public NumberDataValue getDecimalDataValue(Long value,
 			NumberDataValue previous) throws StandardException {
 		if (previous == null)

Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/NumberDataType.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/NumberDataType.java?view=diff&r1=154372&r2=154373
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/NumberDataType.java
(original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/NumberDataType.java
Fri Feb 18 16:50:43 2005
@@ -43,7 +43,19 @@
 public abstract class NumberDataType extends DataType 
 									 implements NumberDataValue
 {
-
+	/**
+	 * Set by the booting DataValueFactory implementation.
+	 */
+	static DataValueDescriptor ZERO_DECIMAL;
+	
+	/**
+	 * Set by the booting DataValueFactory implementation.
+	 */
+	static Comparable MINLONG_MINUS_ONE;
+	/**
+	 * Set by the booting DataValueFactory implementation.
+	 */
+	static Comparable MAXLONG_PLUS_ONE;
 
     /**
      * Numbers check for isNegative first and negate it if negative.
@@ -386,8 +398,8 @@
 
 		// See comment in SQLDecimal.getLong()
 
-		if (   (bdc.compareTo(SQLDecimal.MINLONG_MINUS_ONE) == 1)
-			&& (bdc.compareTo(SQLDecimal.MAXLONG_PLUS_ONE) == -1)) {
+		if (   (bdc.compareTo(NumberDataType.MINLONG_MINUS_ONE) == 1)
+			&& (bdc.compareTo(NumberDataType.MAXLONG_PLUS_ONE) == -1)) {
 
 			setValue(bigDecimal.longValue());
 		} else {

Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBoolean.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBoolean.java?view=diff&r1=154372&r2=154373
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBoolean.java (original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBoolean.java Fri
Feb 18 16:50:43 2005
@@ -483,7 +483,7 @@
 
 	}
 
-	public void setBigDecimal(Number bigDecimal)
+	public void setBigDecimal(Number bigDecimal) throws StandardException
 	{
 		if (SanityManager.DEBUG)
 			SanityManager.ASSERT( ! immutable,
@@ -495,7 +495,9 @@
 		}
 		else
 		{
-			value = org.apache.derby.iapi.types.SQLDecimal.ZERO.compareTo(bigDecimal) != 0;
+			DataValueDescriptor tempDecimal = NumberDataType.ZERO_DECIMAL.getNewNull();
+			tempDecimal.setBigDecimal(bigDecimal);
+			value = NumberDataType.ZERO_DECIMAL.compare(tempDecimal) != 0;
 			isnull = false;
 		}
 

Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDecimal.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDecimal.java?view=diff&r1=154372&r2=154373
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDecimal.java (original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDecimal.java Fri
Feb 18 16:50:43 2005
@@ -67,8 +67,8 @@
  */
 public final class SQLDecimal extends NumberDataType implements VariableSizeDataValue
 {
-	static final BigDecimal ZERO = BigDecimal.valueOf(0L);
-	static final BigDecimal ONE = BigDecimal.valueOf(1L);
+	private static final BigDecimal ZERO = BigDecimal.valueOf(0L);
+	private 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);
 



Mime
View raw message