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

@@ -19,10 +19,10 @@ import gplx.dbs.sqls.wtrs.*;
public class Db_obj_ary_tst {
@Before public void init() {} private Db_obj_ary_fxt fxt = new Db_obj_ary_fxt();
@Test public void Int() {
fxt.Init_fld("fld_0", Type_adp_.Tid__int).Init_fld("fld_1", Type_adp_.Tid__int).Init_vals(1, 10).Init_vals(2, 20).Test_sql("(fld_0=1 AND fld_1=10) OR (fld_0=2 AND fld_1=20)");
fxt.Init_fld("fld_0", Type_ids_.Id__int).Init_fld("fld_1", Type_ids_.Id__int).Init_vals(1, 10).Init_vals(2, 20).Test_sql("(fld_0=1 AND fld_1=10) OR (fld_0=2 AND fld_1=20)");
}
@Test public void Str() {
fxt.Init_fld("fld_0", Type_adp_.Tid__int).Init_fld("fld_1", Type_adp_.Tid__str).Init_vals(1, "a").Init_vals(2, "b").Test_sql("(fld_0=1 AND fld_1='a') OR (fld_0=2 AND fld_1='b')");
fxt.Init_fld("fld_0", Type_ids_.Id__int).Init_fld("fld_1", Type_ids_.Id__str).Init_vals(1, "a").Init_vals(2, "b").Test_sql("(fld_0=1 AND fld_1='a') OR (fld_0=2 AND fld_1='b')");
}
}
class Db_obj_ary_fxt {

View File

@@ -26,19 +26,19 @@ public class Sql_val_wtr {
bfr.Add_str_a7("NULL");
return;
}
int tid_type = Type_adp_.To_tid_type(val.getClass());
int tid_type = Type_ids_.To_id_by_type(val.getClass());
switch (tid_type) {
case Type_adp_.Tid__bool: Bld_val__bool (bfr, Bool_.Cast(val)); break;
case Type_adp_.Tid__byte: Bld_val__byte (bfr, Byte_.cast(val)); break;
case Type_adp_.Tid__short: Bld_val__short (bfr, Short_.cast(val)); break;
case Type_adp_.Tid__int: Bld_val__int (bfr, Int_.cast(val)); break;
case Type_adp_.Tid__long: Bld_val__long (bfr, Long_.cast(val)); break;
case Type_adp_.Tid__float: Bld_val__float (bfr, Float_.cast(val)); break;
case Type_adp_.Tid__double: Bld_val__double (bfr, Double_.cast(val)); break;
case Type_adp_.Tid__decimal: Bld_val__decimal (bfr, Decimal_adp_.cast(val)); break;
case Type_adp_.Tid__str: Bld_val__str (bfr, String_.cast(val)); break;
case Type_adp_.Tid__date: Bld_val__date (bfr, DateAdp_.cast(val)); break;
case Type_adp_.Tid__obj: Bld_val__str (bfr, Object_.Xto_str_strict_or_null(val)); break;
case Type_ids_.Id__bool: Bld_val__bool (bfr, Bool_.Cast(val)); break;
case Type_ids_.Id__byte: Bld_val__byte (bfr, Byte_.cast(val)); break;
case Type_ids_.Id__short: Bld_val__short (bfr, Short_.cast(val)); break;
case Type_ids_.Id__int: Bld_val__int (bfr, Int_.cast(val)); break;
case Type_ids_.Id__long: Bld_val__long (bfr, Long_.cast(val)); break;
case Type_ids_.Id__float: Bld_val__float (bfr, Float_.cast(val)); break;
case Type_ids_.Id__double: Bld_val__double (bfr, Double_.cast(val)); break;
case Type_ids_.Id__decimal: Bld_val__decimal (bfr, Decimal_adp_.cast(val)); break;
case Type_ids_.Id__str: Bld_val__str (bfr, String_.cast(val)); break;
case Type_ids_.Id__date: Bld_val__date (bfr, DateAdp_.cast(val)); break;
case Type_ids_.Id__obj: Bld_val__str (bfr, Object_.Xto_str_strict_or_null(val)); break;
}
}
@gplx.Virtual public void Bld_val__bool (Bry_bfr bfr, boolean val) {bfr.Add_int_digits(1, val ? 1 : 0);} // NOTE: save boolean to 0 or 1 b/c sqlite doesn't support true / false //{bfr.Add_str_a7(val ? "true" : "false");}

View File

@@ -16,8 +16,8 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
package gplx.dbs.sqls.wtrs; import gplx.*; import gplx.dbs.*; import gplx.dbs.sqls.*;
import gplx.core.criterias.*; import gplx.dbs.sqls.itms.*;
public class Sql_where_wtr {
private final Sql_core_wtr qry_wtr;
private final Sql_val_wtr val_wtr;
private final Sql_core_wtr qry_wtr;
private final Sql_val_wtr val_wtr;
public Sql_where_wtr(Sql_core_wtr qry_wtr, Sql_val_wtr val_wtr) {this.qry_wtr = qry_wtr; this.val_wtr = val_wtr;}
public void Bld_where(Bry_bfr bfr, Sql_wtr_ctx ctx, Sql_where_clause where_itm) {
if (where_itm == Sql_where_clause.Where__null) return;
@@ -125,9 +125,9 @@ public class Sql_where_wtr {
Object val = itm[j];
boolean quote = false;
switch (fld.Type_tid()) {
case Type_adp_.Tid__str:
case Type_adp_.Tid__char:
case Type_adp_.Tid__date:
case Type_ids_.Id__str:
case Type_ids_.Id__char:
case Type_ids_.Id__date:
quote = true;
break;
}