1 24 25 package com.mckoi.database; 26 27 import com.mckoi.util.BigNumber; 28 29 34 35 public final class TNumericType extends TType { 36 37 static final long serialVersionUID = -5133489773377747175L; 38 39 42 private int size; 43 44 47 private int scale; 48 49 50 55 public TNumericType(int sql_type, int size, int scale) { 56 super(sql_type); 57 this.size = size; 58 this.scale = scale; 59 } 60 61 64 public int getSize() { 65 return size; 66 } 67 68 71 public int getScale() { 72 return scale; 73 } 74 75 77 public boolean comparableTypes(TType type) { 78 return (type instanceof TNumericType || 79 type instanceof TBooleanType); 80 } 81 82 public int compareObs(Object ob1, Object ob2) { 83 BigNumber n1 = (BigNumber) ob1; 84 BigNumber n2; 85 86 if (ob2 instanceof BigNumber) { 87 n2 = (BigNumber) ob2; 88 } 89 else { 90 n2 = ob2.equals(Boolean.TRUE) ? 91 BigNumber.BIG_NUMBER_ONE : BigNumber.BIG_NUMBER_ZERO; 92 } 93 94 return n1.compareTo(n2); 95 } 96 97 public int calculateApproximateMemoryUse(Object ob) { 98 return 25 + 16; 101 } 102 103 public Class javaClass() { 104 return BigNumber.class; 105 } 106 107 } 108 | Popular Tags |