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 TypeTime implements Type, Externalizable { 58 public static final TypeTime typeTime = new TypeTime(); 59 60 int precision = 0; 61 boolean tz = false; 62 63 public TypeTime() {} 64 65 public TypeTime(int precision, boolean tz) { 66 this.precision = precision; 67 this.tz = tz; 68 } 69 70 public String getTypeName() { 71 return "TIME"; 72 } 73 74 public int getJDBCType() { return Types.TIME; } 75 76 public String getJDBCClassName() { return "java.sql.Time"; } 77 78 public int getPrecision() { return precision; } 79 80 public int getScale() { return 0; } 81 82 public int getMaxPrecision() { return 32; } 83 84 public int getMinScale() { return -1; } 85 86 public int getMaxScale() { return -1; } 87 88 public boolean isCharType() { return false; } 89 90 public boolean isCaseSensitive() { return false; } 91 92 public boolean isCurrency() { return false; } 93 94 public boolean isSigned() { return false; } 95 96 public String toString() { 97 StringBuffer sb = new StringBuffer ("TIME"); 98 if (precision > 0) { 99 sb.append('('); 100 sb.append(Integer.toString(precision)); 101 sb.append(')'); 102 } 103 if (tz) sb.append(" WITH TIME ZONE"); 104 return sb.toString(); 105 } 106 107 public int getDisplayWidth() { 108 int wid = 8; 109 if (precision > 0) wid += (precision + 1); 110 if (tz) wid += 6; 111 return wid; 112 } 113 114 public void readExternal(ObjectInput in) throws IOException { 115 precision = in.read(); 116 tz = in.read() == 1; 117 } 118 119 public void writeExternal(ObjectOutput out) throws IOException { 120 out.write(precision); 121 out.write(tz ? 1 : 0); 122 } 123 124 public Value convert(Value v) throws ValueException { 125 return v.convert(this); 126 } 127 128 public String getCreateParams() { 129 return null; 130 } 131 } 132 | Popular Tags |