1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00

Refactor: Clean up Type_ classes

This commit is contained in:
gnosygnu
2017-10-08 18:24:59 -04:00
parent 209601744e
commit d270cce881
67 changed files with 364 additions and 334 deletions

View File

@@ -55,21 +55,21 @@ public class Db_qry_sql implements Db_qry {
private static void Gen_sql_arg(Bry_bfr bfr, Object val) {
if (val == null) {bfr.Add(Bry_null); return;}
Class<?> val_type = val.getClass();
if (Type_adp_.Eq(val_type, Int_.Cls_ref_type))
if (Type_.Eq(val_type, Int_.Cls_ref_type))
bfr.Add_int_variable(Int_.cast(val));
else if (Type_adp_.Eq(val_type, Bool_.Cls_ref_type))
else if (Type_.Eq(val_type, Bool_.Cls_ref_type))
bfr.Add_int_fixed(1, Bool_.To_int(Bool_.Cast(val))); // NOTE: save boolean to 0 or 1, b/c (a) db may not support bit datatype (sqllite) and (b) avoid i18n issues with "true"/"false"
else if (Type_adp_.Eq(val_type, Double_.Cls_ref_type))
else if (Type_.Eq(val_type, Double_.Cls_ref_type))
bfr.Add_double(Double_.cast(val));
else if (Type_adp_.Eq(val_type, Long_.Cls_ref_type))
else if (Type_.Eq(val_type, Long_.Cls_ref_type))
bfr.Add_long_variable(Long_.cast(val));
else if (Type_adp_.Eq(val_type, Float_.Cls_ref_type))
else if (Type_.Eq(val_type, Float_.Cls_ref_type))
bfr.Add_float(Float_.cast(val));
else if (Type_adp_.Eq(val_type, Byte_.Cls_ref_type))
else if (Type_.Eq(val_type, Byte_.Cls_ref_type))
bfr.Add_byte(Byte_.cast(val));
else if (Type_adp_.Eq(val_type, DateAdp_.Cls_ref_type))
else if (Type_.Eq(val_type, DateAdp_.Cls_ref_type))
bfr.Add_byte_apos().Add_str_a7(DateAdp_.cast(val).XtoStr_gplx_long()).Add_byte_apos();
else if (Type_adp_.Eq(val_type, Decimal_adp_.Cls_ref_type))
else if (Type_.Eq(val_type, Decimal_adp_.Cls_ref_type))
bfr.Add_str_a7(Decimal_adp_.cast(val).To_str());
else {
byte[] val_bry = Bry_.new_u8(Object_.Xto_str_strict_or_null(val));

View File

@@ -178,7 +178,7 @@ public class Db_stmt_sql implements Db_stmt {// used for formatting SQL statemen
str = "NULL";
else {
str = Object_.Xto_str_strict_or_null(obj);
if (Type_adp_.Eq(obj.getClass(), String_.Cls_ref_type))
if (Type_.Eq(obj.getClass(), String_.Cls_ref_type))
str = "'" + String_.Replace(str, "'", "''") + "'";
}
ary[i] = str;