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 FieldLong extends FieldBase implements Datatypes,Comparable { 10 11 public FieldLong(BufferRange bufferRange0,int datatype0) { 12 bufferRange = bufferRange0; 13 datatype = datatype0; 14 } 15 16 public Object getObject() throws DException { 17 if (bufferRange.getNull()) 18 return null; 19 if (object != null) 20 return object; 21 long a = 0; 22 try { 23 for (int i = 0, j = 56; i < 8; i++, j -= 8) { 24 a += ( (long) bufferRange.getByte(i) & 0xFF) << j; 25 } 26 } 27 catch (ArrayIndexOutOfBoundsException ex) { 28 } 29 object = new Long (a); 30 return object; 31 } 32 33 public boolean equals(Object fieldBase){ 34 try { 35 return (datatype != ((FieldBase)fieldBase).getDatatype()) ? false : 36 GetByteComparator.sameComparator.compare(this,fieldBase) == 0 ; 37 } 38 catch (DException ex) { 39 return false; 40 } 41 } 42 43 public int compareTo(Object fieldBase){ 44 try { 45 return GetByteComparator.sameComparator.compare(this,fieldBase) ; 46 } 47 catch (DException ex) { 48 return -1; 49 } 50 } 51 52 public int hashCode(){ 53 try { 54 return ( (Long ) getObject()).intValue(); 55 } 56 catch (DException ex) { 57 return 0; 58 } 59 } 60 61 } 62 | Popular Tags |