KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > db4o > YDouble


1 /* Copyright (C) 2004 - 2006 db4objects Inc. http://www.db4o.com
2
3 This file is part of the db4o open source object database.
4
5 db4o is free software; you can redistribute it and/or modify it under
6 the terms of version 2 of the GNU General Public License as published
7 by the Free Software Foundation and as clarified by db4objects' GPL
8 interpretation policy, available at
9 http://www.db4o.com/about/company/legalpolicies/gplinterpretation/
10 Alternatively you can write to db4objects, Inc., 1900 S Norfolk Street,
11 Suite 350, San Mateo, CA 94403, USA.
12
13 db4o is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
17
18 You should have received a copy of the GNU General Public License along
19 with this program; if not, write to the Free Software Foundation, Inc.,
20 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */

21 package com.db4o;
22
23 import com.db4o.foundation.*;
24 import com.db4o.reflect.*;
25
26 /**
27  * @exclude
28  */

29 public final class YDouble extends YLong
30 {
31     private static final Double JavaDoc i_primitive = new Double JavaDoc(0);
32     
33     public YDouble(YapStream stream) {
34         super(stream);
35     }
36     
37     public Object JavaDoc coerce(ReflectClass claxx, Object JavaDoc obj) {
38         return Coercion4.toDouble(obj);
39     }
40
41     public Object JavaDoc defaultValue(){
42         return i_primitive;
43     }
44     
45     public int getID(){
46         return 5;
47     }
48     
49     protected Class JavaDoc primitiveJavaClass(){
50         return double.class;
51     }
52     
53     Object JavaDoc primitiveNull(){
54         return i_primitive;
55     }
56     
57     Object JavaDoc read1(YapReader a_bytes){
58         return new Double JavaDoc(Platform4.longToDouble(readLong(a_bytes)));
59     }
60     
61     public void write(Object JavaDoc a_object, YapReader a_bytes){
62         a_bytes.writeLong(Platform4.doubleToLong(((Double JavaDoc)a_object).doubleValue()));
63     }
64     
65     
66     // Comparison_______________________
67

68     private double i_compareToDouble;
69     
70     private double dval(Object JavaDoc obj){
71         return ((Double JavaDoc)obj).doubleValue();
72     }
73     
74     void prepareComparison1(Object JavaDoc obj){
75         i_compareToDouble = dval(obj);
76     }
77     
78     public Object JavaDoc current1(){
79         return new Double JavaDoc(i_compareToDouble);
80     }
81     
82     boolean isEqual1(Object JavaDoc obj){
83         return obj instanceof Double JavaDoc && dval(obj) == i_compareToDouble;
84     }
85     
86     boolean isGreater1(Object JavaDoc obj){
87         return obj instanceof Double JavaDoc && dval(obj) > i_compareToDouble;
88     }
89     
90     boolean isSmaller1(Object JavaDoc obj){
91         return obj instanceof Double JavaDoc && dval(obj) < i_compareToDouble;
92     }
93     
94     
95 }
96
Popular Tags