mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
Core: Refactor base classes
This commit is contained in:
@@ -18,9 +18,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.core.consoles; import gplx.*; import gplx.core.*;
|
||||
public class Gfo_cmd_arg_itm {
|
||||
public Gfo_cmd_arg_itm(int tid, boolean reqd, String key, int val_tid) {this.tid = tid; this.reqd = reqd; this.key = key; this.val_tid = val_tid;}
|
||||
public int Tid() {return tid;} private final int tid;
|
||||
public boolean Reqd() {return reqd;} private final boolean reqd;
|
||||
public String Key() {return key;} private final String key;
|
||||
public int Tid() {return tid;} private final int tid;
|
||||
public boolean Reqd() {return reqd;} private final boolean reqd;
|
||||
public String Key() {return key;} private final String key;
|
||||
public int Val_tid() {return val_tid;} private int val_tid;
|
||||
public Object Val() {return val;} public Gfo_cmd_arg_itm Val_(Object v) {this.val = v; dirty = true; return this;} private Object val;
|
||||
public String Note() {return note;} public Gfo_cmd_arg_itm Note_(String v) {note = v; return this;} private String note = "";
|
||||
@@ -45,7 +45,7 @@ public class Gfo_cmd_arg_itm {
|
||||
default: return "unknown";
|
||||
}
|
||||
}
|
||||
public boolean Val_as_bool() {return Bool_.cast(val);}
|
||||
public boolean Val_as_bool() {return Bool_.Cast(val);}
|
||||
public String Val_as_str_or(String or) {return val == null ? or : (String)val;}
|
||||
public String Val_as_str() {return (String)val;}
|
||||
public int Val_as_int_or(int or) {return val == null ? or : Int_.parse_or((String)val, or);}
|
||||
|
||||
@@ -203,8 +203,8 @@ public class Gfh_utl {// TS:Gfo_url_encoder is TS
|
||||
return bfr.To_str_and_clear();
|
||||
}
|
||||
public static void Log(Exception e, String head, byte[] page_url, byte[] src, int pos) {
|
||||
Err err = Err_.cast_or_make(e); if (err.Logged()) return;
|
||||
String msg = String_.Format("{0}; page={1} err={2} mid={3} trace={4}", head, page_url, Err_.To_str(e), Bry_.Escape_ws(Bry_.Mid_by_len_safe(src, pos, 255)), err.To_str__log());
|
||||
Err err = Err_.Cast_or_make(e); if (err.Logged()) return;
|
||||
String msg = String_.Format("{0}; page={1} err={2} mid={3} trace={4}", head, page_url, Err_.Message_lang(e), Bry_.Escape_ws(Bry_.Mid_by_len_safe(src, pos, 255)), err.To_str__log());
|
||||
Gfo_usr_dlg_.Instance.Warn_many("", "", msg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public class Json_kv_ary_srl {
|
||||
}
|
||||
private static Object Val_by_itm(Json_itm itm) {
|
||||
switch (itm.Tid()) {
|
||||
case Json_itm_.Tid__bool: return Bool_.To_str_lower(Bool_.cast(itm.Data()));
|
||||
case Json_itm_.Tid__bool: return Bool_.To_str_lower(Bool_.Cast(itm.Data()));
|
||||
case Json_itm_.Tid__int:
|
||||
case Json_itm_.Tid__null:
|
||||
case Json_itm_.Tid__str:
|
||||
|
||||
@@ -165,7 +165,7 @@ 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__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;
|
||||
|
||||
@@ -33,7 +33,7 @@ public class Srch_html_row_wkr {
|
||||
public void On_rslt_found(Srch_rslt_row new_row) {
|
||||
Srch_rslt_row last_row = rows[rows_len - 1];
|
||||
if (last_row != null) {
|
||||
if (Compare(new_row, last_row) == CompareAble_.MoreOrSame) return; // new_row is < last_row; exit
|
||||
if (Compare(new_row, last_row) == CompareAble_.More_or_same) return; // new_row is < last_row; exit
|
||||
}
|
||||
int new_row_slot = Find_insert_slot(new_row); if (new_row_slot == -1) return;
|
||||
Srch_rslt_row insert_row = rows[new_row_slot];
|
||||
|
||||
@@ -40,7 +40,7 @@ public class Xoi_mirror_parser {
|
||||
int len = ary.length;
|
||||
for (int i = len - 1; i > -1; i--) {
|
||||
String itm = ary[i];
|
||||
if (CompareAble_.Is_lessOrSame(itm, comp)) return itm;
|
||||
if (CompareAble_.Is(CompareAble_.Less_or_same, itm, comp)) return itm;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ public class Site_core_tbl implements Db_tbl {
|
||||
try {
|
||||
while (rdr.Move_next()) {
|
||||
Site_core_itm itm = new_itm(rdr);
|
||||
if (itm.Json_date().compareTo(cutoff) == CompareAble_.MoreOrSame) continue; // ignore those downloaded after cutoff date
|
||||
if (itm.Json_date().compareTo(cutoff) == CompareAble_.More_or_same) continue; // ignore those downloaded after cutoff date
|
||||
itm.Json_text_null_();
|
||||
list.Add(itm);
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ public class Xog_mnu_bldr {
|
||||
Gfui_mnu_itm mnu_itm = owner_gui.Itms_add_chk_msg(sub.Gui_text(), img, app, app.Gfs_mgr(), msg_n, msg_y);
|
||||
sub.Evt_mgr().Sub(mnu_itm);
|
||||
Xog_cmd_itm cmd = app.Gui_mgr().Cmd_mgr().Get_or_null(sub.Key());
|
||||
boolean v = Bool_.cast(app.Gfs_mgr().Run_str_for(app, cmd.Cmd()));
|
||||
boolean v = Bool_.Cast(app.Gfs_mgr().Run_str_for(app, cmd.Cmd()));
|
||||
mnu_itm.Selected_(v);
|
||||
return mnu_itm;
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ public class Xog_html_itm implements Xog_js_wkr, Gfo_invk, Gfo_evt_itm {
|
||||
Gfo_invk_.Invk_by_msg(cmd_sync, Invk_html_elem_delete, m);
|
||||
}
|
||||
@gplx.Virtual public String Html_elem_atr_get_str(String id, String atr_key) {return html_box.Html_js_eval_proc_as_str(Xog_js_procs.Doc__atr_get_as_obj, id, atr_key);}
|
||||
@gplx.Virtual public boolean Html_elem_atr_get_bool(String id, String atr_key) {return Bool_.parse(html_box.Html_js_eval_proc_as_str(Xog_js_procs.Doc__atr_get_to_str, id, atr_key));}
|
||||
@gplx.Virtual public boolean Html_elem_atr_get_bool(String id, String atr_key) {return Bool_.Parse(html_box.Html_js_eval_proc_as_str(Xog_js_procs.Doc__atr_get_to_str, id, atr_key));}
|
||||
|
||||
|
||||
public void Html_atr_set(String elem_id, String atr_key, String atr_val) {
|
||||
|
||||
@@ -18,10 +18,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.htmls.bridges; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import gplx.langs.jsons.*;
|
||||
public class Bridge_msg_bldr {
|
||||
private final Json_wtr wtr = new Json_wtr();
|
||||
private final Json_wtr wtr = new Json_wtr();
|
||||
private boolean rslt_pass; private String rslt_msg;
|
||||
private String notify_text; private String notify_status;
|
||||
private final Gfo_tree_list data_root = new Gfo_tree_list("data");
|
||||
private final Gfo_tree_list data_root = new Gfo_tree_list("data");
|
||||
public Bridge_msg_bldr() {
|
||||
wtr.Opt_ws_(Bool_.N);
|
||||
this.Clear();
|
||||
@@ -83,7 +83,7 @@ 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__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;
|
||||
default: wtr.Kv_str(key, Object_.Xto_str_strict_or_null_mark(val)); break;
|
||||
@@ -96,7 +96,7 @@ public class Bridge_msg_bldr {
|
||||
}
|
||||
wtr.Nde_end();
|
||||
}
|
||||
private static final byte[]
|
||||
private static final byte[]
|
||||
Key_rslt = Bry_.new_a7("rslt"), Key_rslt_pass = Bry_.new_a7("pass"), Key_rslt_msg = Bry_.new_a7("msg")
|
||||
, Key_notify = Bry_.new_a7("notify"), Key_notify_text = Bry_.new_a7("text"), Key_notify_status = Bry_.new_a7("status"), Key_notify_hint = Bry_.new_a7("hint")
|
||||
;
|
||||
|
||||
@@ -49,7 +49,7 @@ public class Xoh_js_cbk implements Gfo_invk {
|
||||
Xop_ctx ctx = wiki.Parser_mgr().Ctx();
|
||||
boolean old_para_enabled = ctx.Para().Enabled();
|
||||
byte[] raw = Bry_.new_u8(m.Args_getAt(0).Val_to_str_or_empty());
|
||||
boolean para_enabled = m.Args_count() < 2 ? false : Bool_.parse(m.Args_getAt(1).Val_to_str_or_empty());
|
||||
boolean para_enabled = m.Args_count() < 2 ? false : Bool_.Parse(m.Args_getAt(1).Val_to_str_or_empty());
|
||||
try {
|
||||
ctx.Para().Enabled_(para_enabled);
|
||||
wiki.Parser_mgr().Main().Parse_text_to_wdom(root, ctx, ctx.Tkn_mkr(), raw, 0);
|
||||
|
||||
@@ -70,7 +70,7 @@ public class Xot_invk_mock implements Xot_invk {
|
||||
if (Type_adp_.Eq_typeSafe(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
|
||||
boolean kv_val_bool = Bool_.cast(kv.Val());
|
||||
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)
|
||||
else
|
||||
@@ -82,7 +82,7 @@ public class Xot_invk_mock implements Xot_invk {
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public static final Xot_invk_mock Null = new Xot_invk_mock(Xot_defn_.Tid_null, 1, Bry_.Empty);
|
||||
public static final Xot_invk_mock Null = new Xot_invk_mock(Xot_defn_.Tid_null, 1, Bry_.Empty);
|
||||
}
|
||||
/*
|
||||
NOTE_1: Xot_invk_mock is being used as a container for two functions
|
||||
|
||||
@@ -98,7 +98,7 @@ public class Xot_tmpl_wtr {
|
||||
tkn.Tmpl_evaluate(ctx, src, Xot_invk_temp.Page_is_caller.Src_(src), rslt_bfr);
|
||||
}
|
||||
catch (Exception e) {
|
||||
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();
|
||||
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();
|
||||
if (Env_.Mode_testing())
|
||||
throw Err_.new_exc(e, "xo", Err_string);
|
||||
else
|
||||
|
||||
@@ -179,6 +179,6 @@ class Gfui_html_mok extends Xog_html_itm { private Hash_adp elem_atrs = Hash_adp
|
||||
return (String)elem_atrs.Get_by(id + "." + atr_key);
|
||||
}
|
||||
@Override public boolean Html_elem_atr_get_bool(String id, String atr_key) {
|
||||
return Bool_.parse((String)elem_atrs.Get_by(id + "." + atr_key));
|
||||
return Bool_.Parse((String)elem_atrs.Get_by(id + "." + atr_key));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ public class Xodb_load_mgr_txt implements Xodb_load_mgr {
|
||||
Int_obj_ref count = Int_obj_ref.New_zero();
|
||||
Xob_random_itm[] files = Build_random_itms(regy_mgr, count);
|
||||
int random_idx = RandomAdp_.new_().Next(count.Val() - 1); // get a random idx; -1 since count is super 1 (EX: count of 1 mil; random_idx of 0 - 999,999)
|
||||
int file_idx = CompareAble_.FindSlot(Xob_random_itm_comparer.Instance, files, new Xob_random_itm(-1, random_idx, -1));
|
||||
int file_idx = Xowd_regy_mgr_.FindSlot(Xob_random_itm_comparer.Instance, files, new Xob_random_itm(-1, random_idx, -1));
|
||||
Io_url file_url = fsys_mgr.Url_ns_fil(Xotdb_dir_info_.Tid_ttl, ns.Id(), file_idx);
|
||||
Load_xdat_file(Cancelable_.Never, tmp_xdat_file, file_url);
|
||||
Xob_random_itm file = files[file_idx];
|
||||
|
||||
@@ -25,7 +25,7 @@ public class Xow_html_util implements Gfo_invk {
|
||||
} private static final String Invk_if_bool = "if_bool", Invk_if_yn = "if_yn";
|
||||
String If_bool(String expr, String true_val, String false_val) {
|
||||
Object o = wiki.Appe().Gfs_mgr().Run_str(expr);
|
||||
try {return Bool_.cast(o) ? true_val : false_val;}
|
||||
try {return Bool_.Cast(o) ? true_val : false_val;}
|
||||
catch (Exception e) {Err_.Noop(e); return "expr failed: " + expr;}
|
||||
}
|
||||
String If_yn(String expr, String true_val, String false_val) {
|
||||
|
||||
@@ -27,7 +27,7 @@ public class Xowd_regy_mgr {
|
||||
public void Clear() {files_ary = Xowd_hive_regy_itm.Ary_empty;}
|
||||
public int Files_find(byte[] key) {
|
||||
if (files_ary.length == 0) return Xowd_regy_mgr.Regy_null; // NOTE: FindSlot does not accept empty ary; returning 0, b/c Find returns likely file_idx; EX: regy of 0|B|D and 1|F|H; A returns 0; Z returns 1
|
||||
return CompareAble_.FindSlot(comparer, files_ary, comparer_itm.End_(key));
|
||||
return Xowd_regy_mgr_.FindSlot(comparer, files_ary, comparer_itm.End_(key));
|
||||
} ComparerAble comparer = Xowd_ttl_file_comparer_end.Instance; Xowd_hive_regy_itm comparer_itm = Xowd_hive_regy_itm.tmp_().Count_(1);
|
||||
public Xowd_hive_regy_itm Create(byte[] key) {
|
||||
int itm_idx = files_ary.length;
|
||||
|
||||
44
400_xowa/src/gplx/xowa/wikis/tdbs/hives/Xowd_regy_mgr_.java
Normal file
44
400_xowa/src/gplx/xowa/wikis/tdbs/hives/Xowd_regy_mgr_.java
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.xowa.wikis.tdbs.hives; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.tdbs.*;
|
||||
import gplx.core.lists.*;
|
||||
public class Xowd_regy_mgr_ {
|
||||
public static int FindSlot(ComparerAble comparer, Object[] ary, Object itm) {if (itm == null) throw Err_.new_null();
|
||||
int aryLen = ary.length;
|
||||
switch (aryLen) {
|
||||
case 0: throw Err_.new_wo_type("ary cannot have 0 itms");
|
||||
case 1: return 0;
|
||||
}
|
||||
int lo = -1, hi = aryLen - 1; // NOTE: -1 is necessary; see test
|
||||
int curPos = (hi - lo) / 2;
|
||||
int delta = 1;
|
||||
while (true) {
|
||||
Object curSeg = ary[curPos];
|
||||
int comp = curSeg == null ? CompareAble_.More : comparer.compare(itm, curSeg); // nulls should only happen for lastAry
|
||||
// if (dbg) {
|
||||
// Tfds.Write(curPos, itm.toString(), comp, comp.toString(), curSeg.toString());
|
||||
// }
|
||||
if (comp == CompareAble_.Same) return curPos;
|
||||
else if (comp > CompareAble_.Same) {lo = curPos; delta = 1;}
|
||||
else if (comp < CompareAble_.Same) {hi = curPos; delta = -1;}
|
||||
int dif = hi - lo;
|
||||
if (dif == 1 || dif == 0) return hi; // NOTE: can be 0 when ary.length == 1 || 2; also, sometimes 0 in some situations
|
||||
else curPos += (dif / 2) * delta;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.xowa.wikis.tdbs.hives; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.tdbs.*;
|
||||
import org.junit.*; import gplx.core.lists.*;
|
||||
public class Xowd_regy_mgr__tst implements ComparerAble {
|
||||
@Test public void Basic() {
|
||||
String[] slotAry = new String[] {"b", "e", "h"}; // 0=b 1=e 2=h
|
||||
tst_FindSlot(slotAry, "f", "h"); // f -> 1 2 -> 2
|
||||
tst_FindSlot(slotAry, "c", "e"); // c -> -1 1 -> 0 -> 0 1 -> 1
|
||||
tst_FindSlot(slotAry, "a", "b"); // a -> -1 1 -> 0 -> -1 0 -> 0
|
||||
}
|
||||
@Test public void Null() {
|
||||
String[] slotAry = new String[] {"b", "g", "l", "q", "v", null};
|
||||
tst_FindSlot(slotAry, "a", "b");
|
||||
tst_FindSlot(slotAry, "b", "b");
|
||||
tst_FindSlot(slotAry, "c", "g");
|
||||
tst_FindSlot(slotAry, "v", "v");
|
||||
tst_FindSlot(slotAry, "w", null);
|
||||
}
|
||||
public int compare(Object lhsObj, Object rhsObj) {return CompareAble_.Compare_obj(lhsObj, rhsObj);}
|
||||
void tst_FindSlot(String[] slotAry, String s, String expd) {Tfds.Eq(expd, slotAry[gplx.xowa.wikis.tdbs.hives.Xowd_regy_mgr_.FindSlot(this, slotAry, s)]);}
|
||||
}
|
||||
@@ -63,7 +63,7 @@ public class Scrib_invoke_func extends Pf_func_base {
|
||||
invoke_wkr.Eval_end(ctx.Page(), mod_name, fnc_name, log_time_bgn);
|
||||
}
|
||||
catch (Throwable e) {
|
||||
Err err = Err_.cast_or_make(e);
|
||||
Err err = Err_.Cast_or_make(e);
|
||||
Error(bfr, wiki.Msg_mgr(), err);
|
||||
Scrib_err_filter_mgr err_filter_mgr = invoke_wkr == null ? null : invoke_wkr.Err_filter_mgr();
|
||||
if ( err_filter_mgr == null // no err_filter_mgr defined;
|
||||
@@ -73,7 +73,7 @@ public class Scrib_invoke_func extends Pf_func_base {
|
||||
wiki.Parser_mgr().Scrib().Terminate_when_page_changes_y_(); // NOTE: terminate core when page changes; not terminating now, else page with many errors will be very slow due to multiple remakes of core; PAGE:th.d:all; DATE:2014-10-03
|
||||
}
|
||||
}
|
||||
public static void Error(Bry_bfr bfr, Xow_msg_mgr msg_mgr, Err err) {Error(bfr, msg_mgr, Err_.cast_or_make(err).To_str__top_wo_args());}// NOTE: must use "short" error message to show in wikitext; DATE:2015-07-27
|
||||
public static void Error(Bry_bfr bfr, Xow_msg_mgr msg_mgr, Err err) {Error(bfr, msg_mgr, Err_.Cast_or_make(err).To_str__top_wo_args());}// NOTE: must use "short" error message to show in wikitext; DATE:2015-07-27
|
||||
public static void Error(Bry_bfr bfr, Xow_msg_mgr msg_mgr, String error) {
|
||||
// for Luaj, msg combines both err; split out traceback else error message will be very long; note that Warn_many will still log traceback; DATE:2016-09-09
|
||||
String error_visible = error;
|
||||
|
||||
@@ -88,7 +88,7 @@ public class Scrib_invoke_func_fxt {
|
||||
fxt.Test_parse_page_tmpl_str(raw, tmp_bfr.To_str_and_clear());
|
||||
}
|
||||
public void Test_error(Exception e, String expd) {
|
||||
Scrib_invoke_func.Error(tmp_bfr, fxt.Wiki().Msg_mgr(), Err_.cast_or_make(e));
|
||||
Scrib_invoke_func.Error(tmp_bfr, fxt.Wiki().Msg_mgr(), Err_.Cast_or_make(e));
|
||||
Tfds.Eq_str(expd, tmp_bfr.To_str_and_clear(), "error");
|
||||
}
|
||||
public void Test_lib_proc(Scrib_lib lib, String func_name, Object[] args, String expd) {Test_lib_proc_kv(lib, func_name, Scrib_kv_utl_.base1_many_(args), expd);}
|
||||
@@ -214,7 +214,7 @@ class Scrib_lua_rsp_bldr {
|
||||
Class<?> v_type = v.getClass();
|
||||
if (Object_.Eq(v_type, Int_.Cls_ref_type)) Bld_int(bfr, Int_.cast(v));
|
||||
else if (Object_.Eq(v_type, String_.Cls_ref_type)) Bld_str(bfr, String_.cast(v));
|
||||
else if (Object_.Eq(v_type, Bool_.Cls_ref_type)) Bld_bool(bfr, Bool_.cast(v));
|
||||
else if (Object_.Eq(v_type, Bool_.Cls_ref_type)) Bld_bool(bfr, Bool_.Cast(v));
|
||||
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);
|
||||
|
||||
@@ -82,7 +82,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);
|
||||
if (Object_.Eq(c, Bool_.Cls_ref_type)) Encode_bool(bfr, Bool_.cast(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));
|
||||
else if (Object_.Eq(c, Double_.Cls_ref_type)) {if (!Encode_double(bfr, Double_.cast(o))) return false;}
|
||||
|
||||
@@ -75,7 +75,7 @@ class Process_server_mock_rcvd_val implements Process_server_mock_rcvd {
|
||||
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))
|
||||
bfr.Add(Bool_.cast(kv_val) ? gplx.langs.jsons.Json_itm_.Bry__true : gplx.langs.jsons.Json_itm_.Bry__false);
|
||||
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;
|
||||
if (sub.length == 0) {bfr.Add_byte(Byte_ascii.Curly_bgn).Add_byte(Byte_ascii.Curly_end);}
|
||||
|
||||
@@ -174,7 +174,7 @@ public class Scrib_lib_language implements Scrib_lib {
|
||||
if (kv_ary != null) {
|
||||
Object skip_commafy_obj = Keyval_.Ary_get_by_key_or_null(kv_ary, "noCommafy");
|
||||
if (skip_commafy_obj != null)
|
||||
skip_commafy = Bool_.cast(skip_commafy_obj);
|
||||
skip_commafy = Bool_.Cast(skip_commafy_obj);
|
||||
}
|
||||
}
|
||||
byte[] rv = lang.Num_mgr().Format_num(num, skip_commafy);
|
||||
|
||||
@@ -81,7 +81,7 @@ class Scrib_lib_message_data {
|
||||
break;
|
||||
case Key_tid_rawMessage: raw_msg_key = kv.Val_to_bry(); break;
|
||||
case Key_tid_lang: lang_key = kv.Val_to_bry(); break;
|
||||
case Key_tid_useDB: use_db = Bool_.cast(kv.Val()); break;
|
||||
case Key_tid_useDB: use_db = Bool_.Cast(kv.Val()); break;
|
||||
case Key_tid_title: title_bry = kv.Val_to_bry(); break;
|
||||
case Key_tid_params:
|
||||
Keyval[] args_ary = (Keyval[])kv.Val();
|
||||
|
||||
@@ -178,7 +178,7 @@ class Scrib_lib_text__json_util {
|
||||
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_adp_.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) {
|
||||
|
||||
@@ -166,7 +166,7 @@ public class Scrib_lib_ustring implements Scrib_lib {
|
||||
for (int j = 0; j < grps_len; j++) {
|
||||
Regx_group grp = grps[j];
|
||||
if ( j < capts_len // bounds check b/c null can be passed
|
||||
&& Bool_.cast(capts[j].Val()) // check if true; indicates that group is "()" or "anypos" see regex converter; DATE:2014-04-23
|
||||
&& Bool_.Cast(capts[j].Val()) // check if true; indicates that group is "()" or "anypos" see regex converter; DATE:2014-04-23
|
||||
)
|
||||
tmp_list.Add(grp.Bgn() + Scrib_lib_ustring.Base1); // return index only for "()"; NOTE: do not return as String; callers expect int and will fail typed comparisons; DATE:2016-01-21
|
||||
else
|
||||
|
||||
@@ -52,7 +52,7 @@ public class Scrib_proc_args {
|
||||
public int Len() {return ary_len;}
|
||||
public Keyval[] Ary() {return ary;}
|
||||
public Object Pull_obj(int i) {return Get_or_fail(i);}
|
||||
public boolean Pull_bool(int i) {return Bool_.cast(Get_or_fail(i));}
|
||||
public boolean Pull_bool(int i) {return Bool_.Cast(Get_or_fail(i));}
|
||||
public String Pull_str(int i) {return String_.cast(Get_or_fail(i));}
|
||||
public byte[] Pull_bry(int i) {return Bry_.new_u8(String_.cast(Get_or_fail(i)));}
|
||||
public int Pull_int(int i) {
|
||||
@@ -118,8 +118,8 @@ public class Scrib_proc_args {
|
||||
public byte[] Cast_bry_or_empty(int i) {Object rv = Get_or_null(i); return rv == null ? Bry_.Empty : Bry_.new_u8(String_.cast (rv));}
|
||||
public byte[] Cast_bry_or(int i, byte[] or) {Object rv = Get_or_null(i); return rv == null ? or : Bry_.new_u8(String_.cast (rv));}
|
||||
public Object Cast_obj_or_null(int i) {return Get_or_null(i);}
|
||||
public boolean Cast_bool_or_y(int i) {Object rv = Get_or_null(i); return rv == null ? Bool_.Y : Bool_.cast(rv);}
|
||||
public boolean Cast_bool_or_n(int i) {Object rv = Get_or_null(i); return rv == null ? Bool_.N : Bool_.cast(rv);}
|
||||
public boolean Cast_bool_or_y(int i) {Object rv = Get_or_null(i); return rv == null ? Bool_.Y : Bool_.Cast(rv);}
|
||||
public boolean Cast_bool_or_n(int i) {Object rv = Get_or_null(i); return rv == null ? Bool_.N : Bool_.Cast(rv);}
|
||||
public int Cast_int_or(int i, int or) {Object rv = Get_or_null(i); return rv == null ? or : Int_.coerce_(rv);} // coerce to handle "1" and 1;
|
||||
public Keyval[] Cast_kv_ary_or_null(int i) {Object rv = Get_or_null(i); return rv == null ? null : (Keyval[])rv;}
|
||||
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));
|
||||
|
||||
Reference in New Issue
Block a user