Methods Summary |
---|
public byte[] | getBytes()
byte b[] = null;
// A null value always returns null
if (data == null) {
return null;
}
switch(internalType) {
case Types.VARCHAR:
{
// Convert the String into a byte array. The String must
// contain an even number of hex digits
String s = ((String) data).toUpperCase();
String digits = "0123456789ABCDEF";
int len = s.length();
int index;
if ((len % 2) != 0) {
throw new SQLException(
"Data must have a even number of hex digits");
}
b = new byte[len / 2];
for (int i = 0; i < (len / 2); i++) {
index = digits.indexOf(s.charAt(i * 2));
if (index < 0) {
throw new SQLException("Invalid hex digit");
}
b[i] = (byte) (index << 4);
index = digits.indexOf(s.charAt((i * 2) + 1));
if (index < 0) {
throw new SQLException("Invalid hex digit");
}
b[i] += (byte) index;
}
}
break;
case Types.VARBINARY:
b = (byte[]) data;
break;
default:
throw new SQLException("Unable to convert data type to byte[]: " +
internalType);
}
return b;
|
public int | getInt()
int i = 0;
// A null value always returns zero
if (data == null) {
return 0;
}
switch(internalType) {
case Types.VARCHAR:
i = (Integer.valueOf((String) data)).intValue();
break;
case Types.INTEGER:
i = ((Integer) data).intValue();
break;
default:
throw new SQLException("Unable to convert data type to String: " +
internalType);
}
return i;
|
public java.lang.String | getString()
String s;
// A null value always returns null
if (data == null) {
return null;
}
switch(internalType) {
case Types.VARCHAR:
s = (String) data;
break;
case Types.INTEGER:
s = ((Integer) data).toString();
break;
case Types.VARBINARY:
{
// Convert a byte array into a String of hex digits
byte b[] = (byte[]) data;
int len = b.length;
String digits = "0123456789ABCDEF";
char c[] = new char[len * 2];
for (int i = 0; i < len; i++) {
c[i * 2] = digits.charAt((b[i] >> 4) & 0x0F);
c[(i * 2) + 1] = digits.charAt(b[i] & 0x0F);
}
s = new String(c);
}
break;
default:
throw new SQLException("Unable to convert data type to String: " +
internalType);
}
return s;
|
public boolean | isNull()
return (data == null);
|