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 TypeVarBinary implements Type, Externalizable { 58 public static final TypeVarBinary typeVarBinary = new TypeVarBinary(-1); 59 60 int max; 61 62 public TypeVarBinary() {} 63 64 public TypeVarBinary(int max) { 65 this.max = max; 66 } 67 68 public String getTypeName() { 69 return "BIT VARYING"; 70 } 71 72 public int getMax() { return max; } 73 74 public int getJDBCType() { return Types.VARBINARY; } 75 76 public String getJDBCClassName() { return "byte[]"; } 77 78 public int getPrecision() { return max; } 79 80 public int getScale() { return 0; } 81 82 public int getMaxPrecision() { return -1; } 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 int getDisplayWidth() { return (max + 3) / 4; } 97 98 public String toString() { 99 StringBuffer sb = new StringBuffer (); 100 sb.append("BIT VARYING"); 101 if (max > 0) { 102 sb.append('('); 103 sb.append(Integer.toString(max)); 104 sb.append(')'); 105 } 106 return sb.toString(); 107 } 108 109 113 public void readExternal(ObjectInput in) throws IOException { 114 max = in.readInt(); 115 } 116 117 public void writeExternal(ObjectOutput out) throws IOException { 118 out.writeInt(max); 119 } 120 121 public Value convert(Value v) throws ValueException { 122 return v.convert(this); 123 } 124 125 public String getCreateParams() { 126 return "length"; 127 } 128 } 129 | Popular Tags |