KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > iapi > types > SQLDouble


1 /*
2
3    Derby - Class org.apache.derby.iapi.types.SQLDouble
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to you under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derby.iapi.types;
23
24 import org.apache.derby.iapi.reference.SQLState;
25
26 import org.apache.derby.iapi.services.io.ArrayInputStream;
27
28 import org.apache.derby.iapi.services.io.StoredFormatIds;
29 import org.apache.derby.iapi.services.io.Storable;
30
31 import org.apache.derby.iapi.services.sanity.SanityManager;
32
33 import org.apache.derby.iapi.error.StandardException;
34
35 import org.apache.derby.iapi.types.BooleanDataValue;
36 import org.apache.derby.iapi.types.DataValueDescriptor;
37 import org.apache.derby.iapi.types.NumberDataValue;
38 import org.apache.derby.iapi.types.TypeId;
39
40 import org.apache.derby.iapi.services.cache.ClassSize;
41
42 import org.apache.derby.iapi.types.NumberDataType;
43 import org.apache.derby.iapi.types.SQLBoolean;
44
45 import java.io.ObjectOutput JavaDoc;
46 import java.io.ObjectInput JavaDoc;
47 import java.io.IOException JavaDoc;
48
49 import java.sql.ResultSet JavaDoc;
50 import java.sql.PreparedStatement JavaDoc;
51 import java.sql.SQLException JavaDoc;
52
53 /**
54  * SQLDouble satisfies the DataValueDescriptor
55  * interfaces (i.e., OrderableDataType). It implements a double column,
56  * e.g. for * storing a column value; it can be specified
57  * when constructed to not allow nulls. Nullability cannot be changed
58  * after construction, as it affects the storage size and mechanism.
59  * <p>
60  * Because OrderableDataType is a subtype of DataType,
61  * SQLDouble can play a role in either a DataType/Row
62  * or a OrderableDataType/Row, interchangeably.
63  * <p>
64  * We assume the store has a flag for nullness of the value,
65  * and simply return a 0-length array for the stored form
66  * when the value is null.
67  * <p>
68  * PERFORMANCE: There are likely alot of performance improvements
69  * possible for this implementation -- it new's Double
70  * more than it probably wants to.
71  * <p>
72  * This is modeled after SQLInteger.
73  * <p>
74  * We don't let doubles get constructed with NaN or Infinity values, and
75  * check for those values where they can occur on operations, so the
76  * set* operations do not check for them coming in.
77  *
78  * @author ames
79  */

80 public final class SQLDouble extends NumberDataType
81 {
82
83     /*
84      * DataValueDescriptor interface
85      * (mostly implemented in DataType)
86      */

87
88
89     // JDBC is lax in what it permits and what it
90
// returns, so we are similarly lax
91
// @see DataValueDescriptor
92
/**
93      * @exception StandardException thrown on failure to convert
94      */

95     public int getInt() throws StandardException
96     {
97         // REMIND: do we want to check for truncation?
98
if ((value > (((double) Integer.MAX_VALUE) + 1.0d)) || (value < (((double) Integer.MIN_VALUE) - 1.0d)))
99             throw StandardException.newException(SQLState.LANG_OUTSIDE_RANGE_FOR_DATATYPE, "INTEGER");
100         return (int)value;
101     }
102
103     /**
104      * @exception StandardException thrown on failure to convert
105      */

106     public byte getByte() throws StandardException
107     {
108         if ((value > (((double) Byte.MAX_VALUE) + 1.0d)) || (value < (((double) Byte.MIN_VALUE) - 1.0d)))
109             throw StandardException.newException(SQLState.LANG_OUTSIDE_RANGE_FOR_DATATYPE, "TINYINT");
110         return (byte) value;
111     }
112
113     /**
114      * @exception StandardException thrown on failure to convert
115      */

116     public short getShort() throws StandardException
117     {
118         if ((value > (((double) Short.MAX_VALUE) + 1.0d)) || (value < (((double) Short.MIN_VALUE) - 1.0d)))
119             throw StandardException.newException(SQLState.LANG_OUTSIDE_RANGE_FOR_DATATYPE, "SMALLINT");
120         return (short) value;
121     }
122
123     /**
124      * @exception StandardException thrown on failure to convert
125      */

126     public long getLong() throws StandardException
127     {
128         if ((value > (((double) Long.MAX_VALUE) + 1.0d)) || (value < (((double) Long.MIN_VALUE) - 1.0d)))
129             throw StandardException.newException(SQLState.LANG_OUTSIDE_RANGE_FOR_DATATYPE, "BIGINT");
130         return (long) value;
131     }
132
133     /**
134      * @exception StandardException thrown on failure to convert
135      */

136     public float getFloat() throws StandardException
137     {
138         if (Float.isInfinite((float)value))
139             throw StandardException.newException(SQLState.LANG_OUTSIDE_RANGE_FOR_DATATYPE, TypeId.REAL_NAME);
140         return (float) value;
141     }
142
143     public double getDouble()
144     {
145         /* This value is bogus if the SQLDouble is null */
146         return value;
147     }
148
149     /**
150      * DOUBLE implementation. Convert to a BigDecimal using getString.
151      */

152     public int typeToBigDecimal()
153     {
154         return java.sql.Types.CHAR;
155     }
156     // for lack of a specification: getDouble()==0 gives true
157
// independent of the NULL flag
158
public boolean getBoolean()
159     {
160         return (value != 0);
161     }
162
163     public String JavaDoc getString()
164     {
165         if (isNull())
166             return null;
167         else
168             return Double.toString(value);
169     }
170
171     public Object JavaDoc getObject()
172     {
173         // REMIND: could create one Double and reuse it?
174
if (isNull())
175             return null;
176         else
177             return new Double JavaDoc(value);
178     }
179
180
181     /**
182      * Set the value from a correctly typed Double object.
183      * @throws StandardException
184      */

185     void setObject(Object JavaDoc theValue) throws StandardException
186     {
187         setValue(((Double JavaDoc) theValue).doubleValue());
188     }
189     
190     protected void setFrom(DataValueDescriptor theValue) throws StandardException {
191         setValue(theValue.getDouble());
192     }
193
194     public int getLength()
195     {
196         return DOUBLE_LENGTH;
197     }
198
199     // this is for DataType's error generator
200
public String JavaDoc getTypeName()
201     {
202         return TypeId.DOUBLE_NAME;
203     }
204
205     /*
206      * Storable interface, implies Externalizable, TypedFormat
207      */

208
209     /**
210         Return my format identifier.
211
212         @see org.apache.derby.iapi.services.io.TypedFormat#getTypeFormatId
213     */

214     public int getTypeFormatId() {
215         return StoredFormatIds.SQL_DOUBLE_ID;
216     }
217
218     /*
219      * see if the double value is null.
220      */

221     /** @see Storable#isNull */
222     public boolean isNull()
223     {
224         return isnull;
225     }
226
227     public void writeExternal(ObjectOutput JavaDoc out) throws IOException JavaDoc {
228
229
230         // never called when value is null
231
if (SanityManager.DEBUG)
232             SanityManager.ASSERT(! isNull());
233
234         out.writeDouble(value);
235     }
236
237     /** @see java.io.Externalizable#readExternal */
238     public void readExternal(ObjectInput JavaDoc in) throws IOException JavaDoc {
239
240         value = in.readDouble();
241         isnull = false;
242     }
243
244     /** @see java.io.Externalizable#readExternal */
245     public void readExternalFromArray(ArrayInputStream in) throws IOException JavaDoc {
246
247         value = in.readDouble();
248         isnull = false;
249     }
250
251     /**
252      * @see Storable#restoreToNull
253      *
254      */

255
256     public void restoreToNull()
257     {
258         value = 0;
259         isnull = true;
260     }
261
262
263     /** @exception StandardException Thrown on error */
264     protected int typeCompare(DataValueDescriptor arg) throws StandardException
265     {
266         /* neither are null, get the value */
267
268         double thisValue = this.getDouble();
269
270         double otherValue = arg.getDouble();
271
272         if (thisValue == otherValue)
273             return 0;
274         else if (thisValue > otherValue)
275             return 1;
276         else
277             return -1;
278     }
279
280     /*
281      * DataValueDescriptor interface
282      */

283
284     /** @see DataValueDescriptor#getClone */
285     public DataValueDescriptor getClone()
286     {
287         try
288         {
289             return new SQLDouble(value, isnull);
290         } catch (StandardException se)
291         {
292             if (SanityManager.DEBUG)
293                 SanityManager.THROWASSERT(
294                     "error on clone, se = " + se +
295                     " value = " + value +
296                     " isnull = " + isnull);
297             return null;
298         }
299     }
300
301     /**
302      * @see DataValueDescriptor#getNewNull
303      */

304     public DataValueDescriptor getNewNull()
305     {
306         return new SQLDouble();
307     }
308
309     /**
310      * @see DataValueDescriptor#setValueFromResultSet
311      *
312      * @exception StandardException Thrown on error
313      * @exception SQLException Thrown on error
314      */

315     public void setValueFromResultSet(ResultSet JavaDoc resultSet, int colNumber,
316                                       boolean isNullable)
317         throws StandardException, SQLException JavaDoc
318     {
319             double dv = resultSet.getDouble(colNumber);
320             isnull = (isNullable && resultSet.wasNull());
321             if (isnull)
322                 value = 0;
323             else
324                 value = NumberDataType.normalizeDOUBLE(dv);
325     }
326     /**
327         Set the value into a PreparedStatement.
328
329         @exception SQLException Error setting value in PreparedStatement
330     */

331     public final void setInto(PreparedStatement JavaDoc ps, int position) throws SQLException JavaDoc {
332
333         if (isNull()) {
334             ps.setNull(position, java.sql.Types.DOUBLE);
335             return;
336         }
337
338         ps.setDouble(position, value);
339     }
340     /**
341         Set this value into a ResultSet for a subsequent ResultSet.insertRow
342         or ResultSet.updateRow. This method will only be called for non-null values.
343
344         @exception SQLException thrown by the ResultSet object
345         @exception StandardException thrown by me accessing my value.
346     */

347     public final void setInto(ResultSet JavaDoc rs, int position) throws SQLException JavaDoc, StandardException {
348         rs.updateDouble(position, value);
349     }
350     /*
351      * class interface
352      */

353
354     /*
355      * constructors
356      */

357
358     /** no-arg constructor, required by Formattable */
359     // This constructor also gets used when we are
360
// allocating space for a double.
361
public SQLDouble() {
362         isnull = true;
363     }
364
365     public SQLDouble(double val) throws StandardException
366     {
367         value = NumberDataType.normalizeDOUBLE(val);
368     }
369
370     public SQLDouble(Double JavaDoc obj) throws StandardException {
371         if (isnull = (obj == null))
372             ;
373         else
374             value = NumberDataType.normalizeDOUBLE(obj.doubleValue());
375     }
376
377     private SQLDouble(double val, boolean startsnull) throws StandardException
378     {
379         value = NumberDataType.normalizeDOUBLE(val); // maybe only do if !startsnull
380
isnull = startsnull;
381     }
382
383     /**
384         @exception StandardException throws NumberFormatException
385             when the String format is not recognized.
386      */

387     public void setValue(String JavaDoc theValue) throws StandardException
388     {
389         if (theValue == null)
390         {
391             value = 0;
392             isnull = true;
393         }
394         else
395         {
396             double doubleValue = 0;
397             try {
398                 // ??? jsk: rounding???
399
doubleValue = Double.valueOf(theValue.trim()).doubleValue();
400             } catch (NumberFormatException JavaDoc nfe) {
401                 throw invalidFormat();
402             }
403             value = NumberDataType.normalizeDOUBLE(doubleValue);
404             isnull = false;
405         }
406     }
407
408     /**
409      * @exception StandardException on NaN or Infinite double
410      */

411     public void setValue(double theValue) throws StandardException
412     {
413         value = NumberDataType.normalizeDOUBLE(theValue);
414         isnull = false;
415     }
416
417     /**
418      * @exception StandardException on NaN or Infinite float
419      */

420     public void setValue(float theValue) throws StandardException
421     {
422         value = NumberDataType.normalizeDOUBLE(theValue);
423         isnull = false;
424     }
425
426     public void setValue(long theValue)
427     {
428         value = theValue; // no check needed
429
isnull = false;
430     }
431
432     public void setValue(int theValue)
433     {
434         value = theValue; // no check needed
435
isnull = false;
436     }
437
438     public void setValue(Number JavaDoc theValue) throws StandardException
439     {
440         if (objectNull(theValue))
441             return;
442
443         if (SanityManager.ASSERT)
444         {
445             if (!(theValue instanceof java.lang.Double JavaDoc))
446                 SanityManager.THROWASSERT("SQLDouble.setValue(Number) passed a " + theValue.getClass());
447         }
448
449         setValue(theValue.doubleValue());
450     }
451
452     /**
453         Called for an application setting this value using a BigDecimal
454     */

455     public void setBigDecimal(Number JavaDoc bigDecimal) throws StandardException
456     {
457         if (objectNull(bigDecimal))
458             return;
459
460         // Note BigDecimal.doubleValue() handles the case where
461
// its value is outside the range of a double. It returns
462
// infinity values which should throw an exception in setValue(double).
463
setValue(bigDecimal.doubleValue());
464         
465     }
466
467     /**
468      * @see NumberDataValue#setValue
469      *
470      */

471     public void setValue(boolean theValue)
472     {
473         value = theValue?1:0;
474         isnull = false;
475     }
476
477
478     /*
479      * DataValueDescriptor interface
480      */

481
482     /** @see DataValueDescriptor#typePrecedence */
483     public int typePrecedence()
484     {
485         return TypeId.DOUBLE_PRECEDENCE;
486     }
487
488
489     /*
490     ** SQL Operators
491     */

492
493     /**
494      * The = operator as called from the language module, as opposed to
495      * the storage module.
496      *
497      * @param left The value on the left side of the =
498      * @param right The value on the right side of the =
499      * is not.
500      *
501      * @return A SQL boolean value telling whether the two parameters are equal
502      *
503      * @exception StandardException Thrown on error
504      */

505
506     public BooleanDataValue equals(DataValueDescriptor left,
507                             DataValueDescriptor right)
508             throws StandardException
509     {
510         return SQLBoolean.truthValue(left,
511                                      right,
512                                      left.getDouble() == right.getDouble());
513     }
514
515     /**
516      * The <> operator as called from the language module, as opposed to
517      * the storage module.
518      *
519      * @param left The value on the left side of the <>
520      * @param right The value on the right side of the <>
521      * is not.
522      *
523      * @return A SQL boolean value telling whether the two parameters
524      * are not equal
525      *
526      * @exception StandardException Thrown on error
527      */

528
529     public BooleanDataValue notEquals(DataValueDescriptor left,
530                             DataValueDescriptor right)
531             throws StandardException
532     {
533         return SQLBoolean.truthValue(left,
534                                      right,
535                                      left.getDouble() != right.getDouble());
536     }
537
538     /**
539      * The < operator as called from the language module, as opposed to
540      * the storage module.
541      *
542      * @param left The value on the left side of the <
543      * @param right The value on the right side of the <
544      *
545      * @return A SQL boolean value telling whether the first operand is less
546      * than the second operand
547      *
548      * @exception StandardException Thrown on error
549      */

550
551     public BooleanDataValue lessThan(DataValueDescriptor left,
552                             DataValueDescriptor right)
553             throws StandardException
554     {
555         return SQLBoolean.truthValue(left,
556                                      right,
557                                      left.getDouble() < right.getDouble());
558     }
559
560     /**
561      * The > operator as called from the language module, as opposed to
562      * the storage module.
563      *
564      * @param left The value on the left side of the >
565      * @param right The value on the right side of the >
566      *
567      * @return A SQL boolean value telling whether the first operand is greater
568      * than the second operand
569      *
570      * @exception StandardException Thrown on error
571      */

572
573     public BooleanDataValue greaterThan(DataValueDescriptor left,
574                             DataValueDescriptor right)
575             throws StandardException
576     {
577         return SQLBoolean.truthValue(left,
578                                      right,
579                                      left.getDouble() > right.getDouble());
580     }
581
582     /**
583      * The <= operator as called from the language module, as opposed to
584      * the storage module.
585      *
586      * @param left The value on the left side of the <=
587      * @param right The value on the right side of the <=
588      *
589      * @return A SQL boolean value telling whether the first operand is less
590      * than or equal to the second operand
591      *
592      * @exception StandardException Thrown on error
593      */

594
595     public BooleanDataValue lessOrEquals(DataValueDescriptor left,
596                             DataValueDescriptor right)
597             throws StandardException
598     {
599         return SQLBoolean.truthValue(left,
600                                      right,
601                                      left.getDouble() <= right.getDouble());
602     }
603
604     /**
605      * The >= operator as called from the language module, as opposed to
606      * the storage module.
607      *
608      * @param left The value on the left side of the >=
609      * @param right The value on the right side of the >=
610      *
611      * @return A SQL boolean value telling whether the first operand is greater
612      * than or equal to the second operand
613      *
614      * @exception StandardException Thrown on error
615      */

616
617     public BooleanDataValue greaterOrEquals(DataValueDescriptor left,
618                             DataValueDescriptor right)
619             throws StandardException
620     {
621         return SQLBoolean.truthValue(left,
622                                      right,
623                                      left.getDouble() >= right.getDouble());
624     }
625
626     /**
627      * This method implements the + operator for "double + double".
628      *
629      * @param addend1 One of the addends
630      * @param addend2 The other addend
631      * @param result The result of a previous call to this method, null
632      * if not called yet
633      *
634      * @return A SQLDouble containing the result of the addition
635      *
636      * @exception StandardException Thrown on error
637      */

638
639     public NumberDataValue plus(NumberDataValue addend1,
640                             NumberDataValue addend2,
641                             NumberDataValue result)
642                 throws StandardException
643     {
644         if (result == null)
645         {
646             result = new SQLDouble();
647         }
648
649         if (addend1.isNull() || addend2.isNull())
650         {
651             result.setToNull();
652             return result;
653         }
654
655         double tmpresult = addend1.getDouble() + addend2.getDouble();
656         // No need to check underflow (result rounded to 0.0),
657
// since the difference between two non-equal valid DB2 DOUBLE values is always non-zero in java.lang.Double precision.
658
result.setValue(tmpresult);
659
660         return result;
661     }
662
663     /**
664      * This method implements the - operator for "double - double".
665      *
666      * @param left The value to be subtracted from
667      * @param right The value to be subtracted
668      * @param result The result of a previous call to this method, null
669      * if not called yet
670      *
671      * @return A SQLDouble containing the result of the subtraction
672      *
673      * @exception StandardException Thrown on error
674      */

675
676     public NumberDataValue minus(NumberDataValue left,
677                             NumberDataValue right,
678                             NumberDataValue result)
679                 throws StandardException
680     {
681         if (result == null)
682         {
683             result = new SQLDouble();
684         }
685
686         if (left.isNull() || right.isNull())
687         {
688             result.setToNull();
689             return result;
690         }
691
692         double tmpresult = left.getDouble() - right.getDouble();
693         // No need to check underflow (result rounded to 0.0),
694
// since no difference between two valid DB2 DOUBLE values can be rounded off to 0.0 in java.lang.Double
695
result.setValue(tmpresult);
696         return result;
697     }
698
699     /**
700      * This method implements the * operator for "double * double".
701      *
702      * @param left The first value to be multiplied
703      * @param right The second value to be multiplied
704      * @param result The result of a previous call to this method, null
705      * if not called yet
706      *
707      * @return A SQLDouble containing the result of the multiplication
708      *
709      * @exception StandardException Thrown on error
710      */

711
712     public NumberDataValue times(NumberDataValue left,
713                             NumberDataValue right,
714                             NumberDataValue result)
715                 throws StandardException
716     {
717         if (result == null)
718         {
719             result = new SQLDouble();
720         }
721
722         if (left.isNull() || right.isNull())
723         {
724             result.setToNull();
725             return result;
726         }
727
728         double leftValue = left.getDouble();
729         double rightValue = right.getDouble();
730         double tempResult = leftValue * rightValue;
731         // check underflow (result rounded to 0.0)
732
if ( (tempResult == 0.0) && ( (leftValue != 0.0) && (rightValue != 0.0) ) ) {
733             throw StandardException.newException(SQLState.LANG_OUTSIDE_RANGE_FOR_DATATYPE, TypeId.DOUBLE_NAME);
734         }
735
736         result.setValue(tempResult);
737         return result;
738     }
739
740     /**
741      * This method implements the / operator for "double / double".
742      *
743      * @param dividend The numerator
744      * @param divisor The denominator
745      * @param result The result of a previous call to this method, null
746      * if not called yet
747      *
748      * @return A SQLDouble containing the result of the division
749      *
750      * @exception StandardException Thrown on error
751      */

752
753     public NumberDataValue divide(NumberDataValue dividend,
754                              NumberDataValue divisor,
755                              NumberDataValue result)
756                 throws StandardException
757     {
758         if (result == null)
759         {
760             result = new SQLDouble();
761         }
762
763         if (dividend.isNull() || divisor.isNull())
764         {
765             result.setToNull();
766             return result;
767         }
768
769         /*
770         ** For double division, we can't catch divide by zero with Double.NaN;
771         ** So we check the divisor before the division.
772         */

773
774         double divisorValue = divisor.getDouble();
775
776         if (divisorValue == 0.0e0D)
777         {
778             throw StandardException.newException(SQLState.LANG_DIVIDE_BY_ZERO);
779         }
780
781         double dividendValue = dividend.getDouble();
782         double divideResult = dividendValue / divisorValue;
783
784         if (Double.isNaN(divideResult))
785         {
786             throw StandardException.newException(SQLState.LANG_DIVIDE_BY_ZERO);
787         }
788
789         // check underflow (result rounded to 0.0d)
790
if ((divideResult == 0.0d) && (dividendValue != 0.0d)) {
791             throw StandardException.newException(SQLState.LANG_OUTSIDE_RANGE_FOR_DATATYPE, TypeId.DOUBLE_NAME);
792         }
793
794         result.setValue(divideResult);
795         return result;
796     }
797
798     /**
799      * This method implements the unary minus operator for double.
800      *
801      * @param result The result of a previous call to this method, null
802      * if not called yet
803      *
804      * @return A SQLDouble containing the result of the division
805      *
806      * @exception StandardException Thrown on error
807      */

808
809     public NumberDataValue minus(NumberDataValue result)
810                                     throws StandardException
811     {
812         double minusResult;
813
814         if (result == null)
815         {
816             result = new SQLDouble();
817         }
818
819         if (this.isNull())
820         {
821             result.setToNull();
822             return result;
823         }
824
825         /*
826         ** Doubles are assumed to be symmetric -- that is, their
827         ** smallest negative value is representable as a positive
828         ** value, and vice-versa.
829         */

830         minusResult = -(this.getDouble());
831
832         result.setValue(minusResult);
833         return result;
834     }
835
836     /**
837      * This method implements the isNegative method.
838      *
839      * @return A boolean. If this.value is negative, return true.
840      * For positive values or null, return false.
841      */

842
843     protected boolean isNegative()
844     {
845         return !isNull() && (value < 0.0d);
846     }
847
848     /*
849      * String display of value
850      */

851
852     public String JavaDoc toString()
853     {
854         if (isNull())
855             return "NULL";
856         else
857             return Double.toString(value);
858     }
859
860     /*
861      * Hash code
862      */

863     public int hashCode()
864     {
865         long longVal = (long) value;
866         double doubleLongVal = (double) longVal;
867
868         /*
869         ** NOTE: This is coded to work around a bug in Visual Cafe 3.0.
870         ** If longVal is compared directly to value on that platform
871         ** with the JIT enabled, the values will not always compare
872         ** as equal even when they should be equal. This happens with
873         ** the value Long.MAX_VALUE, for example.
874         **
875         ** Assigning the long value back to a double and then doing
876         ** the comparison works around the bug.
877         **
878         ** This fixes Cloudscape bug number 1757.
879         **
880         ** - Jeff Lichtman
881         */

882         if (doubleLongVal != value)
883         {
884             longVal = Double.doubleToLongBits(value);
885         }
886
887         return (int) (longVal ^ (longVal >> 32));
888     }
889
890     /*
891      * useful constants...
892      */

893     static final int DOUBLE_LENGTH = 32; // must match the number of bytes written by DataOutput.writeDouble()
894

895     private static final int BASE_MEMORY_USAGE = ClassSize.estimateBaseFromCatalog( SQLDouble.class);
896
897     public int estimateMemoryUsage()
898     {
899         return BASE_MEMORY_USAGE;
900     }
901
902     /*
903      * object state
904      */

905     private double value;
906     private boolean isnull;
907 }
908
Popular Tags