if (pColumn.isStringColumn()) {
return new Object[]{pRs, ".getString(", pParamNum, ")"};
} else if (pColumn.isBinaryColumn()) {
return new Object[]{pRs, ".getBytes(", pParamNum, ")"};
} else if (Column.Type.DATE.equals(type)) {
LocalJavaField cal = pMethod.newJavaField(Calendar.class);
LocalJavaField date = pMethod.newJavaField(Date.class);
date.addLine(pRs, ".getDate(", pParamNum, ")");
pMethod.addIf(date, " == null");
pMethod.addLine(cal, " = null;");
pMethod.addElse();
pMethod.addLine(cal, " = ", Calendar.class, ".getInstance();");
pMethod.addLine(cal, ".setTime(", date, ");");
pMethod.addLine(cal, ".set(", Calendar.class, ".HOUR, 0);");
pMethod.addLine(cal, ".set(", Calendar.class, ".MINUTE, 0);");
pMethod.addLine(cal, ".set(", Calendar.class, ".SECOND, 0);");
pMethod.addLine(cal, ".set(", Calendar.class, ".MILLISECOND, 0);");
pMethod.addEndIf();
return cal;
} else if (Column.Type.TIME.equals(type)) {
LocalJavaField cal = pMethod.newJavaField(Calendar.class);
LocalJavaField date = pMethod.newJavaField(Time.class);
date.addLine(pRs, ".getTime(", pParamNum, ")");
pMethod.addIf(date, " == null");
pMethod.addLine(cal, " = null;");
pMethod.addElse();
pMethod.addLine(cal, " = ", Calendar.class, ".getInstance();");
pMethod.addLine(cal, ".setTime(", date, ");");
pMethod.addLine(cal, ".set(", Calendar.class, ".YEAR, 0);");
pMethod.addLine(cal, ".set(", Calendar.class, ".MONTH, 0);");
pMethod.addLine(cal, ".set(", Calendar.class, ".DAY_OF_MONTH, 0);");
pMethod.addEndIf();
return cal;
} else if (Column.Type.TIMESTAMP.equals(type)) {
LocalJavaField cal = pMethod.newJavaField(Calendar.class);
LocalJavaField date = pMethod.newJavaField(Timestamp.class);
date.addLine(pRs, ".getTimestamp(", pParamNum, ")");
pMethod.addIf(date, " == null");
pMethod.addLine(cal, " = null;");
pMethod.addElse();
pMethod.addLine(cal, " = ", Calendar.class, ".getInstance();");
pMethod.addLine(cal, ".setTime(", date, ");");
pMethod.addEndIf();
return cal;
} else if (Column.Type.BIT.equals(type)) {
LocalJavaField b = pMethod.newJavaField(boolean.class);
b.addLine(pRs, ".getBoolean(", pParamNum, ")");
return new Object[]{"(", pRs, ".wasNull() ? null : ",
b, " ? ", Boolean.class, ".TRUE : ", Boolean.class, ".FALSE)"};
} else if (Column.Type.BIGINT.equals(type)) {
LocalJavaField l = pMethod.newJavaField(long.class);
l.addLine(pRs, ".getLong(", pParamNum, ")");
return new Object[]{"(", pRs, ".wasNull() ? null : new Long(", l, ")"};
} else if (Column.Type.DOUBLE.equals(type)) {
LocalJavaField d = pMethod.newJavaField(double.class);
d.addLine(pRs, ".getDouble(", pParamNum, ")");
return new Object[]{"(", pRs, ".wasNull() ? null : new Double(", d, ")"};
} else if (Column.Type.FLOAT.equals(type)) {
LocalJavaField f = pMethod.newJavaField(float.class);
f.addLine(pRs, ".getFloat(", pParamNum, ")");
return new Object[]{"(", pRs, ".wasNull() ? null : new Float(", f, ")"};
} else if (Column.Type.INTEGER.equals(type)) {
LocalJavaField i = pMethod.newJavaField(int.class);
i.addLine(pRs, ".getInt(", pParamNum, ")");
return new Object[]{"(", pRs, ".wasNull() ? null : new Integer(", i, ")"};
} else if (Column.Type.SMALLINT.equals(type)) {
LocalJavaField s = pMethod.newJavaField(short.class);
s.addLine(pRs, ".getShort(", pParamNum, ")");
return new Object[]{"(", pRs, ".wasNull() ? null : new Short(", s, ")"};
} else if (Column.Type.TINYINT.equals(type)) {
LocalJavaField b = pMethod.newJavaField(byte.class);
b.addLine(pRs, ".getByte(", pParamNum, ")");
return new Object[]{"(", pRs, ".wasNull() ? null : new Byte(", b, ")"};
} else {
throw new IllegalStateException("Unknown column type: " + type);
}
}