KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > daffodilwoods > daffodildb > utils > field > FieldReal


1 package com.daffodilwoods.daffodildb.utils.field;
2
3 import com.daffodilwoods.daffodildb.server.sql99.common.Datatypes;
4 import com.daffodilwoods.database.resource.DException;
5 import com.daffodilwoods.daffodildb.utils.BufferRange;
6 import com.daffodilwoods.daffodildb.utils.GetByteComparator;
7
8 public class FieldReal
9     extends FieldBase
10     implements Datatypes, Comparable JavaDoc {
11
12   public FieldReal(BufferRange bufferRange0, int datatype0) {
13     bufferRange = bufferRange0;
14     datatype = datatype0;
15   }
16
17   public Object JavaDoc getObject() throws DException {
18     if (bufferRange.getNull())
19       return null;
20     if (object != null)
21       return object;
22     int a = 0;
23     for (int i = 0, j = 24; i < 4; i++, j -= 8)
24       a += ( (int) bufferRange.getByte(i) & 0xFF) << j;
25     return object = new Float JavaDoc(Float.intBitsToFloat(a));
26   }
27
28   public boolean equals(Object JavaDoc fieldBase) {
29     try {
30       return (getDatatype() != ( (FieldBase) fieldBase).getDatatype()) ? false :
31           GetByteComparator.sameComparator.compare(this, fieldBase) == 0;
32     }
33     catch (DException ex) {
34       return false;
35     }
36   }
37
38   public int compareTo(Object JavaDoc fieldBase) {
39     try {
40       return GetByteComparator.sameComparator.compare(this, fieldBase);
41     }
42     catch (DException ex) {
43       return -1;
44     }
45   }
46 }
47
Popular Tags