1 package com.quadcap.sql.types; 2 3 40 41 import java.io.Externalizable ; 42 import java.io.IOException ; 43 import java.io.ObjectInput ; 44 import java.io.ObjectOutput ; 45 46 import java.sql.ResultSet ; 47 import java.sql.SQLException ; 48 import java.sql.Types ; 49 50 import com.quadcap.util.Debug; 51 52 57 public class TypeInt implements Type, Externalizable { 58 public static final TypeInt typeInt = new TypeInt(); 59 60 public TypeInt() {} 61 62 public String getTypeName() { 63 return "INT"; 64 } 65 66 public int getJDBCType() { return Types.INTEGER; } 67 68 public String getJDBCClassName() { return "java.lang.Integer"; } 69 70 public int getPrecision() { return 32; } 71 72 public int getScale() { return 0; } 73 74 public int getMaxPrecision() { return 32; } 75 76 public int getMinScale() { return 0; } 77 78 public int getMaxScale() { return 0; } 79 80 public boolean isCharType() { return false; } 81 82 public boolean isCaseSensitive() { return false; } 83 84 public boolean isCurrency() { return false; } 85 86 public boolean isSigned() { return true; } 87 88 public String toString() { 89 return "INT"; 90 } 91 92 public int getDisplayWidth() { return 10; } 93 94 public void readExternal(ObjectInput in) { 95 } 96 97 public void writeExternal(ObjectOutput out) { 98 } 99 100 public Value convert(Value v) throws ValueException { 101 return v.convert(this); 102 } 103 104 107 public static ValueInteger convertNumber(long n) throws ValueException { 108 if (n >= Integer.MIN_VALUE && n <= Integer.MAX_VALUE) { 109 return new ValueInteger((int)n); 110 } 111 throw new ValueException("Can't convert to INT: " + n); 112 } 113 114 117 public static ValueInteger convertNumber(float n) throws ValueException { 118 if (n >= Integer.MIN_VALUE && n <= Integer.MAX_VALUE) { 119 return new ValueInteger((int)n); 120 } 121 throw new ValueException("Can't convert to INT: " + n); 122 } 123 124 127 public static ValueInteger convertNumber(double n) throws ValueException { 128 if (n >= Integer.MIN_VALUE && n <= Integer.MAX_VALUE) { 129 return new ValueInteger((int)n); 130 } 131 throw new ValueException("Can't convert to INT: " + n); 132 } 133 134 public String getCreateParams() { 135 return null; 136 } 137 } 138 | Popular Tags |