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 import java.util.*; 8 9 public class FieldInteger 10 extends FieldBase 11 implements Datatypes, Comparable { 12 13 private int result; 14 15 public FieldInteger(BufferRange bufferRange0, int datatype0) { 16 bufferRange = bufferRange0; 17 datatype = datatype0; 18 } 19 20 public FieldInteger(Object object0, int datatype0) { 21 object = object0; 22 datatype = datatype0; 23 } 24 25 public FieldInteger(int value, int datatype0) { 26 result = value; 27 datatype = datatype0; 28 } 29 30 public Object getObject() throws DException { 31 if (bufferRange.getNull()) 32 return null; 33 if (object != null) 34 return object; 35 int a = 0; 36 for (int i = 0, j = 24; i < 4; i++, j -= 8) 37 a += ( (int) bufferRange.getByte(i) & 0xFF) << j; 38 return object = new Integer (a); 39 40 } 41 42 public int hashCode() { 43 return result; 44 } 45 46 public boolean equals(Object fieldBase) { 47 try { 48 return (getDatatype() != ( (FieldBase) fieldBase).getDatatype()) ? false : 49 GetByteComparator.sameComparator.compare(this, fieldBase) == 0; 50 } 51 catch (DException ex) { 52 return false; 53 } 54 } 55 56 public int compareTo(Object fieldBase) { 57 try { 58 return GetByteComparator.sameComparator.compare(this, fieldBase); 59 } 60 catch (DException ex) { 61 return -1; 62 } 63 } 64 65 public String toString1() { 66 return "FieldInteger [ Object = " + object + " " + bufferRange + 67 " DataType = " + datatype + " ]"; 68 } 69 } 70 | Popular Tags |