1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2024-10-27 20:34:16 +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

@ -70,7 +70,7 @@ public class Array_ {
int len = Len(ary);
for (int i = 0; i < len; i++) {
Object itm = Get_at(ary, i);
if (itm != null && Type_adp_.Is_array(itm.getClass()))
if (itm != null && Type_.Is_array(itm.getClass()))
To_str_nested_ary(bfr, (Object)itm, indent + 1);
else {
if (indent > 0) bfr.Add_byte_repeat(Byte_ascii.Space, indent * 2);

View File

@ -35,11 +35,11 @@ public class Bry_ {
int len = ary.length;
for (int i = 0; i < len; ++i) {
Object itm = ary[i];
Class<?> type = Type_adp_.ClassOf_obj(itm);
if (Type_adp_.Eq(type, int.class)) bfr.Add_byte((byte)Int_.cast(itm));
else if (Type_adp_.Eq(type, String.class)) bfr.Add_str_u8((String)itm);
else if (Type_adp_.Eq(type, byte[].class)) bfr.Add((byte[])itm);
else throw Err_.new_unhandled(Type_adp_.FullNameOf_type(type));
Class<?> type = Type_.Type_by_obj(itm);
if (Type_.Eq(type, int.class)) bfr.Add_byte((byte)Int_.cast(itm));
else if (Type_.Eq(type, String.class)) bfr.Add_str_u8((String)itm);
else if (Type_.Eq(type, byte[].class)) bfr.Add((byte[])itm);
else throw Err_.new_unhandled(Type_.Canonical_name(type));
}
return bfr.To_bry_and_clear();
}

View File

@ -19,25 +19,23 @@ public class Err extends RuntimeException {
private final boolean is_gplx;
private final String trace;
private Err_msg[] msgs_ary = new Err_msg[8]; private int msgs_len = 8, msgs_idx = 0;
public Err(boolean is_gplx, String trace, String type, String msg, Object... args) {
this.is_gplx = is_gplx;
this.trace = is_gplx ? Err_.Trace_lang(this) : trace; // NOTE: Err_ factory methods pass in null stack trace for gplx excs; call Stack_trace here, note that trace will not show constructor
// NOTE: Err_ factory methods pass in null stack trace for gplx excs; call Stack_trace here, note that trace will not show constructor
this.trace = is_gplx ? Err_.Trace_lang(this) : trace;
Msgs_add(type, msg, args);
}
// marks messages logged so they can be ignored; used by Gfh_utl
public boolean Logged() {return logged;} public Err Logged_y_() {logged = true; return this;} private boolean logged;
// ignores current frame for reporting messages
public int Trace_ignore() {return trace_ignore;} public Err Trace_ignore_add_1_() {++trace_ignore; return this;} private int trace_ignore = 0;
public Err Args_add(Object... args) {msgs_ary[msgs_idx - 1].Args_add(args); return this;} // i - 1 to get current
@gplx.Internal protected void Msgs_add(String type, String msg, Object[] args) {
if (msgs_idx == msgs_len) {
int new_len = msgs_len * 2;
Err_msg[] new_ary = new Err_msg[new_len];
Array_.Copy_to(msgs_ary, new_ary, 0);
this.msgs_ary = new_ary;
this.msgs_len = new_len;
}
msgs_ary[msgs_idx] = new Err_msg(type, msg, args);
++msgs_idx;
}
public String To_str__full() {return To_str(Bool_.N, Bool_.Y);}
public String To_str__log() {return To_str(Bool_.Y, Bool_.Y);}
public String To_str__msg_only(){
@ -76,4 +74,16 @@ public class Err extends RuntimeException {
rv += line_bgn_dlm + lines[i];
return rv;
}
@gplx.Internal protected void Msgs_add(String type, String msg, Object[] args) {
if (msgs_idx == msgs_len) {
int new_len = msgs_len * 2;
Err_msg[] new_ary = new Err_msg[new_len];
Array_.Copy_to(msgs_ary, new_ary, 0);
this.msgs_ary = new_ary;
this.msgs_len = new_len;
}
msgs_ary[msgs_idx] = new Err_msg(type, msg, args);
++msgs_idx;
}
}

View File

@ -31,9 +31,10 @@ public class Err_ {
public static Err new_unsupported() {return new Err(Bool_.Y, Trace_null, Type__gplx, "method not supported");}
public static Err new_unimplemented() {return new Err(Bool_.Y, Trace_null, Type__gplx, "method not implemented");}
public static Err new_unimplemented_w_msg(String msg, Object... args) {return new Err(Bool_.Y, Trace_null, Type__gplx, msg, args);}
public static Err new_deprecated(String s) {return new Err(Bool_.Y, Trace_null, Type__gplx, "deprecated", "method", s);}
public static Err new_parse_type(Class<?> c, String raw) {return new_parse(Type_adp_.FullNameOf_type(c), raw);}
public static Err new_parse_exc(Exception e, Class<?> c, String raw) {return new_parse(Type_adp_.FullNameOf_type(c), raw).Args_add("e", Err_.Message_lang(e));}
public static Err new_parse_type(Class<?> c, String raw) {return new_parse(Type_.Canonical_name(c), raw);}
public static Err new_parse_exc(Exception e, Class<?> c, String raw) {return new_parse(Type_.Canonical_name(c), raw).Args_add("e", Err_.Message_lang(e));}
public static Err new_parse(String type, String raw) {return new Err(Bool_.Y, Trace_null, Type__gplx, "parse failed", "type", type, "raw", raw);}
public static Err new_null() {return new Err(Bool_.Y, Trace_null, Type__gplx, "null obj");}
public static Err new_null(String arg) {return new Err(Bool_.Y, Trace_null, Type__gplx, "null obj", "arg", arg);}
@ -43,16 +44,17 @@ public class Err_ {
public static Err new_invalid_arg(String msg, Object... args) {return new Err(Bool_.Y, Trace_null, Type__gplx, msg, args);}
public static Err new_op_canceled() {return new Err(Bool_.Y, Trace_null, Type__op_canceled, "canceled by usr");}
public static Err new_type_mismatch_w_exc(Exception ignore, Class<?> t, Object o) {return new_type_mismatch(t, o);}
public static Err new_type_mismatch(Class<?> t, Object o) {return new Err(Bool_.Y, Trace_null, Type__gplx, "type mismatch", "expdType", Type_adp_.FullNameOf_type(t), "actlType", Type_adp_.NameOf_obj(o), "actlObj", Object_.Xto_str_strict_or_null_mark(o));}
public static Err new_type_mismatch(Class<?> t, Object o) {return new Err(Bool_.Y, Trace_null, Type__gplx, "type mismatch", "expdType", Type_.Canonical_name(t), "actlType", Type_.Name_by_obj(o), "actlObj", Object_.Xto_str_strict_or_null_mark(o));}
public static Err new_cast(Exception ignore, Class<?> t, Object o) {
String o_str = "";
try {o_str = Object_.Xto_str_strict_or_null_mark(o);}
catch (Exception e) {o_str = "<ERROR>"; Err_.Noop(e);}
return new Err(Bool_.Y, Trace_null, Type__gplx, "cast failed", "type", Type_adp_.NameOf_type(t), "obj", o_str);
return new Err(Bool_.Y, Trace_null, Type__gplx, "cast failed", "type", Type_.Name(t), "obj", o_str);
}
public static String Message_gplx_full(Exception e) {return Cast_or_make(e).To_str__full();}
public static String Message_gplx_log(Exception e) {return Cast_or_make(e).To_str__log();}
public static String Message_lang(Throwable e) {
return Error.class.isAssignableFrom(e.getClass())
? e.toString() // error has null for "getMessage()" return "toString()" instead
@ -69,7 +71,7 @@ public class Err_ {
return rv;
}
public static Err Cast_or_null(Exception e) {return Type_adp_.Eq_typeSafe(e, Err.class) ? (Err)e : null;}
public static Err Cast_or_make(Throwable e) {return Type_adp_.Eq_typeSafe(e, Err.class) ? (Err)e : new Err(Bool_.N, Err_.Trace_lang(e), Type_adp_.NameOf_obj(e), Err_.Message_lang(e));}
public static Err Cast_or_null(Exception e) {return Type_.Eq_by_obj(e, Err.class) ? (Err)e : null;}
public static Err Cast_or_make(Throwable e) {return Type_.Eq_by_obj(e, Err.class) ? (Err)e : new Err(Bool_.N, Err_.Trace_lang(e), Type_.Name_by_obj(e), Err_.Message_lang(e));}
public static final String Type__op_canceled = "gplx.op_canceled";
}

View File

@ -256,11 +256,11 @@ interface XtoStrWkr {
class XtoStrWkr_gplx implements XtoStrWkr {
public String To_str(Object o) {
if (o == null) return "<<NULL>>";
Class<?> type = Type_adp_.ClassOf_obj(o);
Class<?> type = Type_.Type_by_obj(o);
String rv = null;
if (type == String.class) rv = String_.cast(o);
else if (Int_.TypeMatch(type)) return Int_.To_str(Int_.cast(o));
else if (Type_adp_.Eq(type, Bool_.Cls_ref_type)) return Yn.To_str(Bool_.Cast(o));
else if (Type_.Eq(type, Bool_.Cls_ref_type)) return Yn.To_str(Bool_.Cast(o));
else if (type == DateAdp.class) return DateAdp_.cast(o).XtoStr_gplx();
else rv = Object_.Xto_str_strict_or_empty(o);
return String_.Replace(rv, "'", "''");

View File

@ -49,7 +49,7 @@ public class Keyval_ {
}
sb.Add(itm.Key()).Add("=");
Object itm_val = itm.Val();
if (Type_adp_.Eq_typeSafe(itm_val, Keyval[].class))
if (Type_.Eq_by_obj(itm_val, Keyval[].class))
sb.Add(Ary_to_str((Keyval[])itm_val));
else
sb.Add(Object_.Xto_str_strict_or_null_mark(itm_val));
@ -81,13 +81,13 @@ public class Keyval_ {
if (val == null)
bfr.Add_str_a7(String_.Null_mark);
else {
Class<?> val_type = Type_adp_.ClassOf_obj(val);
if (Type_adp_.Eq(val_type, Keyval[].class)) { // val is Keyval[]; recurse
Class<?> val_type = Type_.Type_by_obj(val);
if (Type_.Eq(val_type, Keyval[].class)) { // val is Keyval[]; recurse
bfr.Add_byte_nl(); // add nl : "\n"
Ary__to_str__nest(bfr, indent + 1, (Keyval[])val);
continue; // don't add \n below
}
else if (Type_adp_.Eq(val_type, Bool_.Cls_ref_type)) { // val is boolean
else if (Type_.Eq(val_type, Bool_.Cls_ref_type)) { // val is boolean
boolean val_as_bool = Bool_.Cast(val);
bfr.Add(val_as_bool ? Bool_.True_bry : Bool_.False_bry); // add "true" or "false"; don't call toString
}
@ -98,8 +98,8 @@ public class Keyval_ {
}
}
public static Keyval as_(Object obj) {return obj instanceof Keyval ? (Keyval)obj : null;}
public static Keyval new_(String key) {return new Keyval(Type_adp_.Tid__str, key, key);}
public static Keyval new_(String key, Object val) {return new Keyval(Type_adp_.Tid__str, key, val);}
public static Keyval int_(int key, Object val) {return new Keyval(Type_adp_.Tid__int, key, val);}
public static Keyval obj_(Object key, Object val) {return new Keyval(Type_adp_.Tid__obj, key, val);}
public static Keyval new_(String key) {return new Keyval(Type_ids_.Id__str, key, key);}
public static Keyval new_(String key, Object val) {return new Keyval(Type_ids_.Id__str, key, val);}
public static Keyval int_(int key, Object val) {return new Keyval(Type_ids_.Id__int, key, val);}
public static Keyval obj_(Object key, Object val) {return new Keyval(Type_ids_.Id__obj, key, val);}
}

View File

@ -41,17 +41,17 @@ public class Object_ {
public static String Xto_str_strict_or_empty(Object v) {return v == null ? String_.Empty : ToString_lang(v);}
private static String ToString_lang(Object v) {
Class<?> c = v.getClass();
if (Type_adp_.Eq(c, String_.Cls_ref_type)) return (String)v;
else if (Type_adp_.Eq(c, Bry_.Cls_ref_type)) return String_.new_u8((byte[])v);
if (Type_.Eq(c, String_.Cls_ref_type)) return (String)v;
else if (Type_.Eq(c, Bry_.Cls_ref_type)) return String_.new_u8((byte[])v);
else return v.toString();
}
public static String Xto_str_loose_or(Object v, String or) { // tries to pretty-print doubles; also standardizes true/false; DATE:2014-07-14
if (v == null) return null;
Class<?> c = Type_adp_.ClassOf_obj(v);
if (Type_adp_.Eq(c, String_.Cls_ref_type)) return (String)v;
else if (Type_adp_.Eq(c, Bry_.Cls_ref_type)) return String_.new_u8((byte[])v);
else if (Type_adp_.Eq(c, Bool_.Cls_ref_type)) return Bool_.Cast(v) ? Bool_.True_str : Bool_.False_str; // always return "true" / "false"
else if (Type_adp_.Eq(c, Double_.Cls_ref_type)) return Double_.To_str_loose(Double_.cast(v));
Class<?> c = Type_.Type_by_obj(v);
if (Type_.Eq(c, String_.Cls_ref_type)) return (String)v;
else if (Type_.Eq(c, Bry_.Cls_ref_type)) return String_.new_u8((byte[])v);
else if (Type_.Eq(c, Bool_.Cls_ref_type)) return Bool_.Cast(v) ? Bool_.True_str : Bool_.False_str; // always return "true" / "false"
else if (Type_.Eq(c, Double_.Cls_ref_type)) return Double_.To_str_loose(Double_.cast(v));
else return v.toString();
}
public static final Object Null = null;

View File

@ -128,8 +128,8 @@ public class Tfds { // URL:doc/gplx.tfds/Tfds.txt
list.Add(itm);
}
public static void Err_classMatch(Exception exc, Class<?> type) {
boolean match = Type_adp_.Eq_typeSafe(exc, type);
if (!match) throw Err_.new_("Tfds", "error types do not match", "expdType", Type_adp_.FullNameOf_type(type), "actlType", Type_adp_.NameOf_obj(exc), "actlMsg", Err_.Message_lang(exc));
boolean match = Type_.Eq_by_obj(exc, type);
if (!match) throw Err_.new_("Tfds", "error types do not match", "expdType", Type_.Canonical_name(type), "actlType", Type_.Name_by_obj(exc), "actlMsg", Err_.Message_lang(exc));
}
public static void Eq_err(Err expd, Exception actlExc) {
Tfds.Eq(Err_.Message_gplx_full(expd), Err_.Message_gplx_full(actlExc));

View File

@ -0,0 +1,56 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
public class Type_ {
public static Class<?> Type_by_obj(Object o) {return o.getClass();}
public static Class<?> Type_by_primitive(Object o) {
Class<?> rv = o.getClass();
if (rv == Integer.class) rv = int.class;
else if (rv == Long.class) rv = long.class;
else if (rv == Byte.class) rv = byte.class;
else if (rv == Short.class) rv = short.class;
return rv;
}
public static boolean Eq_by_obj(Object lhs_obj, Class<?> rhs_type) {
Class<?> lhs_type = lhs_obj == null ? null : lhs_obj.getClass();
return Type_.Eq(lhs_type, rhs_type);
}
public static boolean Eq(Class<?> lhs, Class<?> rhs) {// DUPE_FOR_TRACKING: same as Object_.Eq
if (lhs == null && rhs == null) return true;
else if (lhs == null || rhs == null) return false;
else return lhs.equals(rhs);
}
public static String Canonical_name_by_obj(Object o) {return Canonical_name(o.getClass());}
public static String Canonical_name(Class<?> type) {
return type.getCanonicalName();
}
public static String Name_by_obj(Object obj) {return obj == null ? String_.Null_mark : Name(Type_by_obj(obj));}
public static String Name(Class<?> type) {
return type.getName();
}
public static boolean Is_array(Class<?> t) {
return t.isArray();
}
public static boolean Is_assignable_from_by_obj(Object o, Class<?> generic) {return o == null ? false : Is_assignable_from(generic, o.getClass());}
public static boolean Is_assignable_from(Class<?> generic, Class<?> specific) {
return generic.isAssignableFrom(specific);
}
}

View File

@ -1,94 +0,0 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
public class Type_adp_ {
public static boolean Eq(Class<?> lhs, Class<?> rhs) {
if (lhs == null && rhs == null) return true;
else if (lhs == null || rhs == null) return false;
else return lhs.equals(rhs);
}
public static boolean Eq_typeSafe(Object o, Class<?> expd) {if (o == null) return false;
Class<?> actl = o.getClass();
return Object_.Eq(expd, actl);
}
public static boolean IsAssignableFrom(Class<?> lhs, Class<?> rhs) {return lhs.isAssignableFrom(rhs);}
public static boolean Implements_intf_obj(Object cur, Class<?> type) {return cur == null ? false : IsAssignableFrom(type, cur.getClass());}
public static boolean Is_array(Class<?> t) {return t.isArray();}
public static Class<?> ClassOf_obj(Object o) {return o.getClass();}
public static Class<?> ClassOf_primitive(Object o) {
Class<?> rv = o.getClass();
if (rv == Integer.class) rv = int.class;
else if (rv == Long.class) rv = long.class;
else if (rv == Byte.class) rv = byte.class;
else if (rv == Short.class) rv = short.class;
return rv;
}
public static String FullNameOf_obj(Object o) {return FullNameOf_type(o.getClass());}
public static String FullNameOf_type(Class<?> type) {return type.getCanonicalName();}
public static String NameOf_type(Class<?> type) {return type.getName();}
public static String NameOf_obj(Object obj) {return obj == null ? String_.Null_mark : obj.getClass().getName();}
public static int To_tid_obj(Object o) {
if (o == null) return Tid__null;
Class<?> type = o.getClass();
return To_tid_type(type);
}
public static int To_tid_type(Class<?> type) {
if (Type_adp_.Eq(type, Int_.Cls_ref_type)) return Tid__int;
else if (Type_adp_.Eq(type, String_.Cls_ref_type)) return Tid__str;
else if (Type_adp_.Eq(type, byte[].class)) return Tid__bry;
else if (Type_adp_.Eq(type, Bool_.Cls_ref_type)) return Tid__bool;
else if (Type_adp_.Eq(type, Byte_.Cls_ref_type)) return Tid__byte;
else if (Type_adp_.Eq(type, Long_.Cls_ref_type)) return Tid__long;
else if (Type_adp_.Eq(type, Double_.Cls_ref_type)) return Tid__double;
else if (Type_adp_.Eq(type, Decimal_adp_.Cls_ref_type)) return Tid__decimal;
else if (Type_adp_.Eq(type, DateAdp_.Cls_ref_type)) return Tid__date;
else if (Type_adp_.Eq(type, Float_.Cls_ref_type)) return Tid__float;
else if (Type_adp_.Eq(type, Short_.Cls_ref_type)) return Tid__short;
else if (Type_adp_.Eq(type, Char_.Cls_ref_type)) return Tid__char;
else return Tid__obj;
}
public static int To_tid(String name) {
if (String_.Eq(name, Int_.Cls_val_name)) return Tid__int;
else if (String_.Eq(name, String_.Cls_val_name)) return Tid__str;
else if (String_.Eq(name, Bry_.Cls_val_name)) return Tid__bry;
else if (String_.Eq(name, Bool_.Cls_val_name)) return Tid__bool;
else if (String_.Eq(name, Byte_.Cls_val_name)) return Tid__byte;
else if (String_.Eq(name, Long_.Cls_val_name)) return Tid__long;
else if (String_.Eq(name, Double_.Cls_val_name)) return Tid__double;
else if (String_.Eq(name, Decimal_adp_.Cls_val_name)) return Tid__decimal;
else if (String_.Eq(name, DateAdp_.Cls_ref_name)) return Tid__date;
else if (String_.Eq(name, Float_.Cls_val_name)) return Tid__float;
else if (String_.Eq(name, Short_.Cls_val_name)) return Tid__short;
else if (String_.Eq(name, Char_.Cls_val_name)) return Tid__char;
else return Tid__obj;
}
public static final int
Tid__obj = 0
, Tid__null = 1
, Tid__bool = 2
, Tid__byte = 3
, Tid__short = 4
, Tid__int = 5
, Tid__long = 6
, Tid__float = 7
, Tid__double = 8
, Tid__char = 9
, Tid__str = 10
, Tid__bry = 11
, Tid__date = 12
, Tid__decimal = 13
;
}

View File

@ -0,0 +1,56 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx;
public class Type_ids_ {
public static final int // SERIALIZABLE.N
Id__obj = 0
, Id__null = 1
, Id__bool = 2
, Id__byte = 3
, Id__short = 4
, Id__int = 5
, Id__long = 6
, Id__float = 7
, Id__double = 8
, Id__char = 9
, Id__str = 10
, Id__bry = 11
, Id__date = 12
, Id__decimal = 13
;
public static int To_id_by_obj(Object o) {
if (o == null) return Type_ids_.Id__null;
Class<?> type = o.getClass();
return Type_ids_.To_id_by_type(type);
}
public static int To_id_by_type(Class<?> type) {
if (Type_.Eq(type, Int_.Cls_ref_type)) return Id__int;
else if (Type_.Eq(type, String_.Cls_ref_type)) return Id__str;
else if (Type_.Eq(type, byte[].class)) return Id__bry;
else if (Type_.Eq(type, Bool_.Cls_ref_type)) return Id__bool;
else if (Type_.Eq(type, Byte_.Cls_ref_type)) return Id__byte;
else if (Type_.Eq(type, Long_.Cls_ref_type)) return Id__long;
else if (Type_.Eq(type, Double_.Cls_ref_type)) return Id__double;
else if (Type_.Eq(type, Decimal_adp_.Cls_ref_type)) return Id__decimal;
else if (Type_.Eq(type, DateAdp_.Cls_ref_type)) return Id__date;
else if (Type_.Eq(type, Float_.Cls_ref_type)) return Id__float;
else if (Type_.Eq(type, Short_.Cls_ref_type)) return Id__short;
else if (Type_.Eq(type, Char_.Cls_ref_type)) return Id__char;
else return Id__obj;
}
}

View File

@ -22,8 +22,8 @@ public class Criteria_eq implements Criteria {
public void Val_as_obj_(Object v) {this.val = v;}
public void Val_from_args(Hash_adp args) {throw Err_.new_unimplemented();}
public boolean Matches(Object comp) {
Class<?> val_type = Type_adp_.ClassOf_obj(val);
if (!Type_adp_.Eq_typeSafe(comp, val_type)) throw Err_.new_type_mismatch(val_type, comp);
Class<?> val_type = Type_.Type_by_obj(val);
if (!Type_.Eq_by_obj(comp, val_type)) throw Err_.new_type_mismatch(val_type, comp);
boolean rv = Object_.Eq(val, comp);
return neg ? !rv : rv;
}

View File

@ -24,13 +24,13 @@ public class Criteria_in implements Criteria {
private void Ary_(Object[] v) {
this.ary = v;
this.ary_len = ary.length;
this.itm_type = ary_len == 0 ? Object.class : Type_adp_.ClassOf_obj(ary[0]);
this.itm_type = ary_len == 0 ? Object.class : Type_.Type_by_obj(ary[0]);
}
public void Val_as_obj_(Object v) {Ary_((Object[])v);}
public void Val_from_args(Hash_adp args) {throw Err_.new_unimplemented();}
public boolean Matches(Object comp) {
if (ary_len == 0) return false; // empty array never matches
if (!Type_adp_.Eq_typeSafe(comp, itm_type)) throw Err_.new_type_mismatch(itm_type, comp);
if (!Type_.Eq_by_obj(comp, itm_type)) throw Err_.new_type_mismatch(itm_type, comp);
boolean rv = false;
for (int i = 0; i < ary_len; ++i) {
Object val = ary[i];

View File

@ -445,7 +445,7 @@ public class IoEngine_system extends IoEngine_base {
try {closeable.close();}
catch (IOException e) {
if (throwErr)
throw Err_.new_exc(e, "io", "close object failed", "class", Type_adp_.NameOf_obj(closeable), "url", url_str);
throw Err_.new_exc(e, "io", "close object failed", "class", Type_.Name_by_obj(closeable), "url", url_str);
// else
// UsrDlg_._.Finally("failed to close FileChannel", "url", url, "apiErr", Err_.Message_err_arg(e));
}
@ -522,8 +522,8 @@ public class IoEngine_system extends IoEngine_base {
}
catch (Exception exc) {
xrg.Rslt_err_(exc);
if (Type_adp_.Eq_typeSafe(exc, java.net.UnknownHostException.class)) xrg.Rslt_(IoEngine_xrg_downloadFil.Rslt_fail_host_not_found);
else if (Type_adp_.Eq_typeSafe(exc, java.io.FileNotFoundException.class)) xrg.Rslt_(IoEngine_xrg_downloadFil.Rslt_fail_file_not_found);
if (Type_.Eq_by_obj(exc, java.net.UnknownHostException.class)) xrg.Rslt_(IoEngine_xrg_downloadFil.Rslt_fail_host_not_found);
else if (Type_.Eq_by_obj(exc, java.io.FileNotFoundException.class)) xrg.Rslt_(IoEngine_xrg_downloadFil.Rslt_fail_file_not_found);
else xrg.Rslt_(IoEngine_xrg_downloadFil.Rslt_fail_unknown);
if (prog_dlg != null && !xrg.Prog_cancel()) {
if (session_fil == null) session_fil = prog_dlg.Log_wkr().Session_dir().GenSubFil("internet.txt");
@ -726,8 +726,8 @@ class Io_stream_rdr_http implements Io_stream_rdr {
read_done = read_failed = true;
len = -1;
xrg.Rslt_err_(exc);
if (Type_adp_.Eq_typeSafe(exc, java.net.UnknownHostException.class)) xrg.Rslt_(IoEngine_xrg_downloadFil.Rslt_fail_host_not_found);
else if (Type_adp_.Eq_typeSafe(exc, java.io.FileNotFoundException.class)) xrg.Rslt_(IoEngine_xrg_downloadFil.Rslt_fail_file_not_found);
if (Type_.Eq_by_obj(exc, java.net.UnknownHostException.class)) xrg.Rslt_(IoEngine_xrg_downloadFil.Rslt_fail_host_not_found);
else if (Type_.Eq_by_obj(exc, java.io.FileNotFoundException.class)) xrg.Rslt_(IoEngine_xrg_downloadFil.Rslt_fail_file_not_found);
else xrg.Rslt_(IoEngine_xrg_downloadFil.Rslt_fail_unknown);
if (prog_dlg != null && !xrg.Prog_cancel()) {
if (session_fil == null) session_fil = prog_dlg.Log_wkr().Session_dir().GenSubFil("internet.txt");

View File

@ -42,9 +42,9 @@ public class Js_wtr {
Object itm = ary[i];
if (i != 0) bfr.Add_byte(Byte_ascii.Comma);
boolean val_needs_quotes = true;
if ( Type_adp_.Eq_typeSafe(itm, Bool_.Cls_ref_type)
|| Type_adp_.Eq_typeSafe(itm, Int_.Cls_ref_type)
|| Type_adp_.Eq_typeSafe(itm, Long_.Cls_ref_type)
if ( Type_.Eq_by_obj(itm, Bool_.Cls_ref_type)
|| Type_.Eq_by_obj(itm, Int_.Cls_ref_type)
|| Type_.Eq_by_obj(itm, Long_.Cls_ref_type)
) {
val_needs_quotes = false;
}

View File

@ -17,20 +17,20 @@ package gplx.core.tests; import gplx.*; import gplx.core.*;
import gplx.core.brys.*;
public class Gftest {
private static final Bry_bfr bfr = Bry_bfr_.New();
public static void Eq__ary(boolean[] expd, boolean[] actl, String msg_fmt, Object... msg_args) {Eq__array(Type_adp_.Tid__bool, expd, actl, msg_fmt, msg_args);}
public static void Eq__ary(int[] expd, int[] actl, String msg_fmt, Object... msg_args) {Eq__array(Type_adp_.Tid__int, expd, actl, msg_fmt, msg_args);}
public static void Eq__ary(long[] expd, long[] actl, String msg_fmt, Object... msg_args) {Eq__array(Type_adp_.Tid__long, expd, actl, msg_fmt, msg_args);}
public static void Eq__ary(byte[] expd, byte[] actl, String msg_fmt, Object... msg_args) {Eq__array(Type_adp_.Tid__byte, expd, actl, msg_fmt, msg_args);}
public static void Eq__ary(boolean[] expd, boolean[] actl, String msg_fmt, Object... msg_args) {Eq__array(Type_ids_.Id__bool, expd, actl, msg_fmt, msg_args);}
public static void Eq__ary(int[] expd, int[] actl, String msg_fmt, Object... msg_args) {Eq__array(Type_ids_.Id__int, expd, actl, msg_fmt, msg_args);}
public static void Eq__ary(long[] expd, long[] actl, String msg_fmt, Object... msg_args) {Eq__array(Type_ids_.Id__long, expd, actl, msg_fmt, msg_args);}
public static void Eq__ary(byte[] expd, byte[] actl, String msg_fmt, Object... msg_args) {Eq__array(Type_ids_.Id__byte, expd, actl, msg_fmt, msg_args);}
public static void Eq__ary__lines(String expd, byte[] actl) {Eq__ary__lines(expd, String_.new_u8(actl), "no_msg");}
public static void Eq__ary__lines(String expd, byte[] actl, String msg_fmt, Object... msg_args) {Eq__ary__lines(expd, String_.new_u8(actl), msg_fmt, msg_args);}
public static void Eq__ary__lines(String expd, String actl, String msg_fmt, Object... msg_args) {Eq__array(Type_adp_.Tid__bry, Bry_split_.Split_lines(Bry_.new_u8_safe(expd)), Bry_split_.Split_lines(Bry_.new_u8_safe(actl)), msg_fmt, msg_args);}
public static void Eq__ary(String[] expd, String[] actl) {Eq__array(Type_adp_.Tid__bry, Bry_.Ary(expd), Bry_.Ary(actl), "no_msg");}
public static void Eq__ary(String[] expd, String[] actl, String msg_fmt, Object... msg_args) {Eq__array(Type_adp_.Tid__bry, Bry_.Ary(expd), Bry_.Ary(actl), msg_fmt, msg_args);}
public static void Eq__ary(String[] expd, byte[][] actl, String msg_fmt, Object... msg_args) {Eq__array(Type_adp_.Tid__bry, Bry_.Ary(expd), actl, msg_fmt, msg_args);}
public static void Eq__ary(byte[][] expd, byte[][] actl, String msg_fmt, Object... msg_args) {Eq__array(Type_adp_.Tid__bry, expd, actl, msg_fmt, msg_args);}
public static void Eq__ary__lines(String expd, String actl, String msg_fmt, Object... msg_args) {Eq__array(Type_ids_.Id__bry, Bry_split_.Split_lines(Bry_.new_u8_safe(expd)), Bry_split_.Split_lines(Bry_.new_u8_safe(actl)), msg_fmt, msg_args);}
public static void Eq__ary(String[] expd, String[] actl) {Eq__array(Type_ids_.Id__bry, Bry_.Ary(expd), Bry_.Ary(actl), "no_msg");}
public static void Eq__ary(String[] expd, String[] actl, String msg_fmt, Object... msg_args) {Eq__array(Type_ids_.Id__bry, Bry_.Ary(expd), Bry_.Ary(actl), msg_fmt, msg_args);}
public static void Eq__ary(String[] expd, byte[][] actl, String msg_fmt, Object... msg_args) {Eq__array(Type_ids_.Id__bry, Bry_.Ary(expd), actl, msg_fmt, msg_args);}
public static void Eq__ary(byte[][] expd, byte[][] actl, String msg_fmt, Object... msg_args) {Eq__array(Type_ids_.Id__bry, expd, actl, msg_fmt, msg_args);}
public static void Eq__ary(Bry_bfr_able[] expd_ary, Bry_bfr_able[] actl_ary) {Eq__ary(expd_ary, actl_ary, null);}
public static void Eq__ary(Bry_bfr_able[] expd_ary, Bry_bfr_able[] actl_ary, String msg_fmt, Object... msg_args) {
Eq__array(Type_adp_.Tid__bry, Bry_bfr_able_.To_bry_ary(bfr, expd_ary), Bry_bfr_able_.To_bry_ary(bfr, actl_ary), msg_fmt, msg_args);
Eq__array(Type_ids_.Id__bry, Bry_bfr_able_.To_bry_ary(bfr, expd_ary), Bry_bfr_able_.To_bry_ary(bfr, actl_ary), msg_fmt, msg_args);
}
private static void Eq__array(int type_tid, Object expd_ary, Object actl_ary, String msg_fmt, Object... msg_args) {
boolean[] failures = Calc__failures(type_tid, expd_ary, actl_ary);
@ -151,11 +151,11 @@ public class Gftest {
private static void Write__itm(Bry_bfr bfr, int type_id, Object ary, int len, int idx) {
if (idx < len) {
switch (type_id) {
case Type_adp_.Tid__bool: bfr.Add_yn(Bool_.Cast(Array_.Get_at(ary, idx))); break;
case Type_adp_.Tid__bry: bfr.Add_safe((byte[])Array_.Get_at(ary, idx)); break;
case Type_adp_.Tid__long: bfr.Add_long_variable(Long_.cast(Array_.Get_at(ary, idx))); break;
case Type_adp_.Tid__int: bfr.Add_int_variable(Int_.cast(Array_.Get_at(ary, idx))); break;
case Type_adp_.Tid__byte: bfr.Add_int_variable((int)(Byte_.cast(Array_.Get_at(ary, idx)))); break;
case Type_ids_.Id__bool: bfr.Add_yn(Bool_.Cast(Array_.Get_at(ary, idx))); break;
case Type_ids_.Id__bry: bfr.Add_safe((byte[])Array_.Get_at(ary, idx)); break;
case Type_ids_.Id__long: bfr.Add_long_variable(Long_.cast(Array_.Get_at(ary, idx))); break;
case Type_ids_.Id__int: bfr.Add_int_variable(Int_.cast(Array_.Get_at(ary, idx))); break;
case Type_ids_.Id__byte: bfr.Add_int_variable((int)(Byte_.cast(Array_.Get_at(ary, idx)))); break;
default: throw Err_.new_unhandled_default(type_id);
}
}
@ -176,11 +176,11 @@ public class Gftest {
else if (expd_obj == null || actl_obj == null) eq = false;
else {
switch (tid) {
case Type_adp_.Tid__bool: eq = Bool_.Cast(expd_obj) == Bool_.Cast(actl_obj); break;
case Type_adp_.Tid__bry: eq = Bry_.Eq((byte[])expd_obj, (byte[])actl_obj); break;
case Type_adp_.Tid__long: eq = Long_.cast(expd_obj) == Long_.cast(actl_obj); break;
case Type_adp_.Tid__int: eq = Int_.cast(expd_obj) == Int_.cast(actl_obj); break;
case Type_adp_.Tid__byte: eq = Byte_.cast(expd_obj) == Byte_.cast(actl_obj); break;
case Type_ids_.Id__bool: eq = Bool_.Cast(expd_obj) == Bool_.Cast(actl_obj); break;
case Type_ids_.Id__bry: eq = Bry_.Eq((byte[])expd_obj, (byte[])actl_obj); break;
case Type_ids_.Id__long: eq = Long_.cast(expd_obj) == Long_.cast(actl_obj); break;
case Type_ids_.Id__int: eq = Int_.cast(expd_obj) == Int_.cast(actl_obj); break;
case Type_ids_.Id__byte: eq = Byte_.cast(expd_obj) == Byte_.cast(actl_obj); break;
}
}
if (!eq) {

View File

@ -20,7 +20,7 @@ public abstract class ClassXtn_base {
@gplx.Virtual public Object XtoDb(Object obj) {return obj;}
@gplx.Virtual public String XtoUi(Object obj, String fmt) {return Object_.Xto_str_strict_or_null_mark(obj);}
@gplx.Virtual public boolean MatchesClass(Object obj) {if (obj == null) throw Err_.new_null();
return Type_adp_.Eq_typeSafe(obj, UnderClass());
return Type_.Eq_by_obj(obj, UnderClass());
}
@gplx.Virtual public int compareTo(Object lhs, Object rhs) {return CompareAble_.Compare_obj(lhs, rhs);}
}

View File

@ -23,10 +23,10 @@ public class GfsCore_ {
if (rv == Gfo_invk_.Rv_cancel) return rv;
else if (rv == Gfo_invk_.Rv_unhandled) {
if (ctx.Fail_if_unhandled())
throw Err_.new_wo_type("Object does not support key", "key", owner_msg.Key(), "ownerType", Type_adp_.FullNameOf_obj(owner_invk));
throw Err_.new_wo_type("Object does not support key", "key", owner_msg.Key(), "ownerType", Type_.Canonical_name_by_obj(owner_invk));
else {
Gfo_usr_dlg usr_dlg = ctx.Usr_dlg();
if (usr_dlg != null) usr_dlg.Warn_many(GRP_KEY, "unhandled_key", "Object does not support key: key=~{0} ownerType=~{1}", owner_msg.Key(), Type_adp_.FullNameOf_obj(owner_invk));
if (usr_dlg != null) usr_dlg.Warn_many(GRP_KEY, "unhandled_key", "Object does not support key: key=~{0} ownerType=~{1}", owner_msg.Key(), Type_.Canonical_name_by_obj(owner_invk));
return Gfo_invk_.Noop;
}
}
@ -42,7 +42,7 @@ public class GfsCore_ {
Gfo_invk invk = Gfo_invk_.as_(rv);
Object primitive = null;
if (invk == null) { // rv is primitive; find appropriate mgr
throw Err_.new_wo_type("unknown primitive", "type", Type_adp_.NameOf_type(rv.getClass()), "obj", Object_.Xto_str_strict_or_null_mark(rv));
throw Err_.new_wo_type("unknown primitive", "type", Type_.Name(rv.getClass()), "obj", Object_.Xto_str_strict_or_null_mark(rv));
}
Object exec_rv = null;
int len = owner_msg.Subs_count();

View File

@ -20,7 +20,7 @@ class GfsRegy implements Gfo_invk {
public boolean Has(String k) {return hash.Has(k);}
public GfsRegyItm Get_at(int i) {return (GfsRegyItm)hash.Get_at(i);}
public GfsRegyItm Get_by(String key) {return (GfsRegyItm)hash.Get_by(key);}
public GfsRegyItm FetchByType(Gfo_invk invk) {return (GfsRegyItm)typeHash.Get_by(Type_adp_.FullNameOf_obj(invk));}
public GfsRegyItm FetchByType(Gfo_invk invk) {return (GfsRegyItm)typeHash.Get_by(Type_.Canonical_name_by_obj(invk));}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
Object rv = (GfsRegyItm)hash.Get_by(k); if (rv == null) throw Err_.new_missing_key(k);
return rv;
@ -29,7 +29,7 @@ class GfsRegy implements Gfo_invk {
public void AddCmd(Gfo_invk invk, String key) {Add(key, invk, true);}
public void Add(String key, Gfo_invk invk, boolean typeCmd) {
if (hash.Has(key)) return;
GfsRegyItm regyItm = new GfsRegyItm().Key_(key).InvkAble_(invk).IsCmd_(typeCmd).TypeKey_(Type_adp_.FullNameOf_obj(invk));
GfsRegyItm regyItm = new GfsRegyItm().Key_(key).InvkAble_(invk).IsCmd_(typeCmd).TypeKey_(Type_.Canonical_name_by_obj(invk));
hash.Add(key, regyItm);
typeHash.Add_if_dupe_use_1st(regyItm.TypeKey(), regyItm); // NOTE: changed to allow same Object to be added under different aliases (app, xowa) DATE:2014-06-09;
}

View File

@ -33,7 +33,7 @@ class GfmlPragmaLxrFrm implements GfmlPragma {
bldr.Doc().RootLxr().SubLxr_Add(lxr); // FIXME: always add to cur lxr; should be outside if block; also, auto_add=n to skip adding to rootLxr
}
else {
GfmlLxr_frame frameLxr = GfmlLxr_frame.as_(lxr); if (frameLxr == null) throw Err_.new_wo_type("lxr is not GfmlLxr_frame", "key", key, "type", Type_adp_.NameOf_obj(lxr));
GfmlLxr_frame frameLxr = GfmlLxr_frame.as_(lxr); if (frameLxr == null) throw Err_.new_wo_type("lxr is not GfmlLxr_frame", "key", key, "type", Type_.Name_by_obj(lxr));
if (type != null) {
// frame = frameLxr.Frame.MakeNew(frameLxr);
}

View File

@ -66,7 +66,7 @@ public class DbMaprWtr extends DataWtr_base implements DataWtr {
}
void WriteDataVal(String fld, Object val) {
if (insertCmd == null) insertCmd = Db_qry_.insert_(curTableName);
if (Type_adp_.Eq_typeSafe(val, String.class))
if (Type_.Eq_by_obj(val, String.class))
insertCmd.Val_obj_type(fld, val, Db_val_type.Tid_varchar);
else
insertCmd.Val_obj(fld, val);

View File

@ -58,16 +58,16 @@ public class Db_stmt_ {
}
public static Db_stmt Rls(Db_stmt v) {if (v != null) v.Rls(); return null;}
public static void Val_by_obj(Db_stmt stmt, String key, Object val) {
int tid = Type_adp_.To_tid_obj(val);
int tid = Type_ids_.To_id_by_obj(val);
switch (tid) {
case Type_adp_.Tid__bool: stmt.Val_bool_as_byte (key, Bool_.Cast(val)); break;
case Type_adp_.Tid__byte: stmt.Val_byte (key, Byte_.cast(val)); break;
case Type_adp_.Tid__int: stmt.Val_int (key, Int_.cast(val)); break;
case Type_adp_.Tid__long: stmt.Val_long (key, Long_.cast(val)); break;
case Type_adp_.Tid__float: stmt.Val_float (key, Float_.cast(val)); break;
case Type_adp_.Tid__double: stmt.Val_double (key, Double_.cast(val)); break;
case Type_adp_.Tid__str: stmt.Val_str (key, String_.cast(val)); break;
case Type_adp_.Tid__bry: stmt.Val_bry (key, Bry_.cast(val)); break;
case Type_ids_.Id__bool: stmt.Val_bool_as_byte (key, Bool_.Cast(val)); break;
case Type_ids_.Id__byte: stmt.Val_byte (key, Byte_.cast(val)); break;
case Type_ids_.Id__int: stmt.Val_int (key, Int_.cast(val)); break;
case Type_ids_.Id__long: stmt.Val_long (key, Long_.cast(val)); break;
case Type_ids_.Id__float: stmt.Val_float (key, Float_.cast(val)); break;
case Type_ids_.Id__double: stmt.Val_double (key, Double_.cast(val)); break;
case Type_ids_.Id__str: stmt.Val_str (key, String_.cast(val)); break;
case Type_ids_.Id__bry: stmt.Val_bry (key, Bry_.cast(val)); break;
default: throw Err_.new_unhandled_default(tid);
}
}

View File

@ -53,7 +53,7 @@ public class TdbTable {
flds = ndeRdr.UnderNde().SubFlds();
}
else { // XmlRdr needs to load each row again...
throw Err_.new_invalid_op("TableLoad not implemented").Args_add("rdrType", Type_adp_.NameOf_obj(rdr), "rdrName", rdr.NameOfNode());
throw Err_.new_invalid_op("TableLoad not implemented").Args_add("rdrType", Type_.Name_by_obj(rdr), "rdrName", rdr.NameOfNode());
}
isLoaded = true;
}

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;

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

@ -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;
}

View File

@ -106,9 +106,9 @@ public class Swt_html implements Gxw_html, Swt_control, FocusListener, Gfo_evt_m
Object arg = args[i];
if (i != 0) bfr.Add_byte(Byte_ascii.Comma);
boolean quote_val = true;
if ( Type_adp_.Eq_typeSafe(arg, Bool_.Cls_ref_type)
|| Type_adp_.Eq_typeSafe(arg, Int_.Cls_ref_type)
|| Type_adp_.Eq_typeSafe(arg, Long_.Cls_ref_type)
if ( Type_.Eq_by_obj(arg, Bool_.Cls_ref_type)
|| Type_.Eq_by_obj(arg, Int_.Cls_ref_type)
|| Type_.Eq_by_obj(arg, Long_.Cls_ref_type)
) {
quote_val = false;
}

View File

@ -66,13 +66,13 @@ public class Gfobj_wtr__json {
Object[] ary_obj = ((Gfobj_ary)ary).Ary_obj();
for (int i = 0; i < len; ++i) {
Object sub_itm = ary_obj[i];
Class<?> sub_itm_type = Type_adp_.ClassOf_obj(sub_itm);
if (Type_adp_.Eq(sub_itm_type, Gfobj_ary.class)) {
Class<?> sub_itm_type = Type_.Type_by_obj(sub_itm);
if (Type_.Eq(sub_itm_type, Gfobj_ary.class)) {
wtr.Ary_bgn_ary();
Write_ary((Gfobj_ary)sub_itm);
wtr.Ary_end();
}
else if (Type_adp_.Eq(sub_itm_type, Gfobj_nde.class)) {
else if (Type_.Eq(sub_itm_type, Gfobj_nde.class)) {
wtr.Nde_bgn_ary();
Write_nde((Gfobj_nde)sub_itm);
wtr.Nde_end();

View File

@ -21,7 +21,7 @@ public interface Tst_chkr {
class Tst_chkr_null implements Tst_chkr {
public Class<?> TypeOf() {return Object.class;}
public int Chk(Tst_mgr mgr, String path, Object actl) {
mgr.Results().Add(Tst_itm.fail_("!=", path, "<cast type>", "<NULL TYPE>", Type_adp_.NameOf_obj(actl)));
mgr.Results().Add(Tst_itm.fail_("!=", path, "<cast type>", "<NULL TYPE>", Type_.Name_by_obj(actl)));
// mgr.Results().Add(Tst_itm.fail_("!=", path, "<cast value>", "<NULL VAL>", Object_.Xto_str_strict_or_null(actl)));
return 1;
}

View File

@ -52,7 +52,7 @@ public class Tst_mgr {
String path = ownerPath + Int_.To_str(i);
Tst_chkr expd_obj = i < expd_ary_len ? expd_ary[i] : Tst_mgr.Null_chkr;
Object actl_obj = i < actl_ary_len ? actl_ary[i] : "<NULL OBJ>";
String actl_type = i < actl_ary_len ? Type_adp_.NameOf_obj(actl_obj) : "<NULL TYPE>";
String actl_type = i < actl_ary_len ? Type_.Name_by_obj(actl_obj) : "<NULL TYPE>";
err += Tst_inner(expd_obj, actl_obj, actl_type, path, err);
}
if (throwError && err > 0) {
@ -61,15 +61,15 @@ public class Tst_mgr {
}
}
public int Tst_sub_obj(Tst_chkr expd, Object actl, String path, int err) {
return Tst_inner(expd, actl, actl == null ? "<NULL>" : Type_adp_.NameOf_obj(actl), path, err);
return Tst_inner(expd, actl, actl == null ? "<NULL>" : Type_.Name_by_obj(actl), path, err);
}
public int Tst_sub_ary(Tst_chkr[] expd_subs, Object[] actl_subs, String path, int err) {
Tst_ary_inner(path + ".", expd_subs, actl_subs);
return err;
}
int Tst_inner(Tst_chkr expd_obj, Object actl_obj, String actl_type, String path, int err) {
if (actl_obj == null || !Type_adp_.IsAssignableFrom(expd_obj.TypeOf(), actl_obj.getClass())) {
results.Add(Tst_itm.fail_("!=", path, "<cast type>", Type_adp_.NameOf_type(expd_obj.TypeOf()), actl_type));
if (actl_obj == null || !Type_.Is_assignable_from(expd_obj.TypeOf(), actl_obj.getClass())) {
results.Add(Tst_itm.fail_("!=", path, "<cast type>", Type_.Name(expd_obj.TypeOf()), actl_type));
return 1;
// results.Add(Tst_itm.fail_("!=", path, "<cast value>", Object_.Xto_str_strict_or_null(expd_obj.ValueOf()), Object_.Xto_str_strict_or_null(actl_obj)));
}

View File

@ -18,8 +18,8 @@ class Log_tbl_fmtr {
private final Bry_bfr bfr = Bry_bfr_.New();
private final List_adp itms = List_adp_.New();
private Log_fld_itm[] ary;
public Log_tbl_fmtr Add_str(String key, int len) {ary = null; itms.Add(new Log_fld_itm__bry(Type_adp_.Tid__bry, key, len)); return this;}
public Log_tbl_fmtr Add_int(String key, int bgn, int end) {ary = null; itms.Add(new Log_fld_itm__int(Type_adp_.Tid__int, key, bgn, end)); return this;}
public Log_tbl_fmtr Add_str(String key, int len) {ary = null; itms.Add(new Log_fld_itm__bry(Type_ids_.Id__bry, key, len)); return this;}
public Log_tbl_fmtr Add_int(String key, int bgn, int end) {ary = null; itms.Add(new Log_fld_itm__int(Type_ids_.Id__int, key, bgn, end)); return this;}
public void Log(Object... vals) {
if (ary == null)
ary = (Log_fld_itm[])itms.To_ary_and_clear(Log_fld_itm.class);

View File

@ -19,7 +19,7 @@ public class Dsv_fld_parser_ {
public static final Dsv_fld_parser Int_parser = Dsv_fld_parser_int.Instance;
public static final Dsv_fld_parser Line_parser__comment_is_pipe = new Dsv_fld_parser_line(Byte_ascii.Pipe);
public static Err err_fld_unhandled(Dsv_fld_parser parser, Dsv_wkr_base wkr, int fld_idx, byte[] src, int bgn, int end) {
throw Err_.new_wo_type("fld unhandled", "parser", Type_adp_.NameOf_obj(parser), "wkr", Type_adp_.NameOf_obj(wkr), "fld_idx", fld_idx, "val", String_.new_u8(src, bgn, end)).Trace_ignore_add_1_();
throw Err_.new_wo_type("fld unhandled", "parser", Type_.Name_by_obj(parser), "wkr", Type_.Name_by_obj(wkr), "fld_idx", fld_idx, "val", String_.new_u8(src, bgn, end)).Trace_ignore_add_1_();
}
}
class Dsv_fld_parser_line implements Dsv_fld_parser {

View File

@ -27,8 +27,8 @@ public class Json_doc_srl {
return this;
}
public void Write_obj(boolean comma, byte[] key, Object val) {
Class<?> t = Type_adp_.ClassOf_obj(val);
if (Type_adp_.Is_array(t))
Class<?> t = Type_.Type_by_obj(val);
if (Type_.Is_array(t))
Write_kv_ary(comma, key, (Object[])val);
else
Write_kv_str(comma, key, Object_.Xto_str_strict_or_empty(val));

View File

@ -44,7 +44,7 @@ public class Json_printer {
for (int i = 0; i < len; ++i) {
Json_kv kv = nde.Get_at_as_kv(i);
Object kv_val = wtr.Get_x(kv.Val());
wtr.Kv_obj(kv.Key_as_bry(), kv_val, Type_adp_.To_tid_obj(kv_val));
wtr.Kv_obj(kv.Key_as_bry(), kv_val, Type_ids_.To_id_by_obj(kv_val));
}
wtr.Doc_nde_end();
return this;

View File

@ -69,9 +69,9 @@ public class Json_wtr {
Write_nl();
return Write_grp_bgn(Sym_ary_bgn);
}
public Json_wtr Ary_itm_str(String itm) {return Ary_itm_by_type_tid(Type_adp_.Tid__str, itm);}
public Json_wtr Ary_itm_bry(byte[] itm) {return Ary_itm_by_type_tid(Type_adp_.Tid__bry, itm);}
public Json_wtr Ary_itm_obj(Object itm) {return Ary_itm_by_type_tid(Type_adp_.To_tid_obj(itm), itm);}
public Json_wtr Ary_itm_str(String itm) {return Ary_itm_by_type_tid(Type_ids_.Id__str, itm);}
public Json_wtr Ary_itm_bry(byte[] itm) {return Ary_itm_by_type_tid(Type_ids_.Id__bry, itm);}
public Json_wtr Ary_itm_obj(Object itm) {return Ary_itm_by_type_tid(Type_ids_.To_id_by_obj(itm), itm);}
public Json_wtr Ary_itm_by_type_tid(int itm_type_tid, Object itm) {
Write_indent_itm();
Write_val_obj(Bool_.Y, itm_type_tid, itm);
@ -126,7 +126,7 @@ public class Json_wtr {
}
public void Kv_itm_x(byte[] key, Json_itm itm) {
Object val = Get_x(itm);
int val_tid = Type_adp_.To_tid_obj(val);
int val_tid = Type_ids_.To_id_by_obj(val);
Kv_obj(key, val, val_tid);
}
public Json_wtr Kv_obj(byte[] key, Object val, int val_tid) {
@ -162,19 +162,19 @@ public class Json_wtr {
}
private void Write_val_obj(boolean called_by_ary, int type_tid, Object obj) {
switch (type_tid) {
case Type_adp_.Tid__null: bfr.Add(Object_.Bry__null); break;
case Type_adp_.Tid__bool: bfr.Add_bool(Bool_.Cast(obj)); break;
case Type_adp_.Tid__byte: bfr.Add_byte(Byte_.cast(obj)); break;
case Type_adp_.Tid__int: bfr.Add_int_variable(Int_.cast(obj)); break;
case Type_adp_.Tid__long: bfr.Add_long_variable(Long_.cast(obj)); break;
case Type_adp_.Tid__float: bfr.Add_float(Float_.cast(obj)); break;
case Type_adp_.Tid__double: bfr.Add_double(Double_.cast(obj)); break;
case Type_adp_.Tid__str: Write_str(Bry_.new_u8((String)obj)); break;
case Type_adp_.Tid__bry: Write_str((byte[])obj); break;
case Type_adp_.Tid__char:
case Type_adp_.Tid__date:
case Type_adp_.Tid__decimal: Write_str(Bry_.new_u8(Object_.Xto_str_strict_or_empty(obj))); break;
case Type_adp_.Tid__obj:
case Type_ids_.Id__null: bfr.Add(Object_.Bry__null); break;
case Type_ids_.Id__bool: bfr.Add_bool(Bool_.Cast(obj)); break;
case Type_ids_.Id__byte: bfr.Add_byte(Byte_.cast(obj)); break;
case Type_ids_.Id__int: bfr.Add_int_variable(Int_.cast(obj)); break;
case Type_ids_.Id__long: bfr.Add_long_variable(Long_.cast(obj)); break;
case Type_ids_.Id__float: bfr.Add_float(Float_.cast(obj)); break;
case Type_ids_.Id__double: bfr.Add_double(Double_.cast(obj)); break;
case Type_ids_.Id__str: Write_str(Bry_.new_u8((String)obj)); break;
case Type_ids_.Id__bry: Write_str((byte[])obj); break;
case Type_ids_.Id__char:
case Type_ids_.Id__date:
case Type_ids_.Id__decimal: Write_str(Bry_.new_u8(Object_.Xto_str_strict_or_empty(obj))); break;
case Type_ids_.Id__obj:
int grp_type = Grp_type__get(obj);
if (grp_type < Grp_type__json_ary)
Write_val_obj__nde(called_by_ary, grp_type, obj);
@ -225,7 +225,7 @@ public class Json_wtr {
for (int i = 0; i < kvy_len; ++i) {
Keyval kv = kvy[i];
Object kv_val = kv.Val();
Kv_obj(Bry_.new_u8(kv.Key()), kv_val, Type_adp_.To_tid_obj(kv_val));
Kv_obj(Bry_.new_u8(kv.Key()), kv_val, Type_ids_.To_id_by_obj(kv_val));
}
}
Write_grp_end(Bool_.Y, Sym_nde_end);
@ -303,10 +303,10 @@ public class Json_wtr {
private static final int Grp_type__json_nde = 1, Grp_type__kv_ary = 2, Grp_type__json_ary = 3, Grp_type__obj_ary = 4;
private static int Grp_type__get(Object obj) {
Class<?> type = obj.getClass();
if (Type_adp_.Eq(type, Keyval[].class)) return Grp_type__kv_ary;
else if (Type_adp_.Is_array(type)) return Grp_type__obj_ary;
else if (Type_adp_.Eq(type, Json_nde.class)) return Grp_type__json_nde;
else if (Type_adp_.Eq(type, Json_ary.class)) return Grp_type__json_ary;
if (Type_.Eq(type, Keyval[].class)) return Grp_type__kv_ary;
else if (Type_.Is_array(type)) return Grp_type__obj_ary;
else if (Type_.Eq(type, Json_nde.class)) return Grp_type__json_nde;
else if (Type_.Eq(type, Json_ary.class)) return Grp_type__json_ary;
else throw Err_.new_unhandled(type);
}
}

View File

@ -87,26 +87,26 @@ public class Xoax_addon_mgr {
Xoax_addon_itm addon = (Xoax_addon_itm)hash.Get_at(i);
// init
if (Type_adp_.Implements_intf_obj(addon, Xoax_addon_itm__init.class)) {
if (Type_.Is_assignable_from_by_obj(addon, Xoax_addon_itm__init.class)) {
Xoax_addon_itm__init addon_init = (Xoax_addon_itm__init)addon;
addon_init.Init_addon_by_app(app);
init_list.Add(addon_init);
}
// add bldr cmds
if (Type_adp_.Implements_intf_obj(addon, Xoax_addon_itm__bldr.class)) {
if (Type_.Is_assignable_from_by_obj(addon, Xoax_addon_itm__bldr.class)) {
Xoax_addon_itm__bldr addon_bldr = (Xoax_addon_itm__bldr)addon;
app.Bldr().Cmd_regy().Add_many(addon_bldr.Bldr_cmds());
}
// add special pages
if (Type_adp_.Implements_intf_obj(addon, Xoax_addon_itm__special.class)) {
if (Type_.Is_assignable_from_by_obj(addon, Xoax_addon_itm__special.class)) {
Xoax_addon_itm__special addon_sp = (Xoax_addon_itm__special)addon;
app.Special_regy().Add_many(addon_sp.Special_pages());
}
// add json mgrs
if (Type_adp_.Implements_intf_obj(addon, Xoax_addon_itm__json.class)) {
if (Type_.Is_assignable_from_by_obj(addon, Xoax_addon_itm__json.class)) {
Xoax_addon_itm__json addon_json = (Xoax_addon_itm__json)addon;
gplx.xowa.htmls.bridges.Bridge_cmd_itm[] json_cmds = addon_json.Json_cmds();
for (gplx.xowa.htmls.bridges.Bridge_cmd_itm json_cmd : json_cmds) {

View File

@ -25,7 +25,7 @@ public class Xop_mediawiki_mgr {
this.mode_is_prod = mode_is_prod;
if (mode_is_prod) {
gplx.dbs.Db_conn_bldr.Instance.Reg_default_sqlite();
gplx.core.envs.Env_.Init_swt(String_.Ary_empty, Type_adp_.ClassOf_obj(this)); // must call Init else unit_testing will be true
gplx.core.envs.Env_.Init_swt(String_.Ary_empty, Type_.Type_by_obj(this)); // must call Init else unit_testing will be true
}
this.app = new Xoae_app(usr_dlg, gplx.xowa.apps.Xoa_app_mode.Itm_cmd
, root_dir

View File

@ -65,7 +65,7 @@ public class Xosrv_server implements Gfo_invk {
}
private String Exec_cmd(String msg_text) {
Object rv_obj = app.Gfs_mgr().Run_str(msg_text);
String rv = Type_adp_.Eq_typeSafe(rv_obj, String_.Cls_ref_type) ? (String)rv_obj : Object_.Xto_str_strict_or_null(rv_obj);
String rv = Type_.Eq_by_obj(rv_obj, String_.Cls_ref_type) ? (String)rv_obj : Object_.Xto_str_strict_or_null(rv_obj);
return rv;
}
public String Exec_js(byte[] sender, byte[] msg_text) {

View File

@ -32,10 +32,10 @@ public class Bridge_msg_bldr {
public Bridge_msg_bldr Notify_hint_(String v) {synchronized(wtr){this.notify_hint = v;} return this;} private String notify_hint;
public Bridge_msg_bldr Notify_pass_(String v){synchronized(wtr){this.notify_text = v; this.notify_status = "success";} return this;}
public Bridge_msg_bldr Notify_fail_(String v){synchronized(wtr){this.notify_text = v; this.notify_status = "error"; this.rslt_pass = false;} return this;}
public Bridge_msg_bldr Data(String key, boolean val) {return Data_obj(key, val, Type_adp_.Tid__bool);}
public Bridge_msg_bldr Data(String key, int val) {return Data_obj(key, val, Type_adp_.Tid__int);}
public Bridge_msg_bldr Data(String key, String val) {return Data_obj(key, val, Type_adp_.Tid__str);}
public Bridge_msg_bldr Data(String key, byte[] val) {return Data_obj(key, val, Type_adp_.Tid__bry);}
public Bridge_msg_bldr Data(String key, boolean val) {return Data_obj(key, val, Type_ids_.Id__bool);}
public Bridge_msg_bldr Data(String key, int val) {return Data_obj(key, val, Type_ids_.Id__int);}
public Bridge_msg_bldr Data(String key, String val) {return Data_obj(key, val, Type_ids_.Id__str);}
public Bridge_msg_bldr Data(String key, byte[] val) {return Data_obj(key, val, Type_ids_.Id__bry);}
private Bridge_msg_bldr Data_obj(String key, Object val, int val_tid) {
synchronized (wtr) {data_root.Add_data(key, val, val_tid);}
return this;
@ -81,9 +81,9 @@ public class Bridge_msg_bldr {
Gfo_tree_data sub_kv = (Gfo_tree_data)itm;
String key = sub_kv.Key(); Object val = sub_kv.Val();
switch (sub_kv.Val_tid()) {
case Type_adp_.Tid__bool: wtr.Kv_bool(key, Bool_.Cast(val)); break;
case Type_adp_.Tid__int: wtr.Kv_int(key, Int_.cast(val)); break;
case Type_adp_.Tid__bry: wtr.Kv_bry(key, (byte[])val); break;
case Type_ids_.Id__bool: wtr.Kv_bool(key, Bool_.Cast(val)); break;
case Type_ids_.Id__int: wtr.Kv_int(key, Int_.cast(val)); break;
case Type_ids_.Id__bry: wtr.Kv_bry(key, (byte[])val); break;
default: wtr.Kv_str(key, Object_.Xto_str_strict_or_null_mark(val)); break;
}
}

View File

@ -66,9 +66,9 @@ public class Xot_invk_mock implements Xot_invk {
String kv_key_str = kv.Key();
Object kv_key_obj = kv.Key_as_obj();
Arg_nde_tkn_mock nde_tkn = null;
if (Type_adp_.Eq_typeSafe(kv_key_obj, Int_.Cls_ref_type)) // key is int; EX: 1 => val
if (Type_.Eq_by_obj(kv_key_obj, Int_.Cls_ref_type)) // key is int; EX: 1 => val
nde_tkn = new Arg_nde_tkn_mock(null, kv.Val_to_str_or_empty()); // add w/o key
else if (Type_adp_.Eq_typeSafe(kv.Val(), Bool_.Cls_ref_type)) { // val is boolean; EX: key => true || key => false
else if (Type_.Eq_by_obj(kv.Val(), Bool_.Cls_ref_type)) { // val is boolean; EX: key => true || key => false
boolean kv_val_bool = Bool_.Cast(kv.Val());
if (kv_val_bool)
nde_tkn = new Arg_nde_tkn_mock(kv_key_str, "1"); // true => 1 (PHP behavior)

View File

@ -97,7 +97,7 @@ public class Xot_tmpl_wtr {
tkn.Tmpl_evaluate(ctx, src, frame, rslt_bfr);
}
catch (Exception e) {
String err_string = String_.new_u8(src, tkn.Src_bgn(), tkn.Src_end()) + "|" + Type_adp_.NameOf_obj(e) + "|" + Err_.Cast_or_make(e).To_str__log();
String err_string = String_.new_u8(src, tkn.Src_bgn(), tkn.Src_end()) + "|" + Type_.Name_by_obj(e) + "|" + Err_.Cast_or_make(e).To_str__log();
if (Env_.Mode_testing())
throw Err_.new_exc(e, "xo", err_string);
else

View File

@ -216,7 +216,7 @@ class Scrib_lua_rsp_bldr {
else if (Object_.Eq(v_type, Double_.Cls_ref_type)) Bld_double(bfr, Double_.cast(v));
else if (Object_.Eq(v_type, Keyval[].class)) Bld_kv_ary(bfr, (Keyval[])v);
else if (Object_.Eq(v_type, Scrib_lua_proc.class)) Bld_fnc(bfr, (Scrib_lua_proc)v);
else throw Err_.new_unhandled(Type_adp_.NameOf_obj(v));
else throw Err_.new_unhandled(Type_.Name_by_obj(v));
}
private void Bld_bool(Bry_bfr bfr, boolean v) {bfr.Add_str_a7("b:").Add_int_fixed(v ? 1 : 0, 1).Add_byte(Byte_ascii.Semic);}
private void Bld_int(Bry_bfr bfr, int v) {bfr.Add_str_a7("i:").Add_int_variable(v).Add_byte(Byte_ascii.Semic);}

View File

@ -50,7 +50,7 @@ public class Scrib_lua_mod {
String prc_key = prc_kv.Key();
Object prc_val = prc_kv.Val();
Scrib_lua_proc fnc = null;
if (Type_adp_.ClassOf_obj(prc_val) == Scrib_lua_proc.class)
if (Type_.Type_by_obj(prc_val) == Scrib_lua_proc.class)
fnc = (Scrib_lua_proc)prc_val;
else
fnc = new Scrib_lua_proc(prc_key, -1);

View File

@ -20,6 +20,6 @@ public class Scrib_lua_proc {
public int Id() {return id;} private int id;
@Override public String toString() {return key + ":" + id;}
public static Scrib_lua_proc cast_or_null_(Object o) { // NOTE: maxStringLength and maxPatternLength return d:INF; ignore these
return Type_adp_.ClassOf_obj(o) == Scrib_lua_proc.class ? (Scrib_lua_proc)o : null;
return Type_.Type_by_obj(o) == Scrib_lua_proc.class ? (Scrib_lua_proc)o : null;
}
}

View File

@ -115,7 +115,7 @@ class Luaj_value_ {
}
public static LuaValue Obj_to_lua_val(Luaj_server server, Object o) {
if (o == null) return LuaValue.NIL;
Class<?> c = Type_adp_.ClassOf_obj(o);
Class<?> c = Type_.Type_by_obj(o);
if (Object_.Eq(c, Bool_.Cls_ref_type)) return LuaValue.valueOf((Boolean)o);
else if (Object_.Eq(c, Byte_.Cls_ref_type)) return LuaValue.valueOf((Byte)o);
else if (Object_.Eq(c, Int_.Cls_ref_type)) return LuaValue.valueOf((Integer)o);
@ -139,11 +139,11 @@ class Luaj_value_ {
Keyval itm = ary[i];
LuaValue itm_val = Obj_to_lua_val(server, itm.Val());
switch (itm.Key_tid()) {
case Type_adp_.Tid__int:
case Type_ids_.Id__int:
rv.set(Int_.cast(itm.Key_as_obj()), itm_val);
break;
case Type_adp_.Tid__str:
case Type_adp_.Tid__obj:
case Type_ids_.Id__str:
case Type_ids_.Id__obj:
rv.set(itm.Key(), itm_val);
break;
}

View File

@ -79,7 +79,7 @@ public class Process_send_wtr {
}
public boolean Encode_obj(Bry_bfr bfr, Object o) {
if (o == null) {bfr.Add(CONST_nil); return true;}
Class<?> c = Type_adp_.ClassOf_obj(o);
Class<?> c = Type_.Type_by_obj(o);
if (Object_.Eq(c, Bool_.Cls_ref_type)) Encode_bool(bfr, Bool_.Cast(o));
else if (Object_.Eq(c, Int_.Cls_ref_type)) Encode_int(bfr, Int_.cast(o));
else if (Object_.Eq(c, Long_.Cls_ref_type)) bfr.Add_long_variable(Long_.cast(o));
@ -89,7 +89,7 @@ public class Process_send_wtr {
else if (Object_.Eq(c, Scrib_lua_proc.class)) {if (!Encode_prc(bfr, (Scrib_lua_proc)o)) return false;}
else if (Object_.Eq(c, Keyval.class)) {if (!Encode_kv(bfr, (Keyval)o)) return false;}
else if (Object_.Eq(c, Keyval[].class)) {if (!Encode_ary(bfr, (Keyval[])o)) return false;}
else {throw Scrib_xtn_mgr.err_("Object cannot be serialized: ~{0}", Type_adp_.NameOf_obj(o));}
else {throw Scrib_xtn_mgr.err_("Object cannot be serialized: ~{0}", Type_.Name_by_obj(o));}
return true;
}
private static final byte[] CONST_nil = Bry_.new_a7("nil"), CONST_bool_true = Bry_.new_a7("true"), CONST_bool_false = Bry_.new_a7("false"), CONST_escape_000 = Bry_.new_a7("\\000");

View File

@ -69,10 +69,10 @@ class Process_server_mock_rcvd_val implements Process_server_mock_rcvd {
continue;
}
Class<?> kv_val_type = kv_val.getClass();
boolean kv_val_is_array = Type_adp_.Eq(kv_val_type, Keyval[].class);
boolean kv_val_is_array = Type_.Eq(kv_val_type, Keyval[].class);
if (print_key && !kv_val_is_array)
bfr.Add_str_u8(kv.Key()).Add_byte(Byte_ascii.Colon);
if (Type_adp_.Eq(kv_val_type, Bool_.Cls_ref_type))
if (Type_.Eq(kv_val_type, Bool_.Cls_ref_type))
bfr.Add(Bool_.Cast(kv_val) ? gplx.langs.jsons.Json_itm_.Bry__true : gplx.langs.jsons.Json_itm_.Bry__false);
else if (kv_val_is_array) {
Keyval[] sub = (Keyval[])kv_val;

View File

@ -38,11 +38,11 @@ class Kv_ary_utl {
private static void Ary_to_str__itm(Json_wtr wtr, int indent, Keyval itm) {
Object val = itm.Val();
Class<?> val_type = val.getClass();
int type_tid = Type_adp_.To_tid_type(val_type);
if (type_tid == Type_adp_.Tid__obj) {
if (Type_adp_.Eq(val_type, Keyval[].class))
int type_tid = Type_ids_.To_id_by_type(val_type);
if (type_tid == Type_ids_.Id__obj) {
if (Type_.Eq(val_type, Keyval[].class))
Ary_to_str__nde(wtr, indent, itm.Key(), (Keyval[])itm.Val());
else if (Type_adp_.Is_array(val_type))
else if (Type_.Is_array(val_type))
Ary_to_str__ary(wtr, indent, itm.Key(), Array_.cast(val));
else
throw Err_.new_unhandled(type_tid);
@ -65,11 +65,11 @@ class Kv_ary_utl {
for (int j = 0; j < len; ++j) {
Object itm = Array_.Get_at(array, j);
Class<?> itm_type = itm.getClass();
int itm_type_tid = Type_adp_.To_tid_type(itm_type);
if (itm_type_tid == Type_adp_.Tid__obj) {
if (Type_adp_.Eq(itm_type, Keyval.class))
int itm_type_tid = Type_ids_.To_id_by_type(itm_type);
if (itm_type_tid == Type_ids_.Id__obj) {
if (Type_.Eq(itm_type, Keyval.class))
Ary_to_str__itm(wtr, indent + 1, (Keyval)itm);
else if (Type_adp_.Is_array(itm_type))
else if (Type_.Is_array(itm_type))
Ary_to_str__ary_itms(wtr, indent + 1, Array_.cast(itm));
else
throw Err_.new_unhandled(itm_type);

View File

@ -304,7 +304,7 @@ public class Scrib_lib_mw implements Scrib_lib {
}
return (Keyval[])rv.To_ary(Keyval.class);
}
private static boolean Is_kv_ary(Keyval kv) {return Type_adp_.Eq_typeSafe(kv.Val(), Keyval[].class);}
private static boolean Is_kv_ary(Keyval kv) {return Type_.Eq_by_obj(kv.Val(), Keyval[].class);}
public boolean ExpandTemplate(Scrib_proc_args args, Scrib_proc_rslt rslt) {
String ttl_str = args.Pull_str(1);
byte[] ttl_bry = Bry_.new_u8(ttl_str);
@ -357,7 +357,7 @@ public class Scrib_lib_mw implements Scrib_lib {
Xot_invk frame = Scrib_frame_.Get_frame(core, frame_id);
Object ttl_obj = args.Cast_obj_or_null(1); // NOTE: callers must pass named title else title will be false; EX: frame:newChild{'current', 'title0'} -> false; frame:newChild{'current', title='title0'} -> 'title0'; DATE:2014-05-20
Xoa_ttl ttl = null;
if (Type_adp_.ClassOf_obj(ttl_obj) != String.class) { // title = false
if (Type_.Type_by_obj(ttl_obj) != String.class) { // title = false
byte[] ttl_bry = frame.Frame_ttl();
ttl = Xoa_ttl.Parse(core.Wiki(), ttl_bry);
}

View File

@ -61,7 +61,7 @@ public class Scrib_lib_text implements Scrib_lib {
Keyval[] itm_as_nde = null;
Object itm_as_ary = null;
Class<?> itm_type = itm.getClass();
boolean itm_is_nde = Type_adp_.Eq(itm_type, Keyval[].class);
boolean itm_is_nde = Type_.Eq(itm_type, Keyval[].class);
// additional logic to classify "[]" as ary, not nde; note that this is done by checking len of itm_as_nde
if (itm_is_nde) {

View File

@ -28,13 +28,13 @@ class Scrib_lib_text__json_util {
for (int i = 0; i < len; ++i) {
Keyval kv = kv_ary[i];
Object kv_val = kv.Val();
if (kv_val != null && Type_adp_.Eq(kv_val.getClass(), Keyval[].class)) {
if (kv_val != null && Type_.Eq(kv_val.getClass(), Keyval[].class)) {
Reindex_arrays(rv, (Keyval[])kv_val, is_encoding);
if (!rv.Rv_is_kvy())
kv.Val_(rv.Rv_as_ary());
}
if (is_sequence) {
if (kv.Key_tid() == Type_adp_.Tid__int) {
if (kv.Key_tid() == Type_ids_.Id__int) {
int kv_key_as_int = Int_.cast(kv.Key_as_obj());
is_sequence = next++ == kv_key_as_int;
}
@ -161,22 +161,22 @@ class Scrib_lib_text__json_util {
}
private void Encode_kv(Keyval kv) {
Object kv_val = kv.Val();
Class<?> type = Type_adp_.ClassOf_obj(kv_val);
if (Type_adp_.Eq(type, Keyval[].class)) {
Class<?> type = Type_.Type_by_obj(kv_val);
if (Type_.Eq(type, Keyval[].class)) {
wtr.Nde_bgn(kv.Key());
Encode_kv_ary((Keyval[])kv_val);
wtr.Nde_end();
}
else if (Type_adp_.Is_array(type)) { // encode as array
else if (Type_.Is_array(type)) { // encode as array
wtr.Ary_bgn(kv.Key());
Encode_ary(kv_val);
wtr.Ary_end();
}
else if (Type_adp_.Eq(type, Int_.Cls_ref_type)) wtr.Kv_int(kv.Key(), Int_.cast(kv_val));
else if (Type_adp_.Eq(type, Long_.Cls_ref_type)) wtr.Kv_long(kv.Key(), Long_.cast(kv_val));
else if (Type_adp_.Eq(type, Float_.Cls_ref_type)) wtr.Kv_float(kv.Key(), Float_.cast(kv_val));
else if (Type_adp_.Eq(type, Double_.Cls_ref_type)) wtr.Kv_double(kv.Key(), Double_.cast(kv_val));
else if (Type_adp_.Eq(type, Bool_.Cls_ref_type)) wtr.Kv_bool(kv.Key(), Bool_.Cast(kv_val));
else if (Type_.Eq(type, Int_.Cls_ref_type)) wtr.Kv_int(kv.Key(), Int_.cast(kv_val));
else if (Type_.Eq(type, Long_.Cls_ref_type)) wtr.Kv_long(kv.Key(), Long_.cast(kv_val));
else if (Type_.Eq(type, Float_.Cls_ref_type)) wtr.Kv_float(kv.Key(), Float_.cast(kv_val));
else if (Type_.Eq(type, Double_.Cls_ref_type)) wtr.Kv_double(kv.Key(), Double_.cast(kv_val));
else if (Type_.Eq(type, Bool_.Cls_ref_type)) wtr.Kv_bool(kv.Key(), Bool_.Cast(kv_val));
else wtr.Kv_str(kv.Key(), Object_.Xto_str_strict_or_null(kv_val));
}
private void Encode_ary(Object ary) {

View File

@ -251,8 +251,8 @@ class Scrib_lib_json_fxt {
private String To_str(Object o) {
if (o == null) return "<< NULL >>";
Class<?> type = o.getClass();
if (Type_adp_.Eq(type, Keyval[].class)) return Kv_ary_utl.Ary_to_str(wtr, (Keyval[])o);
else if (Type_adp_.Is_array(type)) return Array_.To_str_nested_obj(o);
if (Type_.Eq(type, Keyval[].class)) return Kv_ary_utl.Ary_to_str(wtr, (Keyval[])o);
else if (Type_.Is_array(type)) return Array_.To_str_nested_obj(o);
else return Object_.Xto_str_strict_or_null(o);
}
}

View File

@ -105,7 +105,7 @@ public class Scrib_lib_title implements Scrib_lib {
// private static final byte[] Proto_relative = Bry_.new_a7("relative");
// private static final Hash_adp_bry proto_hash = Hash_adp_bry.ci_a7().Add_str_obj("http", Bry_.new_a7("http://")).Add_str_obj("https", Bry_.new_a7("https://")).Add_str_obj("relative", Bry_.new_a7("//")).Add_str_obj("canonical", Bry_.new_a7("1"));
private byte[] Parse_ns(Xowe_wiki wiki, Object ns_obj) {
if (Type_adp_.Eq_typeSafe(ns_obj, String.class))
if (Type_.Eq_by_obj(ns_obj, String.class))
return Bry_.new_u8(String_.cast(ns_obj));
else {
int ns_id = Int_.cast(ns_obj);

View File

@ -243,7 +243,7 @@ class Scrib_lib_ustring_gsub_mgr {
tmp_repl_tid = Repl_tid_string;
tmp_repl_bry = Bry_.new_u8(Double_.To_str(Double_.cast(repl_obj)));
}
else throw Err_.new_unhandled(Type_adp_.NameOf_type(repl_type));
else throw Err_.new_unhandled(Type_.Name(repl_type));
}
private String Exec_repl(byte repl_tid, byte[] repl_bry, String text, String regx, int limit) {
Regx_adp regx_mgr = Scrib_lib_ustring.RegxAdp_new_(core.Ctx(), regx);

View File

@ -479,8 +479,8 @@ class Scrib_lib_wikibase_srl_fxt {
Object kv_val = kv.Val();
if (kv_val == null) {bfr.Add_str_a7("null").Add_byte_nl(); return;}
Class<?> kv_val_cls = kv_val.getClass();
if (Type_adp_.Eq(kv_val_cls, Keyval[].class)) {bfr.Add_byte_nl(); Xto_str(bfr, (Keyval[])kv_val, depth + 1);}
else if (Type_adp_.Eq(kv_val_cls, Keyval[].class)) {bfr.Add_byte_nl(); Xto_str(bfr, (Keyval)kv_val, depth + 1);}
if (Type_.Eq(kv_val_cls, Keyval[].class)) {bfr.Add_byte_nl(); Xto_str(bfr, (Keyval[])kv_val, depth + 1);}
else if (Type_.Eq(kv_val_cls, Keyval[].class)) {bfr.Add_byte_nl(); Xto_str(bfr, (Keyval)kv_val, depth + 1);}
else bfr.Add_byte(Byte_ascii.Apos).Add_str_u8(Object_.Xto_str_strict_or_empty(kv_val)).Add_byte(Byte_ascii.Apos).Add_byte_nl();
}
}

View File

@ -87,8 +87,8 @@ public class Scrib_proc_args {
if (kv == null) continue;
// get integer-key; needed to handle gaps
if ( kv.Key_tid() == Type_adp_.Tid__int // luaj will be int
|| kv.Key_tid() == Type_adp_.Tid__obj) { // lua will be obj; note that luaj will also have other non-key objects
if ( kv.Key_tid() == Type_ids_.Id__int // luaj will be int
|| kv.Key_tid() == Type_ids_.Id__obj) { // lua will be obj; note that luaj will also have other non-key objects
Object key_obj = kv.Key_as_obj();
if (key_obj.getClass() == Int_.Cls_ref_type) { // key is int; cast it
int expd_key = i + List_adp_.Base1; // EX: i=1; expd_key=2
@ -127,7 +127,7 @@ public class Scrib_proc_args {
public byte[][] Cast_params_as_bry_ary_or_rest_of_ary(int params_idx) { // PAGE:ru.w:Ленин,_Владимир_Ильич; DATE:2014-07-01 MW:LanguageLibrary.php|ConvertPlural: if (is_array($args[0])) $args = $args[0]; $forms = array_values(array_map('strval', $args));
if (params_idx < 0 || params_idx >= ary_len) return Bry_.Ary_empty;
Object o = ary[params_idx].Val();
if (Type_adp_.Eq_typeSafe(o, Keyval[].class)) {
if (Type_.Eq_by_obj(o, Keyval[].class)) {
Keyval[] tbl = (Keyval[])o;
int rv_len = tbl.length;
byte[][] rv = new byte[rv_len][];
@ -152,7 +152,7 @@ public class Scrib_proc_args {
public byte[] Extract_qry_args(Xowe_wiki wiki, int idx) {
Object qry_args_obj = Cast_obj_or_null(idx);
if (qry_args_obj == null) return Bry_.Empty;
Class<?> qry_args_cls = Type_adp_.ClassOf_obj(qry_args_obj);
Class<?> qry_args_cls = Type_.Type_by_obj(qry_args_obj);
if (qry_args_cls == String.class)
return Bry_.new_u8((String)qry_args_obj);
else if (qry_args_cls == Keyval[].class) {
@ -169,7 +169,7 @@ public class Scrib_proc_args {
return bfr.To_bry_and_rls();
}
else {
wiki.Appe().Usr_dlg().Warn_many("", "", "unknown type for GetUrl query args: ~{0}", Type_adp_.NameOf_type(qry_args_cls));
wiki.Appe().Usr_dlg().Warn_many("", "", "unknown type for GetUrl query args: ~{0}", Type_.Name(qry_args_cls));
return Bry_.Empty;
}
}

View File

@ -1132,7 +1132,7 @@ public class XomwMessage {
* @return array Array with the parameter type (either "before" or "after") and the value.
*/
private void extractParam(XomwMessageVal rv, Object param, int format) {
if (Type_adp_.Implements_intf_obj(param, XomwMessagePrm.class)) {
if (Type_.Is_assignable_from_by_obj(param, XomwMessagePrm.class)) {
XomwMessagePrm prm = (XomwMessagePrm)param;
switch (prm.Tid()) {
case XomwMessagePrm.Tid__raw:

View File

@ -35,7 +35,7 @@ public class XomwSanitizer {
private static Btrie_slim_mgr invalid_idn_trie;
public XomwSanitizer() {
if (regex_url_char == null) {
synchronized (Type_adp_.ClassOf_obj(this)) {
synchronized (Type_.Type_by_obj(this)) {
regex_url_char = new Xomw_regex_url_char();
// Characters that will be ignored in IDNs.
@ -81,7 +81,7 @@ public class XomwSanitizer {
// assert static structs
if (html_entities == null) {
synchronized (Type_adp_.ClassOf_obj(this)) {
synchronized (Type_.Type_by_obj(this)) {
html_entities = Html_entities_new();
}
}

View File

@ -261,7 +261,7 @@ public abstract class XomwAbstractContent implements XomwContent {
// break;
// }
// // Redirects to some special pages are not permitted
// if (Type_adp_.Eq_typeSafe(newtitle, typeof(XomwTitle)) && newtitle.isValidRedirectTarget()) {
// if (Type_.Eq_by_obj(newtitle, typeof(XomwTitle)) && newtitle.isValidRedirectTarget()) {
// // The new title passes the checks, so make that our current
// // title so that further recursion can be checked
// title = newtitle;

View File

@ -148,7 +148,7 @@ public class XomwInterwikiLookupAdapter implements XomwInterwikiLookup {
String interwiki = (String)hash.Get_at(i);
String url = site.getPageUrl();
String path = null;
if (Type_adp_.Eq_typeSafe(site, XomwMediaWikiSite.class)) {
if (Type_.Eq_by_obj(site, XomwMediaWikiSite.class)) {
path = ((XomwMediaWikiSite)site).getFileUrl("api.php");
} else {
path = "";

View File

@ -112,7 +112,7 @@ public abstract class XomwGenericArrayObject extends XomwArrayObject { /**
*/
protected boolean hasValidType(Object val) {
Class<?> cls = this.getObjectType();
return Type_adp_.Eq_typeSafe(val, cls);
return Type_.Eq_by_obj(val, cls);
}
/**
@ -134,8 +134,8 @@ public abstract class XomwGenericArrayObject extends XomwArrayObject { /**
protected void setElement(int index, Object val) {
if (!this.hasValidType(val)) {
throw new XophpInvalidArgumentException(
"Can only add " + Type_adp_.FullNameOf_type(this.getObjectType()) + " implementing objects to "
+ Type_adp_.ClassOf_obj(this) + "."
"Can only add " + Type_.Canonical_name(this.getObjectType()) + " implementing objects to "
+ Type_.Type_by_obj(this) + "."
);
}

View File

@ -203,7 +203,7 @@ public class XomwBlockLevelPass {
// XO.STATIC
if (block_chars_ary == null) {
synchronized (Type_adp_.ClassOf_obj(this)) {
synchronized (Type_.Type_by_obj(this)) {
block_chars_ary = Block_chars_ary__new();
openMatchTrie = Btrie_slim_mgr.ci_a7().Add_many_str
( "<table", "<h1", "<h2", "<h3", "<h4", "<h5", "<h6", "<pre", "<tr"

View File

@ -315,7 +315,7 @@ public class XomwParser implements XomwParserIface {
private static byte[] Atr__rel;
public XomwParser(XomwEnv env) {
if (regex_space == null) {
synchronized (Type_adp_.ClassOf_obj(this)) {
synchronized (Type_.Type_by_obj(this)) {
regex_space = new Xomw_regex_space();
regex_boundary = new Xomw_regex_boundary(regex_space);
regex_url = new Xomw_regex_url(regex_space);

View File

@ -37,7 +37,7 @@ public class Xomw_lnke_wkr {// THREAD.UNSAFE: caching for repeated calls
this.sanitizer = sanitizer;
if (angle_entities_trie == null) {
synchronized (Type_adp_.ClassOf_obj(this)) {
synchronized (Type_.Type_by_obj(this)) {
Link_type__free = Bry_.new_a7("free");
Link_type__text = Bry_.new_a7("text");
Link_type__autonumber = Bry_.new_a7("autonumber");

View File

@ -46,7 +46,7 @@ public class Xomw_magiclinks_wkr {
.To_ary();
if (Tag__anch__rhs == null) {
synchronized (Type_adp_.ClassOf_obj(this)) {
synchronized (Type_.Type_by_obj(this)) {
Tag__anch__rhs = Bry_.new_a7("</a>");
regex_link_interrupt = new Xomw_regex_link_interrupt();
}