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 TypeTinyInt implements Type, Externalizable { 58 public static final TypeTinyInt typeTinyInt = new TypeTinyInt(); 59 60 public TypeTinyInt() {} 61 62 public String getTypeName() { 63 return "TINYINT"; 64 } 65 66 public int getJDBCType() { return Types.TINYINT; } 67 68 public String getJDBCClassName() { return "java.lang.Byte"; } 69 70 public int getPrecision() { return 8; } 71 72 public int getScale() { return 0; } 73 74 public int getMaxPrecision() { return 8; } 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 int getDisplayWidth() { return 4; } 89 90 public String toString() { 91 return "TINYINT"; 92 } 93 94 98 public void readExternal(ObjectInput in) { 99 } 100 101 public void writeExternal(ObjectOutput out) { 102 } 103 104 public Value convert(Value v) throws ValueException { 105 return v.convert(this); 106 } 107 108 111 public static ValueByte convertNumber(long n) throws ValueException { 112 if (n >= Byte.MIN_VALUE && n <= Byte.MAX_VALUE) { 113 return new ValueByte((byte)n); 114 } 115 throw new ValueException("Can't convert to TINYINT: " + n); 116 } 117 118 121 public static ValueByte convertNumber(float n) throws ValueException { 122 if (n >= Byte.MIN_VALUE && n <= Byte.MAX_VALUE) { 123 return new ValueByte((byte)n); 124 } 125 throw new ValueException("Can't convert to TINYINT: " + n); 126 } 127 128 131 public static ValueByte convertNumber(double n) throws ValueException { 132 if (n >= Byte.MIN_VALUE && n <= Byte.MAX_VALUE) { 133 return new ValueByte((byte)n); 134 } 135 throw new ValueException("Can't convert to TINYINT: " + n); 136 } 137 138 public String getCreateParams() { 139 return null; 140 } 141 } 142 | Popular Tags |