mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.8.4.1
This commit is contained in:
@@ -28,11 +28,12 @@ public class Err_ {
|
||||
return rv;
|
||||
}
|
||||
public static Err new_unhandled(Object val) {return new Err(Bool_.Y, Trace_null, Type__gplx, "val is not in switch/if", "val", val);}
|
||||
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(ClassAdp_.FullNameOf_type(c), raw);}
|
||||
public static Err new_parse_exc(Exception e, Class<?> c, String raw) {return new_parse(ClassAdp_.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_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(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_missing_idx(int idx, int len) {return new Err(Bool_.Y, Trace_null, Type__gplx, "index is out of bounds", "idx", idx, "len", len);}
|
||||
@@ -41,12 +42,12 @@ 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", ClassAdp_.FullNameOf_type(t), "actlType", ClassAdp_.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_adp_.FullNameOf_type(t), "actlType", Type_adp_.NameOf_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", ClassAdp_.NameOf_type(t), "obj", o_str);
|
||||
return new Err(Bool_.Y, Trace_null, Type__gplx, "cast failed", "type", Type_adp_.NameOf_type(t), "obj", o_str);
|
||||
}
|
||||
|
||||
public static String Message_lang(Exception e) {return e.getMessage();}
|
||||
@@ -67,6 +68,6 @@ public class Err_ {
|
||||
}
|
||||
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 Err cast_or_make(Exception e) {return ClassAdp_.Eq_typeSafe(e, Err.class) ? (Err)e : new Err(Bool_.N, Err_.Trace_lang(e), ClassAdp_.NameOf_obj(e), Err_.Message_lang(e));}
|
||||
public static Err cast_or_make(Exception 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 final String Type__op_canceled = "gplx.op_canceled";
|
||||
}
|
||||
|
||||
@@ -24,8 +24,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 = ClassAdp_.ClassOf_obj(val);
|
||||
if (!ClassAdp_.Eq_typeSafe(comp, val_type)) throw Err_.new_type_mismatch(val_type, 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);
|
||||
boolean rv = Object_.Eq(val, comp);
|
||||
return negated ? !rv : rv;
|
||||
}
|
||||
|
||||
@@ -24,13 +24,13 @@ public class Criteria_in implements Criteria {
|
||||
private void Val_as_obj_ary_(Object[] v) {
|
||||
this.ary = v;
|
||||
ary_len = Array_.Len(ary);
|
||||
ary_type = ary_len == 0 ? Object.class : ClassAdp_.ClassOf_obj(ary[0]);
|
||||
ary_type = ary_len == 0 ? Object.class : Type_adp_.ClassOf_obj(ary[0]);
|
||||
}
|
||||
public void Val_as_obj_(Object v) {Val_as_obj_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 (!ClassAdp_.Eq_typeSafe(comp, ary_type)) throw Err_.new_type_mismatch(ary_type, comp);
|
||||
if (!Type_adp_.Eq_typeSafe(comp, ary_type)) throw Err_.new_type_mismatch(ary_type, comp);
|
||||
boolean rv = false;
|
||||
for (int i = 0; i < ary_len; i++) {
|
||||
Object val = ary[i];
|
||||
|
||||
@@ -44,9 +44,9 @@ public class Js_wtr {
|
||||
Object itm = ary[i];
|
||||
if (i != 0) bfr.Add_byte(Byte_ascii.Comma);
|
||||
boolean val_needs_quotes = true;
|
||||
if ( ClassAdp_.Eq_typeSafe(itm, Bool_.Cls_ref_type)
|
||||
|| ClassAdp_.Eq_typeSafe(itm, Int_.Cls_ref_type)
|
||||
|| ClassAdp_.Eq_typeSafe(itm, Long_.Cls_ref_type)
|
||||
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)
|
||||
) {
|
||||
val_needs_quotes = false;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package gplx;
|
||||
import java.lang.reflect.Array;
|
||||
import gplx.core.strings.*;
|
||||
public class Array_ {
|
||||
public static Object cast(Object o) {return (Object)o;}
|
||||
public static void Sort(Object[] obj) {List_adp_sorter.new_().Sort(obj, obj.length);}
|
||||
public static void Sort(Object[] obj, gplx.lists.ComparerAble comparer) {List_adp_sorter.new_().Sort(obj, obj.length, true, comparer);}
|
||||
public static List_adp XtoList(Object ary) {
|
||||
|
||||
@@ -187,7 +187,7 @@ public class Bry_bfr {
|
||||
bfr_len += utf8_len;
|
||||
return this;
|
||||
}
|
||||
public Bry_bfr Add_bool(boolean v) {return Add(v ? Const_bool_true : Const_bool_false);} public static final byte[] Const_bool_true = Bry_.new_a7("true"), Const_bool_false = Bry_.new_a7("false");
|
||||
public Bry_bfr Add_bool(boolean v) {return Add(v ? Bool_.True_bry : Bool_.False_bry);}
|
||||
public Bry_bfr Add_int_bool(boolean v) {return Add_int_fixed(v ? 1 : 0, 1);}
|
||||
public Bry_bfr Add_int_variable(int val) {
|
||||
int log10 = Int_.Log10(val);
|
||||
|
||||
@@ -17,6 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx;
|
||||
public class Char_ {
|
||||
public static final Class<?> Cls_ref_type = Character.class;
|
||||
public static final char Null = '\0', NewLine = '\n';
|
||||
public static final int CharLen = 1;
|
||||
public static final int AsciiZero = 48;
|
||||
|
||||
@@ -30,17 +30,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 (ClassAdp_.Eq(c, String_.Cls_ref_type)) return (String)v;
|
||||
else if (ClassAdp_.Eq(c, Bry_.Cls_ref_type)) return String_.new_u8((byte[])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 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 = ClassAdp_.ClassOf_obj(v);
|
||||
if (ClassAdp_.Eq(c, String_.Cls_ref_type)) return (String)v;
|
||||
else if (ClassAdp_.Eq(c, Bry_.Cls_ref_type)) return String_.new_u8((byte[])v);
|
||||
else if (ClassAdp_.Eq(c, Bool_.Cls_ref_type)) return Bool_.cast_(v) ? Bool_.True_str : Bool_.False_str; // always return "true" / "false"
|
||||
else if (ClassAdp_.Eq(c, Double_.Cls_ref_type)) return Double_.Xto_str_loose(Double_.cast_(v));
|
||||
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_.Xto_str_loose(Double_.cast_(v));
|
||||
else return v.toString();
|
||||
}
|
||||
}
|
||||
@@ -17,14 +17,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx;
|
||||
public class Enm_ {
|
||||
public static int XtoInt(Object enm) {return Ordinal_lang(enm);}
|
||||
public static boolean HasInt(int val, int find) {return find == (val & find);}
|
||||
public static int AddInt(int lhs, int rhs) {return lhs | rhs;}
|
||||
public static int FlipInt(boolean enable, int val, int find) {
|
||||
public static int To_int(Object enm) {return Ordinal_lang(enm);}
|
||||
public static boolean Has_int(int val, int find) {return find == (val & find);}
|
||||
public static int Add_int(int lhs, int rhs) {return lhs | rhs;}
|
||||
public static int Flip_int(boolean enable, int val, int find) {
|
||||
boolean has = find == (val & find);
|
||||
return (has ^ enable) ? val ^ find : val;
|
||||
}
|
||||
public static boolean Has_byte(byte val, byte find) {return find == (val & find);}
|
||||
public static byte Add_byte(byte flag, byte itm) {return (byte)(flag | itm);}
|
||||
static int Ordinal_lang(Object v) {return ((Enum)v).ordinal();}
|
||||
public static boolean Has_byte(byte val, byte find) {return find == (val & find);}
|
||||
public static byte Add_byte(byte flag, byte itm) {return (byte)(flag | itm);}
|
||||
private static int Ordinal_lang(Object v) {return ((Enum)v).ordinal();}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public class KeyVal_ {
|
||||
KeyVal itm = ary[i];
|
||||
sb.Add(itm.Key()).Add("=");
|
||||
Object itm_val = itm.Val();
|
||||
if (ClassAdp_.Eq_typeSafe(itm_val, KeyVal[].class))
|
||||
if (Type_adp_.Eq_typeSafe(itm_val, KeyVal[].class))
|
||||
sb.Add(Ary_x_to_str((KeyVal[])itm_val));
|
||||
else
|
||||
sb.Add(Object_.Xto_str_strict_or_null_mark(itm_val));
|
||||
@@ -79,13 +79,13 @@ public class KeyVal_ {
|
||||
if (val == null)
|
||||
bfr.Add_str(String_.Null_mark);
|
||||
else {
|
||||
Class<?> val_type = ClassAdp_.ClassOf_obj(val);
|
||||
if (ClassAdp_.Eq(val_type, KeyVal[].class)) { // val is KeyVal[]; recurse
|
||||
Class<?> val_type = Type_adp_.ClassOf_obj(val);
|
||||
if (Type_adp_.Eq(val_type, KeyVal[].class)) { // val is KeyVal[]; recurse
|
||||
bfr.Add_byte_nl(); // add nl : "\n"
|
||||
Ary_xto_str_nested(bfr, indent + 1, (KeyVal[])val);
|
||||
continue; // don't add \n below
|
||||
}
|
||||
else if (ClassAdp_.Eq(val_type, Bool_.Cls_ref_type)) { // val is boolean
|
||||
else if (Type_adp_.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
|
||||
}
|
||||
|
||||
@@ -27,8 +27,9 @@ public class Hash_adp_bry extends gplx.lists.Hash_adp_base implements Hash_adp {
|
||||
@Override protected Object Fetch_base(Object key) {return super.Fetch_base(key_ref.Init((byte[])key));}
|
||||
@Override protected void Del_base(Object key) {super.Del_base(key_ref.Init((byte[])key));}
|
||||
@Override protected boolean Has_base(Object key) {return super.Has_base(key_ref.Init((byte[])key));}
|
||||
public int Get_as_int(byte[] key) {
|
||||
Object o = Get_by_bry(key); if (key == null) throw Err_.new_("core", "unknown key", "key", key);
|
||||
public int Get_as_int(byte[] key) {return Get_as_int(key, 0, key.length);}
|
||||
public int Get_as_int(byte[] key, int bgn, int end) {
|
||||
Object o = Get_by_mid(key, bgn, end); if (o == null) throw Err_.new_("core", "unknown key", "key", key);
|
||||
return ((Int_obj_val)o).Val();
|
||||
}
|
||||
public Object Get_by_bry(byte[] src) {return super.Fetch_base(key_ref.Init(src));}
|
||||
|
||||
@@ -360,7 +360,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", ClassAdp_.NameOf_obj(closeable), "url", url_str);
|
||||
throw Err_.new_exc(e, "io", "close object failed", "class", Type_adp_.NameOf_obj(closeable), "url", url_str);
|
||||
// else
|
||||
// UsrDlg_._.Finally("failed to close FileChannel", "url", url, "apiErr", Err_.Message_err_arg(e));
|
||||
}
|
||||
@@ -437,8 +437,8 @@ public class IoEngine_system extends IoEngine_base {
|
||||
}
|
||||
catch (Exception exc) {
|
||||
xrg.Rslt_err_(exc);
|
||||
if (ClassAdp_.Eq_typeSafe(exc, java.net.UnknownHostException.class)) xrg.Rslt_(IoEngine_xrg_downloadFil.Rslt_fail_host_not_found);
|
||||
else if (ClassAdp_.Eq_typeSafe(exc, java.io.FileNotFoundException.class)) xrg.Rslt_(IoEngine_xrg_downloadFil.Rslt_fail_file_not_found);
|
||||
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);
|
||||
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");
|
||||
@@ -624,8 +624,8 @@ class Io_stream_rdr_http implements Io_stream_rdr {
|
||||
read_done = read_failed = true;
|
||||
len = -1;
|
||||
xrg.Rslt_err_(exc);
|
||||
if (ClassAdp_.Eq_typeSafe(exc, java.net.UnknownHostException.class)) xrg.Rslt_(IoEngine_xrg_downloadFil.Rslt_fail_host_not_found);
|
||||
else if (ClassAdp_.Eq_typeSafe(exc, java.io.FileNotFoundException.class)) xrg.Rslt_(IoEngine_xrg_downloadFil.Rslt_fail_file_not_found);
|
||||
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);
|
||||
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");
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx;
|
||||
public class ClassAdp_ {
|
||||
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;
|
||||
@@ -42,5 +42,35 @@ public class ClassAdp_ {
|
||||
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 final byte Tid_bool = 1, Tid_byte = 2, Tid_int = 3, Tid_long = 4, Tid_float = 5, Tid_double = 6, Tid_char = 7, Tid_str = 8, Tid_date = 9, Tid_decimal = 10, Tid_bry = 11;
|
||||
public static int To_tid(Object o) {
|
||||
if (o == null) return Tid__null;
|
||||
Class<?> type = o.getClass();
|
||||
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, Char_.Cls_ref_type)) return Tid__char;
|
||||
else return Tid__obj;
|
||||
}
|
||||
public static final int
|
||||
Tid__obj = 0
|
||||
, Tid__null = 1
|
||||
, Tid__bool = 2
|
||||
, Tid__byte = 3
|
||||
, Tid__int = 4
|
||||
, Tid__long = 5
|
||||
, Tid__float = 6
|
||||
, Tid__double = 7
|
||||
, Tid__char = 8
|
||||
, Tid__str = 9
|
||||
, Tid__date = 10
|
||||
, Tid__decimal = 11
|
||||
, Tid__bry = 12
|
||||
;
|
||||
}
|
||||
@@ -22,7 +22,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 ClassAdp_.Eq_typeSafe(obj, UnderClass());
|
||||
return Type_adp_.Eq_typeSafe(obj, UnderClass());
|
||||
}
|
||||
@gplx.Virtual public int compareTo(Object lhs, Object rhs) {return CompareAble_.Compare_obj(lhs, rhs);}
|
||||
}
|
||||
|
||||
@@ -258,11 +258,11 @@ interface XtoStrWkr {
|
||||
class XtoStrWkr_gplx implements XtoStrWkr {
|
||||
public String To_str(Object o) {
|
||||
if (o == null) return "<<NULL>>";
|
||||
Class<?> type = ClassAdp_.ClassOf_obj(o);
|
||||
Class<?> type = Type_adp_.ClassOf_obj(o);
|
||||
String rv = null;
|
||||
if (type == String.class) rv = String_.cast_(o);
|
||||
else if (Int_.TypeMatch(type)) return Int_.Xto_str(Int_.cast_(o));
|
||||
else if (ClassAdp_.Eq(type, Bool_.Cls_ref_type)) return Yn.Xto_str(Bool_.cast_(o));
|
||||
else if (Type_adp_.Eq(type, Bool_.Cls_ref_type)) return Yn.Xto_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, "'", "''");
|
||||
|
||||
@@ -96,10 +96,10 @@ class GfsCore_ {
|
||||
if (rv == GfoInvkAble_.Rv_cancel) return rv;
|
||||
else if (rv == GfoInvkAble_.Rv_unhandled) {
|
||||
if (ctx.Fail_if_unhandled())
|
||||
throw Err_.new_wo_type("Object does not support key", "key", owner_msg.Key(), "ownerType", ClassAdp_.FullNameOf_obj(owner_invk));
|
||||
throw Err_.new_wo_type("Object does not support key", "key", owner_msg.Key(), "ownerType", Type_adp_.FullNameOf_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(), ClassAdp_.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_adp_.FullNameOf_obj(owner_invk));
|
||||
return GfoInvkAble_.Null;
|
||||
}
|
||||
}
|
||||
@@ -118,8 +118,8 @@ class GfsCore_ {
|
||||
Class<?> type = rv.getClass();
|
||||
if (type == String.class) invk = String_.Gfs;
|
||||
else if (Int_.TypeMatch(type)) invk = Int_.Gfs;
|
||||
else if (ClassAdp_.Eq(type, Bool_.Cls_ref_type)) invk = Bool_.Gfs;
|
||||
else throw Err_.new_wo_type("unknown primitive", "type", ClassAdp_.NameOf_type(type), "obj", Object_.Xto_str_strict_or_null_mark(rv));
|
||||
else if (Type_adp_.Eq(type, Bool_.Cls_ref_type)) invk = Bool_.Gfs;
|
||||
else throw Err_.new_wo_type("unknown primitive", "type", Type_adp_.NameOf_type(type), "obj", Object_.Xto_str_strict_or_null_mark(rv));
|
||||
primitive = rv;
|
||||
}
|
||||
Object exec_rv = null;
|
||||
|
||||
@@ -22,7 +22,7 @@ class GfsRegy implements GfoInvkAble {
|
||||
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(GfoInvkAble invk) {return (GfsRegyItm)typeHash.Get_by(ClassAdp_.FullNameOf_obj(invk));}
|
||||
public GfsRegyItm FetchByType(GfoInvkAble invk) {return (GfsRegyItm)typeHash.Get_by(Type_adp_.FullNameOf_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;
|
||||
@@ -31,7 +31,7 @@ class GfsRegy implements GfoInvkAble {
|
||||
public void AddCmd(GfoInvkAble invk, String key) {Add(key, invk, true);}
|
||||
public void Add(String key, GfoInvkAble invk, boolean typeCmd) {
|
||||
if (hash.Has(key)) return;
|
||||
GfsRegyItm regyItm = new GfsRegyItm().Key_(key).InvkAble_(invk).IsCmd_(typeCmd).TypeKey_(ClassAdp_.FullNameOf_obj(invk));
|
||||
GfsRegyItm regyItm = new GfsRegyItm().Key_(key).InvkAble_(invk).IsCmd_(typeCmd).TypeKey_(Type_adp_.FullNameOf_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;
|
||||
}
|
||||
|
||||
@@ -21,10 +21,12 @@ public class Tfds { // URL:doc/gplx.tfds/Tfds.txt
|
||||
public static boolean SkipDb = false;
|
||||
public static void Eq_bool (boolean expd , boolean actl, String fmt, Object... args) {Eq_exec_y(expd, actl, fmt, args);}
|
||||
public static void Eq_byte (byte expd , byte actl, String fmt, Object... args) {Eq_exec_y(expd, actl, fmt, args);}
|
||||
public static void Eq_int (int expd , int actl) {Eq_exec_y(expd, actl, "", Object_.Ary_empty);}
|
||||
public static void Eq_int (int expd , int actl, String fmt, Object... args) {Eq_exec_y(expd, actl, fmt, args);}
|
||||
public static void Eq_str (byte[] expd, byte[] actl, String fmt, Object... args) {Eq_exec_y(String_.new_u8(expd), String_.new_u8(actl), fmt, args);}
|
||||
public static void Eq_str (byte[] expd, String actl, String fmt, Object... args) {Eq_exec_y(String_.new_u8(expd), actl, fmt, args);}
|
||||
public static void Eq_str (String expd, byte[] actl, String fmt, Object... args) {Eq_exec_y(expd, String_.new_u8(actl), fmt, args);}
|
||||
public static void Eq_str (String expd, String actl) {Eq_exec_y(expd, actl, "", Object_.Ary_empty);}
|
||||
public static void Eq_str (String expd, String actl, String fmt, Object... args) {Eq_exec_y(expd, actl, fmt, args);}
|
||||
|
||||
public static void Eq(Object expd, Object actl) {Eq_wkr(expd, actl, true, EmptyStr);}
|
||||
@@ -138,8 +140,8 @@ public class Tfds { // URL:doc/gplx.tfds/Tfds.txt
|
||||
list.Add(itm);
|
||||
}
|
||||
public static void Err_classMatch(Exception exc, Class<?> type) {
|
||||
boolean match = ClassAdp_.Eq_typeSafe(exc, type);
|
||||
if (!match) throw Err_.new_("Tfds", "error types do not match", "expdType", ClassAdp_.FullNameOf_type(type), "actlType", ClassAdp_.NameOf_obj(exc), "actlMsg", Err_.Message_lang(exc));
|
||||
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));
|
||||
}
|
||||
public static void Eq_err(Err expd, Exception actlExc) {
|
||||
Tfds.Eq(Err_.Message_gplx_full(expd), Err_.Message_gplx_full(actlExc));
|
||||
|
||||
Reference in New Issue
Block a user