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

Refactor: Clean up Int_ classes

This commit is contained in:
gnosygnu
2017-10-22 08:07:00 -04:00
parent d270cce881
commit 3157551d1d
154 changed files with 609 additions and 577 deletions

View File

@@ -37,20 +37,20 @@ public class Bit__tst {
fxt.Test_shift_rhs(8, 1, 4);
}
@Test public void Shift_lhs_to_int() {
int[] shift_ary = Int_.Ary(0, 3, 5);
fxt.Test_shift_lhs_to_int(shift_ary, Int_.Ary(0, 0, 0), 0);
fxt.Test_shift_lhs_to_int(shift_ary, Int_.Ary(7, 0, 0), 7); // 1st 3 bits
fxt.Test_shift_lhs_to_int(shift_ary, Int_.Ary(0, 3, 0), 24); // 2nd 2 bits
fxt.Test_shift_lhs_to_int(shift_ary, Int_.Ary(0, 0, 1), 32); // 3rd 1 bit
fxt.Test_shift_lhs_to_int(shift_ary, Int_.Ary(7, 3, 1), 63); // many bits
int[] shift_ary = Int_ary_.New(0, 3, 5);
fxt.Test_shift_lhs_to_int(shift_ary, Int_ary_.New(0, 0, 0), 0);
fxt.Test_shift_lhs_to_int(shift_ary, Int_ary_.New(7, 0, 0), 7); // 1st 3 bits
fxt.Test_shift_lhs_to_int(shift_ary, Int_ary_.New(0, 3, 0), 24); // 2nd 2 bits
fxt.Test_shift_lhs_to_int(shift_ary, Int_ary_.New(0, 0, 1), 32); // 3rd 1 bit
fxt.Test_shift_lhs_to_int(shift_ary, Int_ary_.New(7, 3, 1), 63); // many bits
}
@Test public void Shift_rhs_to_ary() {
int[] shift_ary = Int_.Ary(0, 3, 5);
fxt.Test_shift_rhs_to_ary(shift_ary, 0, Int_.Ary(0, 0, 0));
fxt.Test_shift_rhs_to_ary(shift_ary, 7, Int_.Ary(7, 0, 0)); // 1st 3 bits
fxt.Test_shift_rhs_to_ary(shift_ary, 24, Int_.Ary(0, 3, 0)); // 2nd 2 bits
fxt.Test_shift_rhs_to_ary(shift_ary, 32, Int_.Ary(0, 0, 1)); // 3rd 1 bit
fxt.Test_shift_rhs_to_ary(shift_ary, 63, Int_.Ary(7, 3, 1)); // many bits
int[] shift_ary = Int_ary_.New(0, 3, 5);
fxt.Test_shift_rhs_to_ary(shift_ary, 0, Int_ary_.New(0, 0, 0));
fxt.Test_shift_rhs_to_ary(shift_ary, 7, Int_ary_.New(7, 0, 0)); // 1st 3 bits
fxt.Test_shift_rhs_to_ary(shift_ary, 24, Int_ary_.New(0, 3, 0)); // 2nd 2 bits
fxt.Test_shift_rhs_to_ary(shift_ary, 32, Int_ary_.New(0, 0, 1)); // 3rd 1 bit
fxt.Test_shift_rhs_to_ary(shift_ary, 63, Int_ary_.New(7, 3, 1)); // many bits
}
}
class Bit__fxt {
@@ -59,7 +59,7 @@ class Bit__fxt {
public void Test_shift_rhs(int val, int shift, int expd) {Tfds.Eq(expd, Bit_.Shift_rhs(val, shift));}
public void Test_shift_lhs_to_int(int[] shift_ary, int[] val_ary, int expd) {Tfds.Eq(expd, Bit_.Shift_lhs_to_int(shift_ary, val_ary));}
public void Test_shift_rhs_to_ary(int[] shift_ary, int val, int[] expd_ary) {
int[] actl_ary = Int_.Ary(0, 0, 0);
int[] actl_ary = Int_ary_.New(0, 0, 0);
Bit_.Shift_rhs_to_ary(actl_ary, shift_ary, val);
Tfds.Eq_ary(expd_ary, actl_ary);
}

View File

@@ -47,7 +47,7 @@ public class Gfo_cmd_arg_itm {
public boolean Val_as_bool_or(boolean or) {return val == null ? or : String_.Eq((String)val, "y");}
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);}
public int Val_as_int_or(int or) {return val == null ? or : Int_.Parse_or((String)val, or);}
public Io_url Val_as_url__rel_dir_or(Io_url owner_dir, Io_url or) {return Val_as_url__rel_url_or(Bool_.Y, owner_dir, or);}
public Io_url Val_as_url__rel_fil_or(Io_url owner_dir, Io_url or) {return Val_as_url__rel_url_or(Bool_.N, owner_dir, or);}
public Io_url Val_as_url__rel_url_or(boolean to_dir, Io_url owner_dir, Io_url or) {return Gfo_cmd_arg_itm_.Val_as_url__rel_url_or(Val_as_str(), to_dir, owner_dir, or);}

View File

@@ -46,7 +46,7 @@ public class Gfo_url_parser {
if (!rel) { // search for ":"; NOTE: only search if not rel; i.e.: "//"
int colon_pos = Bry_find_.Find_fwd(src, Byte_ascii.Colon, pos, src_end); // no colon found; EX: "//a.org/b"; "a.org/b"
if (colon_pos != Bry_find_.Not_found) // colon found; EX: "http://" or "https://"
pos = colon_pos + Int_.Const_dlm_len;
pos = colon_pos + Byte_ascii.Len_1;
if (pos < src_end && src[pos] == Byte_ascii.Slash) { // skip slash after colon
pos += 1;
if (pos < src_end && src[pos] == Byte_ascii.Slash) // skip 2nd slash after colon

View File

@@ -46,7 +46,7 @@ public class Gfo_qarg_mgr {
public int Read_int_or(String key, int or) {return Read_int_or(Bry_.new_u8(key), or);}
public int Read_int_or(byte[] key, int or) {
byte[] val = Read_bry_or(key, null);
return val == null ? or : Int_.parse_or(String_.new_a7(val), or);
return val == null ? or : Int_.Parse_or(String_.new_a7(val), or);
}
public int Read_enm_as_int_or(Gfo_qarg_enum_itm enm, int or) {
Gfo_qarg_itm arg = (Gfo_qarg_itm)hash.Get_by_bry(enm.Key());

View File

@@ -34,8 +34,8 @@ public class Int_2_ref {
public static Int_2_ref parse(String raw) {
try {
String[] itms = String_.Split(raw, ",");
int v0 = Int_.parse(itms[0]);
int v1 = Int_.parse(itms[1]);
int v0 = Int_.Parse(itms[0]);
int v1 = Int_.Parse(itms[1]);
return new Int_2_ref(v0, v1);
} catch (Exception e) {Err_.Noop(e); throw Err_.new_parse("Int_2_ref", raw);}
}
@@ -46,8 +46,8 @@ public class Int_2_ref {
Int_2_ref[] rv = new Int_2_ref[itms_len];
for (int i = 0; i < itms_len; i++) {
String[] vals = String_.Split(itms[i], ",");
int v0 = Int_.parse(vals[0]);
int v1 = Int_.parse(vals[1]);
int v0 = Int_.Parse(vals[0]);
int v1 = Int_.Parse(vals[1]);
rv[i] = new Int_2_ref(v0, v1);
}
return rv;

View File

@@ -16,15 +16,15 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
package gplx.core.primitives; import gplx.*; import gplx.core.*;
public class Int_2_val {
public Int_2_val(int v0, int v1) {val_0 = v0; val_1 = v1;}
public int Val_0() {return val_0;} final int val_0;
public int Val_1() {return val_1;} final int val_1;
public int Val_0() {return val_0;} final int val_0;
public int Val_1() {return val_1;} final int val_1;
public String Xto_str(Bry_bfr bfr) {return Xto_str(bfr, val_0, val_1);}
public static final Int_2_val Null_ptr = null;
public static final Int_2_val Null_ptr = null;
public static Int_2_val parse(String raw) {
String[] itms = String_.Split(raw, ',');
if (itms.length != 2) return Null_ptr;
int v0 = Int_.parse_or(itms[0], Int_.Min_value); if (v0 == Int_.Min_value) return Null_ptr;
int v1 = Int_.parse_or(itms[1], Int_.Min_value); if (v1 == Int_.Min_value) return Null_ptr;
int v0 = Int_.Parse_or(itms[0], Int_.Min_value); if (v0 == Int_.Min_value) return Null_ptr;
int v1 = Int_.Parse_or(itms[1], Int_.Min_value); if (v1 == Int_.Min_value) return Null_ptr;
return new Int_2_val(v0, v1);
}
public static String Xto_str(Bry_bfr bfr, int x, int y) {return bfr.Add_int_variable(x).Add_byte_comma().Add_int_variable(y).To_str_and_clear();}

View File

@@ -24,7 +24,7 @@ public class Int_ary_parser extends Obj_ary_parser_base {
}
@Override protected void Ary_len_(int v) {
if (v == 0)
ary = Int_.Ary_empty;
ary = Int_ary_.Empty;
else {
ary = new int[v]; // NOTE: always create new array; never reuse;
ary_idx = 0;

View File

@@ -17,9 +17,9 @@ package gplx.core.primitives; import gplx.*; import gplx.core.*;
import org.junit.*; import gplx.core.tests.*;
public class Int_ary_parser_tst {
private final Int_ary_parser_fxt fxt = new Int_ary_parser_fxt();
@Test public void Many() {fxt.Test__Parse_ary("1,2,3,4,5" , 0, 9, Int_.Ary(1, 2, 3, 4, 5));}
@Test public void One() {fxt.Test__Parse_ary("1" , 0, 1, Int_.Ary(1));}
@Test public void None() {fxt.Test__Parse_ary("" , 0, 0, Int_.Ary());}
@Test public void Many() {fxt.Test__Parse_ary("1,2,3,4,5" , 0, 9, Int_ary_.New(1, 2, 3, 4, 5));}
@Test public void One() {fxt.Test__Parse_ary("1" , 0, 1, Int_ary_.New(1));}
@Test public void None() {fxt.Test__Parse_ary("" , 0, 0, Int_ary_.New());}
}
class Int_ary_parser_fxt {
public void Test__Parse_ary(String raw, int bgn, int end, int[] expd) {

View File

@@ -21,16 +21,16 @@ public class Db_cfg_itm {
public String Val() {return val;} public Db_cfg_itm Val_(String v) {val = v; return this;} private String val;
public String To_str_or(String or) {return val == null ? or : val;}
public byte[] To_bry_or(byte[] or) {try {return val == null ? or : Bry_.new_u8(val) ;} catch (Exception e) {throw err_parse(e, Bry_.Cls_val_name);}}
public int To_int_or(int or) {try {return val == null ? or : Int_.parse_or(val, or) ;} catch (Exception e) {throw err_parse(e, Int_.Cls_val_name);}}
public int To_int_or(int or) {try {return val == null ? or : Int_.Parse_or(val, or) ;} catch (Exception e) {throw err_parse(e, Int_.Cls_val_name);}}
public long To_long_or(long or) {try {return val == null ? or : Long_.parse_or(val, or) ;} catch (Exception e) {throw err_parse(e, Long_.Cls_val_name);}}
public byte To_byte_or(byte or) {try {return val == null ? or : Byte_.parse_or(val, or) ;} catch (Exception e) {throw err_parse(e, Byte_.Cls_val_name);}}
public byte To_byte_or(byte or) {try {return val == null ? or : Byte_.Parse_or(val, or) ;} catch (Exception e) {throw err_parse(e, Byte_.Cls_val_name);}}
public boolean To_yn_or_n() {return To_yn_or(Bool_.N);}
public boolean To_yn_or(boolean or) {try {return val == null ? or : Yn.parse_by_char_or(val, or);} catch (Exception e) {throw err_parse(e, Bool_.Cls_val_name);}}
public DateAdp To_date_or(DateAdp or) {try {return val == null ? or : DateAdp_.parse_gplx(val) ;} catch (Exception e) {throw err_parse(e, DateAdp_.Cls_ref_name);}}
public Guid_adp To_guid_or(Guid_adp or) {try {return val == null ? or : Guid_adp_.Parse(val) ;} catch (Exception e) {throw err_parse(e, Guid_adp_.Cls_ref_name);}}
public boolean To_bool() {Fail_if_null(); try {return Yn.parse(val) ;} catch (Exception e) {throw err_parse(e, Bool_.Cls_val_name);}}
public byte To_byte() {Fail_if_null(); try {return Byte_.parse(val) ;} catch (Exception e) {throw err_parse(e, Byte_.Cls_val_name);}}
public int To_int() {Fail_if_null(); try {return Int_.parse(val) ;} catch (Exception e) {throw err_parse(e, Int_.Cls_val_name);}}
public byte To_byte() {Fail_if_null(); try {return Byte_.Parse(val) ;} catch (Exception e) {throw err_parse(e, Byte_.Cls_val_name);}}
public int To_int() {Fail_if_null(); try {return Int_.Parse(val) ;} catch (Exception e) {throw err_parse(e, Int_.Cls_val_name);}}
public String To_str() {Fail_if_null(); return val;}
private void Fail_if_null() {if (val == null) throw Err_.new_wo_type("cfg.val is empty", "grp", grp, "key", key); }
private Err err_parse(Exception e, String type) {return Err_.new_wo_type("cfg.val is not parseable", "grp", grp, "key", key, "val", val, "type", type).Trace_ignore_add_1_();}

View File

@@ -149,8 +149,8 @@ public class Db_cfg_tbl implements Db_tbl {
public Guid_adp Assert_guid (String grp, String key, Guid_adp or) {String val = Select_str_or(grp, key, null) ; if (val == null) {Insert_guid (grp, key, or); return or;} return Parse_guid (grp, key, val);}
public String Assert_str (String grp, String key, String or) {String val = Select_str_or(grp, key, null) ; if (val == null) {Insert_str (grp, key, or); return or;} return val;}
private boolean Parse_yn (String grp, String key, String val) {try {return Yn.parse(val) ;} catch (Exception e) {throw err_parse(e, grp, key, val, Bool_.Cls_val_name);}}
private byte Parse_byte (String grp, String key, String val) {try {return Byte_.parse(val) ;} catch (Exception e) {throw err_parse(e, grp, key, val, Byte_.Cls_val_name);}}
private int Parse_int (String grp, String key, String val) {try {return Int_.parse(val) ;} catch (Exception e) {throw err_parse(e, grp, key, val, Int_.Cls_val_name);}}
private byte Parse_byte (String grp, String key, String val) {try {return Byte_.Parse(val) ;} catch (Exception e) {throw err_parse(e, grp, key, val, Byte_.Cls_val_name);}}
private int Parse_int (String grp, String key, String val) {try {return Int_.Parse(val) ;} catch (Exception e) {throw err_parse(e, grp, key, val, Int_.Cls_val_name);}}
private long Parse_long (String grp, String key, String val) {try {return Long_.parse(val) ;} catch (Exception e) {throw err_parse(e, grp, key, val, Long_.Cls_val_name);}}
private byte[] Parse_bry (String grp, String key, String val) {try {return Bry_.new_u8(val) ;} catch (Exception e) {throw err_parse(e, grp, key, val, Bry_.Cls_val_name);}}
private DateAdp Parse_date (String grp, String key, String val) {try {return DateAdp_.parse_gplx(val) ;} catch (Exception e) {throw err_parse(e, grp, key, val, DateAdp_.Cls_ref_name);}}

View File

@@ -65,7 +65,7 @@ class Log_fld_itm__int extends Log_fld_itm__base {
public int Bgn() {return bgn;} private final int bgn;
public int End() {return end;} private final int end;
@Override public void Fmt(Bry_bfr bfr, Object val) {
int val_int = Int_.cast(val);
int val_int = Int_.Cast(val);
String val_str = String_.PadBgn(Int_.To_str(val_int), this.Len(), " ");
bfr.Add_str_u8(val_str);
}

View File

@@ -32,8 +32,8 @@ public class Sql_runner {
public String Msg() {return msg;} public void Msg_(String v) {msg = v;} private String msg;
public String Fill_next(String state) {
String[] vals = String_.Split(state, "|");
int val_lo = Int_.parse(vals[0]);
int interval = Int_.parse(vals[1]);
int val_lo = Int_.Parse(vals[0]);
int interval = Int_.Parse(vals[1]);
int val_hi = val_lo + interval;
Db_stmt_arg arg = list.Get_at(0);

View File

@@ -44,7 +44,7 @@ public class Gfs_nde {
subs[subs_len] = nde;
subs_len = new_len;
return this;
} Gfs_nde[] subs = Gfs_nde.Ary_empty; int subs_max; int[] subs_pos_ary = Int_.Ary_empty;
} Gfs_nde[] subs = Gfs_nde.Ary_empty; int subs_max; int[] subs_pos_ary = Int_ary_.Empty;
public Gfs_nde Subs_get_at(int i) {return subs[i];}
public Gfs_nde[] Subs_to_ary() {
Gfs_nde[] rv = new Gfs_nde[subs_len];
@@ -71,7 +71,7 @@ public class Gfs_nde {
args[args_len] = nde;
args_len = new_len;
return this;
} Gfs_nde[] args = Gfs_nde.Ary_empty; int args_max; int[] args_pos_ary = Int_.Ary_empty;
} Gfs_nde[] args = Gfs_nde.Ary_empty; int args_max; int[] args_pos_ary = Int_ary_.Empty;
public Gfs_nde[] Atrs_to_ary() {
Gfs_nde[] rv = new Gfs_nde[args_len];
for (int i = 0; i < args_len; i++)

View File

@@ -27,7 +27,7 @@ public class Gfh_nde {
}
}
public byte[] Src() {return src;} private byte[] src;
public int[] Atrs() {return atrs;} private int[] atrs = Int_.Ary_empty;
public int[] Atrs() {return atrs;} private int[] atrs = Int_ary_.Empty;
public int Atrs_len() {return atrs_len;} private int atrs_len;
public boolean Tag_tid_is_inline() {return tag_tid_is_inline;} private boolean tag_tid_is_inline;
public int Tag_lhs_bgn() {return tag_lhs_bgn;} public Gfh_nde Tag_lhs_bgn_(int v) {tag_lhs_bgn = v; return this;} private int tag_lhs_bgn;

View File

@@ -49,14 +49,14 @@ class Gfo_url_encoder_itm_hex implements Gfo_url_encoder_itm {
return 0;
}
}
int hex_val = Int_.To_int_hex(src[idx + 1]);
int hex_val = Int_.By_hex_byte(src[idx + 1]);
if (hex_val == -1) { // invalid hex byte; EX: %GC; DATE:2014-04-10
bfr.Add_byte(b);
return 0;
}
int v_0 = hex_val * 16;
if (v_0 != -1) {
int v_1 = Int_.To_int_hex(src[idx + 2]);
int v_1 = Int_.By_hex_byte(src[idx + 2]);
if (v_1 != -1) {
bfr.Add_byte((byte)(v_0 + v_1));
return 2;

View File

@@ -164,8 +164,8 @@ public class Json_wtr {
switch (type_tid) {
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__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;

View File

@@ -40,7 +40,7 @@ public class Php_srl_parser {
val = Xto_kv_ary(ary);
break;
case Php_srl_itm_.Tid_function:
val = new gplx.xowa.xtns.scribunto.Scrib_lua_proc(Object_.Xto_str_strict_or_null_mark(key), Int_.cast(itm_val.Val())); // NOTE: in most cases, key is a STRING (name of ScribFunction); however, for gsub it is an INT (arg_idx) b/c it is passed as a parameter
val = new gplx.xowa.xtns.scribunto.Scrib_lua_proc(Object_.Xto_str_strict_or_null_mark(key), Int_.Cast(itm_val.Val())); // NOTE: in most cases, key is a STRING (name of ScribFunction); however, for gsub it is an INT (arg_idx) b/c it is passed as a parameter
break;
default:
val = itm_val.Val();

View File

@@ -119,11 +119,11 @@ public class Php_text_itm_parser {
}
if (txt_bgn != -1) {tmp_list.Add(new Php_text_itm_text(txt_bgn, raw_len)); txt_bgn = -1; rslt_val = Rslt_dirty;}
rslt.Val_(rslt_val);
} private static final byte[] CONST_utf_prefix = Bry_.new_a7("\\u00");
} private static final byte[] CONST_utf_prefix = Bry_.new_a7("\\u00");
private void Parse_utf16(List_adp rv, byte[] src, int bgn, int src_len) {
int end = bgn + 4;
if (end >= src_len) throw Err_.new_wo_type("utf16_parse", "src", String_.new_u8(src));
int v = Int_.To_int_hex(src, bgn, end); // +2; skip "\" + "u"
int v = Int_.By_hex_bry(src, bgn, end); // +2; skip "\" + "u"
byte[] literal = gplx.core.intls.Utf16_.Encode_int_to_bry(v);
rv.Add(new Php_text_itm_utf16(bgn, end, literal));
}

View File

@@ -55,7 +55,7 @@ public class Xocfg_mgr implements Gfo_invk {
}
public int Get_int_app_or(String key, int or) {
String rv = cache_mgr.Get_or(Ctx__app, key, null);
return rv == null ? or : Int_.parse_or(rv, or);
return rv == null ? or : Int_.Parse_or(rv, or);
}
public long Get_long_app_or(String key, long or) {
String rv = cache_mgr.Get_or(Ctx__app, key, null);
@@ -83,7 +83,7 @@ public class Xocfg_mgr implements Gfo_invk {
}
public int Get_int_wiki_or(Xow_wiki wiki, String key, int or) {
String rv = Get_str(wiki.Domain_itm().Abrv_xo_str(), key);
try {return Int_.parse(rv);}
try {return Int_.Parse(rv);}
catch (Exception exc) {
Err_.Noop(exc);
Gfo_usr_dlg_.Instance.Warn_many("", "", "cfg:failed to parse int; key=~{0} val=~{1}", key, rv);
@@ -92,7 +92,7 @@ public class Xocfg_mgr implements Gfo_invk {
}
public int Get_int_or(String ctx, String key, int or) {
String rv = cache_mgr.Get(ctx, key);
try {return Int_.parse(rv);}
try {return Int_.Parse(rv);}
catch (Exception exc) {
Err_.Noop(exc);
Gfo_usr_dlg_.Instance.Warn_many("", "", "cfg:failed to parse int; key=~{0} val=~{1}", key, rv);

View File

@@ -51,7 +51,7 @@ public class Xocfg_map_tbl implements Db_tbl {
try {
if (!rdr.Move_next()) return 0;
Object max = rdr.Read_obj(fld__map_sort);
return max == null ? 0 : Int_.cast(max) + 10;
return max == null ? 0 : Int_.Cast(max) + 10;
}
finally {rdr.Rls();}
}

View File

@@ -30,7 +30,7 @@ class Xocfg_maint_parser {
private Xocfg_maint_nde Parse_nde(GfoMsg msg) {
Ordered_hash hash = To_atr_hash(msg);
// get common atrs
int id = Int_.parse(Get_atr_as_str_or_fail(hash, "id_"));
int id = Int_.Parse(Get_atr_as_str_or_fail(hash, "id_"));
String owner = Get_atr_as_str_or_fail(hash, "owner_");
String key = Get_atr_as_str_or_fail(hash, "key_");
String name = Get_atr_as_str_or_fail(hash, "name_");

View File

@@ -134,7 +134,7 @@ public class Xob_wiki_cfg_bldr_tst {
for (int j = 0; j < xndes_len; j++) {
gplx.langs.xmls.XmlNde ns_nde = xnde.SubNdes().Get_at(j);
if (!String_.Eq(ns_nde.Name(), "ns")) continue;
int id = Int_.parse(ns_nde.Atrs().FetchValOr("id", "-1"));
int id = Int_.Parse(ns_nde.Atrs().FetchValOr("id", "-1"));
String name = String_.Replace(String_.Replace(ns_nde.Text_inner(), " ", "_"), "'", "''");
sb.Add(Int_.To_str(id)).Add("|").Add(String_.Trim(name)).Add_char_nl();
}

View File

@@ -18,9 +18,9 @@ public class Xobc_task_step_hash {
private final Ordered_hash tasks_hash = Ordered_hash_.New();
private final Ordered_hash steps_hash = Ordered_hash_.New();
public int Tasks__len() {return tasks_hash.Len();}
public int Tasks__get_at(int i) {return Int_.cast(tasks_hash.Get_at(i));}
public int Tasks__get_at(int i) {return Int_.Cast(tasks_hash.Get_at(i));}
public int Steps__len() {return steps_hash.Len();}
public int Steps__get_at(int i) {return Int_.cast(steps_hash.Get_at(i));}
public int Steps__get_at(int i) {return Int_.Cast(steps_hash.Get_at(i));}
public void Clear() {tasks_hash.Clear(); steps_hash.Clear();}
public void Add(int task_id, int step_id) {
tasks_hash.Add_if_dupe_use_nth(task_id, task_id);

View File

@@ -32,7 +32,7 @@ public class Split_cfg implements Gfo_invk {
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk__ns_ids_)) this.Ns_itms_(Int_.Ary_parse(m.ReadStr("v"), "|"));
if (ctx.Match(k, Invk__ns_ids_)) this.Ns_itms_(Int_ary_.Parse(m.ReadStr("v"), "|"));
else if (ctx.Match(k, Invk__loader_rows_)) this.loader_rows = m.ReadInt("v");
else if (ctx.Match(k, Invk__force_rebuild_)) this.force_rebuild = m.ReadBool("v");
else if (ctx.Match(k, Invk__trg_max_)) this.trg_max = m.ReadLong("v");

View File

@@ -33,6 +33,6 @@ public class Split_file_tid_ {
int bgn = String_.FindFwd(raw, "ns."); if (bgn == Bry_find_.Not_found) throw Err_.new_wo_type("could not find ns in url", "fil", raw);
bgn += 3; // ns.
int end = String_.FindFwd(raw, ".", bgn); if (end == Bry_find_.Not_found) throw Err_.new_wo_type("could not find ns in url", "fil", raw);
return Int_.parse(String_.Mid(raw, bgn, end));
return Int_.Parse(String_.Mid(raw, bgn, end));
}
}

View File

@@ -26,7 +26,7 @@ public class Xobldr__fsdb_db__create_data extends Xob_cmd__base implements Xob_c
private Xof_bin_mgr src_bin_mgr; private Xof_bin_wkr__fsdb_sql src_fsdb_wkr; private boolean src_bin_mgr__cache_enabled = Bool_.N; private String src_bin_mgr__fsdb_version; private String[] src_bin_mgr__fsdb_skip_wkrs; private boolean src_bin_mgr__wmf_enabled;
private Fsm_mnt_itm trg_mnt_itm; private Fsm_cfg_mgr trg_cfg_mgr; private Fsm_atr_fil trg_atr_fil; private Fsm_bin_fil trg_bin_fil; private long trg_bin_db_max; private String trg_bin_mgr__fsdb_version;
private final Xof_bin_updater trg_bin_updater = new Xof_bin_updater(); private Xob_bin_db_mgr bin_db_mgr; private int[] ns_ids; private int prv_lnki_tier_id = -1;
private long download_size_max = Io_mgr.Len_mb_long * 5; private int[] download_keep_tier_ids = Int_.Ary(0);
private long download_size_max = Io_mgr.Len_mb_long * 5; private int[] download_keep_tier_ids = Int_ary_.New(0);
private Xobu_poll_mgr poll_mgr; private int poll_interval; private long time_bgn;
private int select_interval = 2500, progress_interval = 1, commit_interval = 1, delete_interval = 5000;
private boolean exec_done, resume_enabled; private int exec_count, exec_count_max = Int_.Max_value, exec_fail, exec_fail_max = 10000; // 115 errors over 900k images
@@ -142,7 +142,7 @@ public class Xobldr__fsdb_db__create_data extends Xob_cmd__base implements Xob_c
}
else {
if (tier_id_bmk == -1) {
tier_id_bmk = Int_.parse(tier_id_str);
tier_id_bmk = Int_.Parse(tier_id_str);
usr_dlg.Note_many("", "", "restoring from bmk: tier_id=~{0}", tier_id_bmk);
}
if (page_id_bmk == -1) {
@@ -312,14 +312,14 @@ public class Xobldr__fsdb_db__create_data extends Xob_cmd__base implements Xob_c
else if (ctx.Match(k, Invk_exit_after_commit_)) exit_after_commit = m.ReadYn("v");
else if (ctx.Match(k, Invk_exit_now_)) exit_now = m.ReadYn("v");
else if (ctx.Match(k, Invk_resume_enabled_)) resume_enabled = m.ReadYn("v");
else if (ctx.Match(k, Invk_ns_ids_)) ns_ids = Int_.Ary_parse(m.ReadStr("v"), "|");
else if (ctx.Match(k, Invk_ns_ids_)) ns_ids = Int_ary_.Parse(m.ReadStr("v"), "|");
else if (ctx.Match(k, Invk_src_bin_mgr__fsdb_version_)) src_bin_mgr__fsdb_version = m.ReadStr("v");
else if (ctx.Match(k, Invk_src_bin_mgr__fsdb_skip_wkrs_)) src_bin_mgr__fsdb_skip_wkrs = m.ReadStrAry("v", "|");
else if (ctx.Match(k, Invk_src_bin_mgr__wmf_enabled_)) src_bin_mgr__wmf_enabled = m.ReadYn("v");
else if (ctx.Match(k, Invk_src_bin_mgr__cache_enabled_)) src_bin_mgr__cache_enabled = m.ReadYn("v");
else if (ctx.Match(k, Invk_trg_bin_mgr__fsdb_version_)) trg_bin_mgr__fsdb_version = m.ReadStr("v");
else if (ctx.Match(k, Invk_poll_mgr)) return poll_mgr;
else if (ctx.Match(k, Invk_download_keep_tier_ids)) download_keep_tier_ids = Int_.Ary_parse(m.ReadStr("v"), "|");
else if (ctx.Match(k, Invk_download_keep_tier_ids)) download_keep_tier_ids = Int_ary_.Parse(m.ReadStr("v"), "|");
else if (ctx.Match(k, Invk_download_size_max)) download_size_max = Io_size_.To_long_by_msg_mb(m, download_size_max);
else return Gfo_invk_.Rv_unhandled;
return this;

View File

@@ -33,7 +33,7 @@ public class Xobldr__lnki_temp__create extends Xob_dump_mgr_base implements gplx
private final Xob_hdump_bldr hdump_bldr = new Xob_hdump_bldr(); private Vnt_convert_lang converter_lang;
public Xobldr__lnki_temp__create(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki);}
@Override public byte Init_redirect() {return Bool_.N_byte;} // lnki_temp does not look at redirect pages
@Override public int[] Init_ns_ary() {return ns_ids;} private int[] ns_ids = Int_.Ary(Xow_ns_.Tid__main);
@Override public int[] Init_ns_ary() {return ns_ids;} private int[] ns_ids = Int_ary_.New(Xow_ns_.Tid__main);
@Override protected void Init_reset(Db_conn conn) {
Db_cfg_tbl cfg_tbl = gplx.xowa.wikis.data.Xowd_cfg_tbl_.New(conn);
cfg_tbl.Delete_all();
@@ -157,7 +157,7 @@ public class Xobldr__lnki_temp__create extends Xob_dump_mgr_base implements gplx
@Override public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_wdata_enabled_)) wdata_enabled = m.ReadYn("v");
else if (ctx.Match(k, Invk_xtn_ref_enabled_)) xtn_ref_enabled = m.ReadYn("v");
else if (ctx.Match(k, Invk_ns_ids_)) ns_ids = Int_.Ary_parse(m.ReadStr("v"), "|");
else if (ctx.Match(k, Invk_ns_ids_)) ns_ids = Int_ary_.Parse(m.ReadStr("v"), "|");
else if (ctx.Match(k, Invk_ns_ids_by_aliases)) ns_ids = Xobldr__lnki_temp__create_.Ns_ids_by_aliases(wiki, m.ReadStrAry("v", "|"));
else if (ctx.Match(k, Invk_gen_html_)) gen_html = m.ReadYn("v");
else if (ctx.Match(k, Invk__load_all_imglinks_)) load_all_imglinks = m.ReadYn("v");

View File

@@ -24,7 +24,7 @@ public class Xobldr__redirect__create extends Xob_dump_mgr_base {
private Db_conn conn; private Xob_redirect_tbl redirect_tbl;
private Xodb_mgr_sql db_mgr; private Xop_redirect_mgr redirect_mgr; private Gfo_url_encoder encoder;
public Xobldr__redirect__create(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki); this.Reset_db_y_();}
@Override public int[] Init_ns_ary() {return Int_.Ary(Xow_ns_.Tid__file);} // restrict to file ns
@Override public int[] Init_ns_ary() {return Int_ary_.New(Xow_ns_.Tid__file);} // restrict to file ns
@Override public byte Init_redirect() {return Bool_.Y_byte;} // restrict to redirects
@Override protected void Init_reset(Db_conn conn) {
Db_cfg_tbl cfg_tbl = gplx.xowa.wikis.data.Xowd_cfg_tbl_.New(conn);

View File

@@ -37,7 +37,7 @@ class Xobc_info_html extends Xow_special_wtr__base {
long total_size = 0;
Bry_bfr tmp_size_bfr = Bry_bfr_.New();
for (int i = 0; i < len; ++i) {
int step_id = Int_.cast(list.Get_at(i));
int step_id = Int_.Cast(list.Get_at(i));
Xobc_import_step_itm step_itm = data_db.Tbl__import_step().Select_one(step_id);
if (i == 0) {
wiki_domain = Xow_abrv_xo_.To_itm(step_itm.Wiki_abrv()); // ASSUME: 1st step's wiki is same for all steps

View File

@@ -29,7 +29,7 @@ class Xomp_init_mgr {
mgr_db.Remake();
// insert ns into cfg; need for lnki_temp.tier in xomp.make
mgr_db.Tbl__cfg().Insert_str("", gplx.xowa.addons.bldrs.mass_parses.parses.wkrs.Xomp_parse_wkr.Cfg__ns_ids, Int_.Ary_concat("|", cfg.Ns_ids()));
mgr_db.Tbl__cfg().Insert_str("", gplx.xowa.addons.bldrs.mass_parses.parses.wkrs.Xomp_parse_wkr.Cfg__ns_ids, Int_ary_.To_str("|", cfg.Ns_ids()));
// fill page tbl
Db_attach_mgr attach_mgr = new Db_attach_mgr(mgr_conn, new Db_attach_itm("page_db", wiki.Data__core_mgr().Db__core().Conn()));

View File

@@ -28,7 +28,7 @@ class Xomp_init_mgr_cfg implements Gfo_invk {
return rv;
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk__ns_ids_)) ns_ids = Int_.Ary_parse(m.ReadStr("v"), "|");
if (ctx.Match(k, Invk__ns_ids_)) ns_ids = Int_ary_.Parse(m.ReadStr("v"), "|");
else return Gfo_invk_.Rv_unhandled;
return this;
}

View File

@@ -60,7 +60,7 @@ class Xomp_html_db_wtr {
if (prv_ns_id != ns_id
|| ns_itm == null) {
prv_ns_id = ns_id;
ns_itm = new Xob_ns_file_itm(Xow_db_file_.Tid__html_data, "ns." + Int_.To_str_pad_bgn_zero(ns_id, 3), Int_.Ary(ns_id));
ns_itm = new Xob_ns_file_itm(Xow_db_file_.Tid__html_data, "ns." + Int_.To_str_pad_bgn_zero(ns_id, 3), Int_ary_.New(ns_id));
}
String file_name = is_all_or_few ? "-html.xowa" : ns_itm.Make_file_name();
this.html_db = wiki.Data__core_mgr().Dbs__make_by_tid(Xow_db_file_.Tid__html_data, Int_.To_str(ns_id), ns_itm.Nth_db_idx(), file_name);

View File

@@ -57,7 +57,7 @@ public class Xomp_parse_mgr {
Xomp_parse_wkr[] wkrs = new Xomp_parse_wkr[wkr_len];
// init ns_ord_mgr
Xomp_ns_ord_mgr ns_ord_mgr = new Xomp_ns_ord_mgr(Int_.Ary_parse(mgr_db.Tbl__cfg().Select_str("", Xomp_parse_wkr.Cfg__ns_ids), "|"));
Xomp_ns_ord_mgr ns_ord_mgr = new Xomp_ns_ord_mgr(Int_ary_.Parse(mgr_db.Tbl__cfg().Select_str("", Xomp_parse_wkr.Cfg__ns_ids), "|"));
// init indexer
Xofulltext_indexer_wkr indexer = cfg.Indexer_enabled() ? new Xofulltext_indexer_wkr() : null;
@@ -131,7 +131,7 @@ public class Xomp_parse_mgr {
} finally {rdr.Rls();}
// mark ns
int[] ns_ids = Int_.Ary_parse(ns_list, ",");
int[] ns_ids = Int_ary_.Parse(ns_list, ",");
cache.Add_ns_loaded(ns_ids);
}
}

View File

@@ -65,9 +65,9 @@ class Xoh_toc_wkr__lvl {
sub_lvl_count[toc_lvl - List_adp_.Base1] = sub_lvl_count[toc_lvl - List_adp_.Base1] + 1;
prv_lvl = lvl; // NOTE: same as "if ( $toclevel ) $prevlevel = $level;" but at end of block
// Tfds.Write(lvl, prv_lvl, lvl, toc_lvl, Int_.Ary_concat(",", lvl_count), Int_.Ary_concat(",", sub_lvl_count));
// Tfds.Write(lvl, prv_lvl, lvl, toc_lvl, Int_ary_.To_str(",", lvl_count), Int_ary_.To_str(",", sub_lvl_count));
int[] copy = new int[toc_lvl];
Int_.Ary_copy_to(sub_lvl_count, toc_lvl, copy);
Int_ary_.Copy_to(sub_lvl_count, toc_lvl, copy);
rv.Set__lvl(++uid, toc_lvl, copy);
}
}

View File

@@ -18,32 +18,32 @@ import org.junit.*; import gplx.core.tests.*;
public class Xoh_toc_wkr__lvl__basic__tst {
@Before public void init() {fxt.Clear();} private final Xoh_toc_wkr__lvl__fxt fxt = new Xoh_toc_wkr__lvl__fxt();
@Test public void D1_S0_S0() {
fxt.Test__calc(2, fxt.Make(1, 1, Int_.Ary(1)));
fxt.Test__calc(2, fxt.Make(2, 1, Int_.Ary(2)));
fxt.Test__calc(2, fxt.Make(3, 1, Int_.Ary(3)));
fxt.Test__calc(2, fxt.Make(1, 1, Int_ary_.New(1)));
fxt.Test__calc(2, fxt.Make(2, 1, Int_ary_.New(2)));
fxt.Test__calc(2, fxt.Make(3, 1, Int_ary_.New(3)));
}
@Test public void D1_D1_D1() {
fxt.Test__calc(2, fxt.Make(1, 1, Int_.Ary(1)));
fxt.Test__calc(3, fxt.Make(2, 2, Int_.Ary(1, 1)));
fxt.Test__calc(4, fxt.Make(3, 3, Int_.Ary(1, 1, 1)));
fxt.Test__calc(2, fxt.Make(1, 1, Int_ary_.New(1)));
fxt.Test__calc(3, fxt.Make(2, 2, Int_ary_.New(1, 1)));
fxt.Test__calc(4, fxt.Make(3, 3, Int_ary_.New(1, 1, 1)));
}
@Test public void D1_D1_S0_U1() {
fxt.Test__calc(2, fxt.Make(1, 1, Int_.Ary(1)));
fxt.Test__calc(3, fxt.Make(2, 2, Int_.Ary(1, 1)));
fxt.Test__calc(3, fxt.Make(3, 2, Int_.Ary(1, 2)));
fxt.Test__calc(2, fxt.Make(4, 1, Int_.Ary(2)));
fxt.Test__calc(2, fxt.Make(1, 1, Int_ary_.New(1)));
fxt.Test__calc(3, fxt.Make(2, 2, Int_ary_.New(1, 1)));
fxt.Test__calc(3, fxt.Make(3, 2, Int_ary_.New(1, 2)));
fxt.Test__calc(2, fxt.Make(4, 1, Int_ary_.New(2)));
}
@Test public void D1_D1_U1_D1() {
fxt.Test__calc(2, fxt.Make(1, 1, Int_.Ary(1)));
fxt.Test__calc(3, fxt.Make(2, 2, Int_.Ary(1, 1)));
fxt.Test__calc(2, fxt.Make(3, 1, Int_.Ary(2)));
fxt.Test__calc(3, fxt.Make(4, 2, Int_.Ary(2, 1)));
fxt.Test__calc(2, fxt.Make(1, 1, Int_ary_.New(1)));
fxt.Test__calc(3, fxt.Make(2, 2, Int_ary_.New(1, 1)));
fxt.Test__calc(2, fxt.Make(3, 1, Int_ary_.New(2)));
fxt.Test__calc(3, fxt.Make(4, 2, Int_ary_.New(2, 1)));
}
@Test public void D1_D1_D1_U2() {
fxt.Test__calc(2, fxt.Make(1, 1, Int_.Ary(1)));
fxt.Test__calc(3, fxt.Make(2, 2, Int_.Ary(1, 1)));
fxt.Test__calc(4, fxt.Make(3, 3, Int_.Ary(1, 1, 1)));
fxt.Test__calc(2, fxt.Make(4, 1, Int_.Ary(2)));
fxt.Test__calc(2, fxt.Make(1, 1, Int_ary_.New(1)));
fxt.Test__calc(3, fxt.Make(2, 2, Int_ary_.New(1, 1)));
fxt.Test__calc(4, fxt.Make(3, 3, Int_ary_.New(1, 1, 1)));
fxt.Test__calc(2, fxt.Make(4, 1, Int_ary_.New(2)));
}
}
class Xoh_toc_wkr__lvl__fxt {

View File

@@ -175,7 +175,7 @@ public class Xosync_img_src_parser {
}
private boolean Check_md5() { // check if md5; also, skip past md5; EX: "a/a0/"
int pos = rdr.Pos();
if (!Byte_.Eq_many(Byte_ascii.Slash, raw[pos + 1], raw[pos + 4])) return false; // check slashes
if (!Byte_.Match_all(Byte_ascii.Slash, raw[pos + 1], raw[pos + 4])) return false; // check slashes
byte b_0 = raw[pos + 0], b_2 = raw[pos + 2];
if (b_0 != b_2) return false; // WM repeats 1st MD5 char; EX: "a" in "a/a0"
if (!gplx.core.encoders.Hex_utl_.Is_hex_many(b_0, b_2, raw[pos + 3])) return false; // check rest is hex

View File

@@ -28,10 +28,10 @@ public class Srch_urlbar_mgr implements Gfo_invk { // NOTE: needs to be app-leve
private final Srch_ns_mgr ns_mgr = new Srch_ns_mgr().Add_main_if_empty();
private Srch_crt_scanner_syms syms = Srch_crt_scanner_syms.New__dflt();
private void Ns_ids_(String s) {
int[] ns_ids = Int_.Ary_empty;
int[] ns_ids = Int_ary_.Empty;
if (String_.Eq(s, "*")) {} // leave as int[0]; ns_mgr will interpret as wildcard
else {
ns_ids = Int_.Ary_parse(s, ",");
ns_ids = Int_ary_.Parse(s, ",");
}
ns_mgr.Add_by_int_ids(ns_ids);
if (addon != null) addon.Clear_rslts_cache(); // invalidate cache when ns changes; else ns_0 rslts will show up in ns_100; DATE:2016-03-24

View File

@@ -81,8 +81,8 @@ public class Srch_ns_mgr {
}
}
public int[] To_int_ary() {
if (ns_all) return Int_.Ary_empty;
else if (ns_main) return Int_.Ary(Xow_ns_.Tid__main);
if (ns_all) return Int_ary_.Empty;
else if (ns_main) return Int_ary_.New(Xow_ns_.Tid__main);
else {
int len = ns_hash.Count();
int[] rv = new int[len];

View File

@@ -25,7 +25,7 @@ public class Xoa_fmtr_itm implements Gfo_invk {
}
public String Run() {
Gfo_invk src_invk = (Gfo_invk)app.Gfs_mgr().Run_str(src);
int len = Int_.cast(Gfo_invk_.Invk_by_key(src_invk, Invk_len));
int len = Int_.Cast(Gfo_invk_.Invk_by_key(src_invk, Invk_len));
Bry_bfr bfr = Bry_bfr_.New();
Bfmtr_eval_invk eval_mgr = new Bfmtr_eval_invk(app);
Bry_fmtr fmtr = Bry_fmtr.new_bry_(fmt).Eval_mgr_(eval_mgr);

View File

@@ -176,7 +176,7 @@ public class Xow_url_parser {
}
if (xwiki != null) return true;
if (app.Wiki_mgri().Has(domain)) return true;
return Byte_.In(tmp_protocol_tid, Gfo_protocol_itm.Tid_http, Gfo_protocol_itm.Tid_https);
return Byte_.Match_any(tmp_protocol_tid, Gfo_protocol_itm.Tid_http, Gfo_protocol_itm.Tid_https);
}
private void Bld_page(int bgn_seg) {
tmp_tid = Xoa_url_.Tid_page;

View File

@@ -28,7 +28,7 @@ public class Xoa_version_ {
for (int i = 0; i < lhs_ary_len; ++i) {
String lhs_itm = lhs_ary[i];
String rhs_itm = rhs_ary[i];
int itm_comp = Int_.Compare(Int_.parse_or(lhs_itm, 0), Int_.parse_or(rhs_itm, 0));
int itm_comp = Int_.Compare(Int_.Parse_or(lhs_itm, 0), Int_.Parse_or(rhs_itm, 0));
if (itm_comp != CompareAble_.Same) return itm_comp;
}
return CompareAble_.Same;

View File

@@ -56,7 +56,7 @@ public class Xob_ns_to_db_mgr {
return rv;
}
private Xow_db_file Init_db(Xob_ns_file_itm ns_file_itm) {
Xow_db_file rv = db_mgr.Dbs__make_by_tid(ns_file_itm.Db_file_tid(), Int_.To_str(ns_file_itm.Ns_ids(), "|"), ns_file_itm.Nth_db_idx(), ns_file_itm.Make_file_name());
Xow_db_file rv = db_mgr.Dbs__make_by_tid(ns_file_itm.Db_file_tid(), Int_ary_.To_str("|", ns_file_itm.Ns_ids()), ns_file_itm.Nth_db_idx(), ns_file_itm.Make_file_name());
ns_file_itm.Nth_db_id_(rv.Id());
Init_tbl(rv);
return rv;

View File

@@ -42,7 +42,7 @@ public class Xob_ns_file_itm_parser extends Dsv_wkr_base {
for (int i = 0; i < len; ++i) {
Xow_ns ns = ns_mgr.Ords_get_at(i);
int ns_id = ns.Id();
rslts.Add(new Xob_ns_file_itm(db_file_tid, "ns." + Int_.To_str_pad_bgn_zero(ns_id, 3), Int_.Ary(ns_id)));
rslts.Add(new Xob_ns_file_itm(db_file_tid, "ns." + Int_.To_str_pad_bgn_zero(ns_id, 3), Int_ary_.New(ns_id)));
}
return;
}
@@ -65,7 +65,7 @@ public class Xob_ns_file_itm_parser extends Dsv_wkr_base {
ns_ids[i] = ns_mgr.Ords_get_at(i).Id();
}
else
ns_ids = Int_.Ary_parse(String_.new_u8(ns_ids_bry), ",");
ns_ids = Int_ary_.Parse(String_.new_u8(ns_ids_bry), ",");
if (ns_ids.length == 0) throw Err_.new_wo_type("map.invalid.ns_missing", "src", this.Src());
if (String_.Len_eq_0(name)) { // no name; auto-generate
int ns_id_1st = ns_ids[0]; // take 1st ns_id

View File

@@ -18,7 +18,7 @@ import gplx.xowa.bldrs.wkrs.*;
public class Xob_diff_build_cmd implements Xob_cmd {
private final Xob_bldr bldr; private final Xowe_wiki wiki;
private String prev_url, curr_url, diff_url; private int commit_interval;
private int[] db_ids = Int_.Ary_empty; private String bld_name = "all";
private int[] db_ids = Int_ary_.Empty; private String bld_name = "all";
public Xob_diff_build_cmd(Xob_bldr bldr, Xowe_wiki wiki) {this.bldr = bldr; this.wiki = wiki;}
public String Cmd_key() {return Xob_cmd_keys.Key_diff_build;}
public Xob_cmd Cmd_clone(Xob_bldr bldr, Xowe_wiki wiki) {return null;}
@@ -30,7 +30,7 @@ public class Xob_diff_build_cmd implements Xob_cmd {
else if (ctx.Match(k, Invk__curr_url_)) curr_url = m.ReadStr("v");
else if (ctx.Match(k, Invk__diff_url_)) diff_url = m.ReadStr("v");
else if (ctx.Match(k, Invk__commit_interval_)) commit_interval = m.ReadInt("v");
else if (ctx.Match(k, Invk__db_ids_)) db_ids = Int_.Ary_parse(m.ReadStr("v"), "|");
else if (ctx.Match(k, Invk__db_ids_)) db_ids = Int_ary_.Parse(m.ReadStr("v"), "|");
else if (ctx.Match(k, Invk__bld_name_)) bld_name = m.ReadStr("v");
else return Gfo_invk_.Rv_unhandled;
return this;

View File

@@ -71,7 +71,7 @@ public class Xob_siteinfo_parser_ {
String ns_id = itm_nde.Atrs().FetchValOr("key", null); if (ns_id == null) throw Err_.new_("Xob_siteinfo_parser_", "missing key for ns", "ns_xml", itm_nde.Text_inner());
String case_match = itm_nde.Atrs().FetchValOr("case", case_dflt); // NOTE: some dumps can omit "case"; EX: https://dumps.wikimedia.org/sep11wiki; DATE:2015-11-01
String name = itm_nde.Text_inner();
ns_mgr.Add_new(Int_.parse(ns_id), Bry_.new_u8(name), Xow_ns_case_.To_tid(case_match), false);
ns_mgr.Add_new(Int_.Parse(ns_id), Bry_.new_u8(name), Xow_ns_case_.To_tid(case_match), false);
}
ns_mgr.Init_w_defaults();
}

View File

@@ -130,7 +130,7 @@ public class Xoa_css_img_downloader {
bfr.Add(css_trg_bry).Add_byte_nl();
bfr.Add_byte_nl();
int semic_pos = Bry_find_.Find_fwd(src, Byte_ascii.Semic, find_bgn + url_raw.length, src_len);
return semic_pos + Int_.Const_dlm_len;
return semic_pos + Byte_ascii.Len_1;
}
private static final byte[]
Wikisource_dynimg_ttl = Bry_.new_a7("en.wikisource.org/w/index.php?title=MediaWiki:Dynimg.css")

View File

@@ -29,7 +29,7 @@ class Xosql_tbl_parser {
byte[] line = lines[i];
// get fld bgn / end; EX: "`fld_1`"
int bgn = Bry_find_.Find_fwd(line, Byte_ascii.Tick); if (bgn == Bry_find_.Not_found) continue; // skip blank lines
bgn += Int_.Const_position_after_char;
bgn += Int_.Offset_1;
int end = Bry_find_.Find_fwd(line, Byte_ascii.Tick, bgn); if (end == Bry_find_.Not_found) continue; // skip blank lines
// add fld

View File

@@ -19,7 +19,7 @@ public class Xoi_wiki_props_alias {
public String Alias() {return alias;} private String alias;
public Xoi_wiki_props_alias Init_by_ctor(int id, String alias) {this.id = id; this.alias = alias; return this;}
public void Init_by_xml(gplx.langs.xmls.XmlNde ns_nde) {
this.id = Int_.parse(ns_nde.Atrs().FetchValOr("id", "-1"));
this.id = Int_.Parse(ns_nde.Atrs().FetchValOr("id", "-1"));
this.alias = String_.Replace(String_.Replace(ns_nde.Text_inner(), " ", "_"), "'", "''");
}
}

View File

@@ -19,7 +19,7 @@ public class Xoi_wiki_props_ns {
public boolean Subpages_enabled() {return subpages_enabled;} private boolean subpages_enabled;
public Xoi_wiki_props_ns Init_by_ctor(int id, boolean subpages_enabled) {this.id = id; this.subpages_enabled = subpages_enabled; return this;}
public void Init_by_xml(gplx.langs.xmls.XmlNde ns_nde) {
this.id = Int_.parse(ns_nde.Atrs().FetchValOr("id", "-1"));
this.id = Int_.Parse(ns_nde.Atrs().FetchValOr("id", "-1"));
this.subpages_enabled = ns_nde.Atrs().Fetch_or_null("subpages") != null;// per api, subpages="" means ns has subpages; no subpages attribute means no subpages
}
}

View File

@@ -25,12 +25,12 @@ public class Rect_ref {
public gplx.gfui.RectAdp XtoRectAdp() {return gplx.gfui.RectAdp_.new_(x, y, w, h);}
public gplx.gfui.RectAdp XtoRectAdp_add(Rect_ref v) {return gplx.gfui.RectAdp_.new_(x + v.x, y + v.y, w + v.w, h + v.h);}
@Override public String toString() {return String_.Format("{0},{1},{2},{3}", x, y, w, h);}
public static final Rect_ref Zero = new Rect_ref(0, 0, 0, 0);
public static final Rect_ref Zero = new Rect_ref(0, 0, 0, 0);
public static Rect_ref rectAdp_(gplx.gfui.RectAdp v) {return new Rect_ref(v.X(), v.Y(), v.Width(), v.Height());}
public static Rect_ref parse(String raw) {
try {
String[] ary = String_.Split(raw, ",");
return new Rect_ref(Int_.parse(ary[0]), Int_.parse(ary[1]), Int_.parse(ary[2]), Int_.parse(ary[3]));
return new Rect_ref(Int_.Parse(ary[0]), Int_.Parse(ary[1]), Int_.Parse(ary[2]), Int_.Parse(ary[3]));
} catch(Exception exc) {throw Err_.new_parse_exc(exc, Rect_ref.class, raw);}
}
}

View File

@@ -52,12 +52,12 @@ public class Xog_layout_box implements Gfo_invk {
else if (ctx.Match(k, Invk_y_rel_)) y_rel = m.ReadInt("v");
else if (ctx.Match(k, Invk_w_rel_)) w_rel = m.ReadInt("v");
else if (ctx.Match(k, Invk_h_rel_)) h_rel = m.ReadInt("v");
else if (ctx.Match(k, Invk_size_abs_)) {int[] ary = Int_.Ary_parse(m.ReadStr("v"), 2, null); if (ary != null) {w_abs = ary[0]; h_abs = ary[1];}}
else if (ctx.Match(k, Invk_size_rel_)) {int[] ary = Int_.Ary_parse(m.ReadStr("v"), 2, null); if (ary != null) {w_rel = ary[0]; h_rel = ary[1];}}
else if (ctx.Match(k, Invk_pos_abs_)) {int[] ary = Int_.Ary_parse(m.ReadStr("v"), 2, null); if (ary != null) {x_abs = ary[0]; y_abs = ary[1];}}
else if (ctx.Match(k, Invk_pos_rel_)) {int[] ary = Int_.Ary_parse(m.ReadStr("v"), 2, null); if (ary != null) {x_rel = ary[0]; y_rel = ary[1];}}
else if (ctx.Match(k, Invk_rect_abs_)) {int[] ary = Int_.Ary_parse(m.ReadStr("v"), 4, null); if (ary != null) {w_abs = ary[0]; h_abs = ary[1]; x_abs = ary[2]; y_abs = ary[3];}}
else if (ctx.Match(k, Invk_rect_rel_)) {int[] ary = Int_.Ary_parse(m.ReadStr("v"), 4, null); if (ary != null) {w_rel = ary[0]; h_rel = ary[1]; x_rel = ary[2]; y_rel = ary[3];}}
else if (ctx.Match(k, Invk_size_abs_)) {int[] ary = Int_ary_.Parse(m.ReadStr("v"), 2, null); if (ary != null) {w_abs = ary[0]; h_abs = ary[1];}}
else if (ctx.Match(k, Invk_size_rel_)) {int[] ary = Int_ary_.Parse(m.ReadStr("v"), 2, null); if (ary != null) {w_rel = ary[0]; h_rel = ary[1];}}
else if (ctx.Match(k, Invk_pos_abs_)) {int[] ary = Int_ary_.Parse(m.ReadStr("v"), 2, null); if (ary != null) {x_abs = ary[0]; y_abs = ary[1];}}
else if (ctx.Match(k, Invk_pos_rel_)) {int[] ary = Int_ary_.Parse(m.ReadStr("v"), 2, null); if (ary != null) {x_rel = ary[0]; y_rel = ary[1];}}
else if (ctx.Match(k, Invk_rect_abs_)) {int[] ary = Int_ary_.Parse(m.ReadStr("v"), 4, null); if (ary != null) {w_abs = ary[0]; h_abs = ary[1]; x_abs = ary[2]; y_abs = ary[3];}}
else if (ctx.Match(k, Invk_rect_rel_)) {int[] ary = Int_ary_.Parse(m.ReadStr("v"), 4, null); if (ary != null) {w_rel = ary[0]; h_rel = ary[1]; x_rel = ary[2]; y_rel = ary[3];}}
else if (ctx.Match(k, Invk_text_)) text = m.ReadStr("v");
else if (ctx.Match(k, Invk_font_name_)) font_name = m.ReadStr("v");
else if (ctx.Match(k, Invk_font_size_)) font_size = m.ReadFloat("v");

View File

@@ -82,7 +82,7 @@ public class Bridge_msg_bldr {
String key = sub_kv.Key(); Object val = sub_kv.Val();
switch (sub_kv.Val_tid()) {
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__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

@@ -76,7 +76,7 @@ public class Xoh_js_cbk implements Gfo_invk {
}
private String Popups_get_html(GfoMsg m) {
try {
int popups_id = Int_.Xby_double_(Double_.cast(m.Args_getAt(0).Val()));
int popups_id = Int_.By_double(Double_.cast(m.Args_getAt(0).Val()));
byte[] href_bry = m.Args_getAt(1).Val_to_bry();
byte[] tooltip_bry = m.Args_getAt(2).Val_to_bry();
return html_itm.Owner_tab().Wiki().Html_mgr().Head_mgr().Popup_mgr().Show_init(popups_id, href_bry, tooltip_bry);

View File

@@ -54,7 +54,7 @@ public class Xol_csv_parser {
byte[] utf_bytes = new byte[utf_len]; int utf_idx = 0;
int utf_pos = i + 2;
for (int j = 0; j < utf_len; j++) {
int utf_int = Int_.To_int_hex(src, utf_pos, utf_pos + 4);
int utf_int = Int_.By_hex_bry(src, utf_pos, utf_pos + 4);
if (utf_int == -1) throw Err_.new_wo_type("invalid value for \\u", "val", String_.new_u8(src, bgn, end));
utf_bytes[utf_idx++] = (byte)utf_int;
utf_pos += 6;

View File

@@ -62,7 +62,7 @@ public abstract class Xop_tkn_itm_base implements Xop_tkn_itm {
subs[subs_len] = sub;
sub.Tkn_grp_(this, subs_len);
subs_len = new_len;
} private Xop_tkn_itm[] subs = Xop_tkn_itm_.Ary_empty; int subs_max; int[] subs_pos_ary = Int_.Ary_empty;
} private Xop_tkn_itm[] subs = Xop_tkn_itm_.Ary_empty; int subs_max; int[] subs_pos_ary = Int_ary_.Empty;
public void Subs_add_grp(Xop_tkn_itm sub, Xop_tkn_grp old_grp, int old_sub_idx) {
this.Subs_add(sub);
if (sub.Tkn_immutable())
@@ -93,7 +93,7 @@ public abstract class Xop_tkn_itm_base implements Xop_tkn_itm {
public void Subs_clear() {
subs_len = subs_max = 0;
subs = Xop_tkn_itm_.Ary_empty;
subs_pos_ary = Int_.Ary_empty;
subs_pos_ary = Int_ary_.Empty;
}
public void Subs_move(Xop_tkn_itm tkn) {
int nxt_idx = tkn_sub_idx + 1, len = tkn.Subs_len();

View File

@@ -16,7 +16,7 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
package gplx.xowa.parsers.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
import gplx.core.brys.*;
public class Mwh_atr_mgr {
private final int data_max_orig;
private final int data_max_orig;
public Mwh_atr_mgr(int max) {
this.data_max_orig = max * Idx__mult;
this.Max_(max);
@@ -41,7 +41,7 @@ public class Mwh_atr_mgr {
if (data_idx == data_max) {
int new_data_max = data_max == 0 ? Idx__mult : data_max * 2;
int[] new_data_ary = new int[new_data_max];
Int_.Ary_copy_to(data_ary, data_max, data_ary);
Int_ary_.Copy_to(data_ary, data_max, data_ary);
this.data_ary = new_data_ary;
int text_max = text_ary.length;

View File

@@ -15,7 +15,7 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.parsers.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
class Mwh_doc_mgr {
private final int data_max_orig;
private final int data_max_orig;
public Mwh_doc_mgr(int max) {
this.data_max_orig = max * Idx__mult;
this.Max_(max);
@@ -38,7 +38,7 @@ class Mwh_doc_mgr {
if (data_idx == data_max) {
int new_data_max = data_max == 0 ? Idx__mult : data_max * 2;
int[] new_data_ary = new int[new_data_max];
Int_.Ary_copy_to(data_ary, data_max, data_ary);
Int_ary_.Copy_to(data_ary, data_max, data_ary);
this.data_ary = new_data_ary;
this.data_max = new_data_max;
}

View File

@@ -44,7 +44,7 @@ public class HierPosAryBldr {
}
public boolean Dirty() {return aryIdx > -1 || root > 0;}
public int[] XtoIntAry() {
if (aryIdx == -1) return Int_.Ary_empty;
if (aryIdx == -1) return Int_ary_.Empty;
int[] rv = new int[aryIdx + 1];
for (int i = 0; i < aryIdx + 1; i++)
rv[i] = ary[i];

View File

@@ -18,7 +18,7 @@ import org.junit.*;
public class HierPosAryBldr_tst {
@Before public void init() {bldr.Init();} HierPosAryBldr bldr = new HierPosAryBldr(256);
@Test public void Basic() {
tst_ary(Int_.Ary_empty);
tst_ary(Int_ary_.Empty);
}
@Test public void Move_d() {
bldr.MoveDown();

View File

@@ -19,12 +19,12 @@ public class Xop_list_tkn extends Xop_tkn_itm_base {
public int List_uid() {return list_uid;} public Xop_list_tkn List_uid_(int v) {list_uid = v; return this;} private int list_uid = -1;
public byte List_bgn() {return list_bgn;} private byte list_bgn;
public byte List_itmTyp() {return list_itmTyp;} public Xop_list_tkn List_itmTyp_(byte v) {list_itmTyp = v; return this;} private byte list_itmTyp = Xop_list_tkn_.List_itmTyp_null;
public int[] List_path() {return path;} public Xop_list_tkn List_path_(int... v) {path = v; return this;} private int[] path = Int_.Ary_empty;
public int[] List_path() {return path;} public Xop_list_tkn List_path_(int... v) {path = v; return this;} private int[] path = Int_ary_.Empty;
public int List_path_idx() {return path[path.length - 1];}
public boolean List_sub_first() {return List_path_idx() == 0;}
public byte List_sub_last() {return list_sub_last;} public Xop_list_tkn List_sub_last_(byte v) {list_sub_last = v; return this;} private byte list_sub_last = Bool_.__byte;
public static Xop_list_tkn bgn_(int bgn, int end, byte list_itmTyp, int symLen) {return new Xop_list_tkn(bgn, end, Bool_.Y_byte, list_itmTyp);}
public static Xop_list_tkn end_(int pos, byte list_itmTyp) {return new Xop_list_tkn(pos, pos, Bool_.N_byte, list_itmTyp);}
public Xop_list_tkn(int bgn, int end, byte bgnEndType, byte list_itmTyp) {this.Tkn_ini_pos(false, bgn, end); this.list_bgn = bgnEndType; this.list_itmTyp = list_itmTyp;}
public static final Xop_list_tkn Null = new Xop_list_tkn(); Xop_list_tkn() {}
public static final Xop_list_tkn Null = new Xop_list_tkn(); Xop_list_tkn() {}
}

View File

@@ -21,7 +21,7 @@ public class Xop_list_tkn_chkr extends Xop_tkn_chkr_base {
public int List_uid() {return list_uid;} public Xop_list_tkn_chkr List_uid_(int v) {list_uid = v; return this;} private int list_uid = -1;
public byte List_bgn() {return list_bgn;} public Xop_list_tkn_chkr List_bgn_(byte v) {list_bgn = v; return this;} private byte list_bgn;
public byte List_itmTyp() {return list_itmTyp;} public Xop_list_tkn_chkr List_itmTyp_(byte v) {list_itmTyp = v; return this;} private byte list_itmTyp = Xop_list_tkn_.List_itmTyp_null;
public int[] List_path() {return list_path;} public Xop_list_tkn_chkr List_path_(int... v) {list_path = v; return this;} private int[] list_path = Int_.Ary_empty;
public int[] List_path() {return list_path;} public Xop_list_tkn_chkr List_path_(int... v) {list_path = v; return this;} private int[] list_path = Int_ary_.Empty;
public byte List_sub_last() {return list_sub_last;} public Xop_list_tkn_chkr List_sub_last_(byte v) {list_sub_last = v; return this;} private byte list_sub_last = Bool_.__byte;
@Override public int Chk_hook(Tst_mgr mgr, String path, Object actl_obj, int err) {
Xop_list_tkn actl = (Xop_list_tkn)actl_obj;
@@ -29,7 +29,7 @@ public class Xop_list_tkn_chkr extends Xop_tkn_chkr_base {
err += mgr.Tst_val(list_bgn == 0, path, "list_bgn", list_bgn, actl.List_bgn());
err += mgr.Tst_val(list_itmTyp == Xop_list_tkn_.List_itmTyp_null, path, "list_itmTyp", list_itmTyp, actl.List_itmTyp());
err += mgr.Tst_val(list_sub_last == Bool_.__byte, path, "list_sub_last", list_sub_last, actl.List_sub_last());
err += mgr.Tst_val(list_path == Int_.Ary_empty, path, "list_path", Array_.To_str(list_path), Array_.To_str(actl.List_path()));
err += mgr.Tst_val(list_path == Int_ary_.Empty, path, "list_path", Array_.To_str(list_path), Array_.To_str(actl.List_path()));
return err;
}
}

View File

@@ -163,7 +163,7 @@ public class Xop_lnke_wkr implements Xop_ctx_wkr {
tkn.Lnke_relative_(site_data.Rel());
Xow_xwiki_itm xwiki = ctx.App().Usere().Wiki().Xwiki_mgr().Get_by_mid(src, site_bgn, site_end); // NOTE: check User_wiki.Xwiki_mgr, not App.Wiki_mgr() b/c only it is guaranteed to know all wikis on system
if ( xwiki != null // lnke is to an xwiki; EX: [http://en.wikipedia.org/A a]
&& Byte_.In(proto_tid, Gfo_protocol_itm.Tid_relative_1, Gfo_protocol_itm.Tid_relative_2, Gfo_protocol_itm.Tid_http, Gfo_protocol_itm.Tid_https) // only consider http / https; ignore mailto and others; PAGE:uk.w:Маскалі; DATE:2015-07-28
&& Byte_.Match_any(proto_tid, Gfo_protocol_itm.Tid_relative_1, Gfo_protocol_itm.Tid_relative_2, Gfo_protocol_itm.Tid_http, Gfo_protocol_itm.Tid_https) // only consider http / https; ignore mailto and others; PAGE:uk.w:Маскалі; DATE:2015-07-28
&& Bry_.Match(src, site_bgn, site_end, xwiki.Domain_bry()) // only consider full domains, not alliases; EX: [http://w/b] should not match alias of w for en.wikipedia.org
) {
Xowe_wiki wiki = ctx.Wiki();

View File

@@ -53,7 +53,7 @@ public class Xop_link_parser {
if (proto_len + 1 < raw_len && raw[proto_len + 1] == Byte_ascii.Slash) { // next char is slash, assume xfer_itm refers to protocol; EX: file:///C/A.png
int slash_pos = Bry_find_.Find_bwd(raw, Byte_ascii.Slash);
if (slash_pos != Bry_find_.Not_found) // set xowa_title to file_name; TODO_OLD: call Xoa_url.build; note that this will fail sometimes when (a) xfer_itm is very long (File:ReallyLongName will be shortened to 128 chars) or (b) xfer_itm has invalid windows characters (EX:File:a"b"c.jpg)
html_xowa_ttl = Bry_.Mid(raw, slash_pos + Int_.Const_dlm_len, raw.length);
html_xowa_ttl = Bry_.Mid(raw, slash_pos + Byte_ascii.Len_1, raw.length);
}
else // next char is not slash; assume xfer_itm refers to ns; EX:File:A.png
raw = tmp_bfr.Add(Xoh_href_.Bry__wiki).Add(raw).To_bry_and_clear();

View File

@@ -129,7 +129,7 @@ public class Xop_lnki_arg_parser {
int len = digit_mgr.Len(); // NOTE: add non-english numbers; EX: ۲۰۰px; DATE:2015-07-18
for (int i = 0; i < len; ++i) {
Keyval kv = digit_mgr.Get_at(i);
int num = (byte)Int_.parse_or(kv.Key(), -1); if (num == -1) continue; // ignore separators; EX: "," "."
int num = (byte)Int_.Parse_or(kv.Key(), -1); if (num == -1) continue; // ignore separators; EX: "," "."
size_trie.Add((byte[])kv.Val(), Byte_obj_val.new_((byte)num)); // NOTE: num corresponds to dim_d0 -> d9 below
}
size_trie.Add(Byte_ascii.Space, Byte_obj_val.new_(Key_space));

View File

@@ -18,11 +18,11 @@ import gplx.core.tests.*;
public class Xop_tblw_tb_tkn_chkr extends Xop_tkn_chkr_base {
@Override public Class<?> TypeOf() {return Xop_tblw_tb_tkn.class;}
@Override public byte Tkn_tid() {return Xop_tkn_itm_.Tid_tblw_tb;}
public int Caption_count() {return caption_count;} public Xop_tblw_tb_tkn_chkr Caption_count_(int v) {caption_count = v; return this;} private int caption_count = Int_.Neg1_count;
public int Caption_count() {return caption_count;} public Xop_tblw_tb_tkn_chkr Caption_count_(int v) {caption_count = v; return this;} private int caption_count = Int_.Neg1;
public Xop_tblw_tb_tkn_chkr Atrs_rng_(int bgn, int end) {this.atrs_bgn = bgn; this.atrs_end = end; return this;} private int atrs_bgn = Xop_tblw_wkr.Atrs_null, atrs_end = Xop_tblw_wkr.Atrs_null;
@Override public int Chk_hook(Tst_mgr mgr, String path, Object actl_obj, int err) {
Xop_tblw_tb_tkn actl = (Xop_tblw_tb_tkn)actl_obj;
err += mgr.Tst_val(caption_count == Int_.Neg1_count, path, "caption_count", caption_count, actl.Caption_count());
err += mgr.Tst_val(caption_count == Int_.Neg1, path, "caption_count", caption_count, actl.Caption_count());
err += mgr.Tst_val(atrs_bgn == Xop_tblw_wkr.Atrs_null, path, "atrs_bgn", atrs_bgn, actl.Atrs_bgn());
err += mgr.Tst_val(atrs_end == Xop_tblw_wkr.Atrs_null, path, "atrs_end", atrs_end, actl.Atrs_end());
return err;

View File

@@ -19,10 +19,10 @@ public class Xop_uniq_mgr__tst {
private final Xop_uniq_mgr__fxt fxt = new Xop_uniq_mgr__fxt();
@Before public void init() {fxt.Init();}
@Test public void Test__random_bry() {
fxt.Init_random_int_ary(Int_.Ary(240563374, 22728940, 1451248133));
fxt.Init_random_int_ary(Int_ary_.New(240563374, 22728940, 1451248133));
fxt.Test__uniq_bry_new("'\"`UNIQ-E56B4AE15AD0EC68");
fxt.Init_random_int_ary(Int_.Ary(1363621437, 426295411, 421041101));
fxt.Init_random_int_ary(Int_ary_.New(1363621437, 426295411, 421041101));
fxt.Test__uniq_bry_new("'\"`UNIQ-147363D968C07391");
}
@Test public void Add_and_get() {

View File

@@ -349,7 +349,7 @@ public class Xop_xnde_wkr implements Xop_ctx_wkr {
Xop_xnde_tkn xnde_inline = Xnde_bgn(ctx, tkn_mkr, root, tag, Xop_xnde_tkn.CloseMode_open, src, bgn_pos, open_tag_end, atrs_bgn, atrs_end, atrs);
End_tag(ctx, root, xnde_inline, src, src_len, bgn_pos, gtPos, tagId, false, tag);
ctx.Msg_log().Add_itm_none(Xop_xnde_log.No_inline, src, bgn_pos, gtPos);
return gtPos + Int_.Const_position_after_char;
return gtPos + Int_.Offset_1;
}
Xop_xnde_tkn xnde = null;
xnde = Xnde_bgn(ctx, tkn_mkr, root, tag, inline ? Xop_xnde_tkn.CloseMode_inline : Xop_xnde_tkn.CloseMode_open, src, bgn_pos, open_tag_end, atrs_bgn, atrs_end, atrs);

View File

@@ -59,7 +59,7 @@ class Xows_cmd__file_check {
int rows_len = rows.length;
for (int i = 0; i < rows_len; ++i) {
Object[] row = rows[i];
int file_id = Int_.cast(row[0]);
int file_id = Int_.Cast(row[0]);
String sql = sql_mkr.Thm_by_id(file_id);
Write_sect(bfr, "fsdb.thm.select", sql);
Object[][] thm_rows = Db_rdr_utl.Load(atr_main.Conn(), sql);
@@ -75,9 +75,9 @@ class Xows_cmd__file_check {
int rows_len = rows.length;
for (int i = 0; i < rows_len; ++i) {
Object[] row = rows[i];
int bin_db_id = Int_.cast(row[bin_db_id_ordinal]); if (bin_db_id == -1) continue;
int bin_db_id = Int_.Cast(row[bin_db_id_ordinal]); if (bin_db_id == -1) continue;
Fsm_bin_fil bin_db = mnt_itm.Bin_mgr().Dbs__get_at(bin_db_id);
int owner_id = Int_.cast(row[owner_id_ordinal]);
int owner_id = Int_.Cast(row[owner_id_ordinal]);
String sql = sql_mkr.Bin_by_id(owner_id);
Write_sect(bfr, "fsdb.bin.select", sql);
Object[][] bin_rows = Db_rdr_utl.Load(bin_db.Conn(), sql);
@@ -90,7 +90,7 @@ class Xows_cmd__file_check {
Bry_bfr tmp_bfr = Bry_bfr_.New();
for (int i = 0; i < rows_len; ++i) {
Object[] row = rows[i];
int owner_id = Int_.cast(row[owner_id_ordinal]);
int owner_id = Int_.Cast(row[owner_id_ordinal]);
byte[] bin_data = (byte[])row[bin_data_ordinal];
file_bry = gplx.xowa.files.repos.Xof_itm_ttl_.Remove_invalid(tmp_bfr, file_bry);
Io_url bin_url = tmp_dir.GenSubFil(String_.new_u8(file_bry));

View File

@@ -74,7 +74,7 @@ public class Xoud_bmk_itm_tbl implements Rls_able {
int rv = 0;
if (rdr.Move_next()) {
Object rv_obj = rdr.Read_obj(fld_sort);
rv = rv_obj == null ? 0 : Int_.cast(rv_obj) + 1;
rv = rv_obj == null ? 0 : Int_.Cast(rv_obj) + 1;
}
return rv;
}

View File

@@ -24,7 +24,7 @@ public class Xoud_cfg_mgr {
}
public int Select_int_or(String grp, String key, int or) {
String rv = Select_str_or(grp, key, null);
return rv == null ? or : Int_.parse_or(rv, or);
return rv == null ? or : Int_.Parse_or(rv, or);
}
public byte[] Select_bry_or(String key, byte[] or) {return Select_bry_or("" , key, or);}
public byte[] Select_bry_or(String grp, String key, byte[] or) {

View File

@@ -50,7 +50,7 @@ public class Xow_db_file {
public String Url_rel() {return url_rel;} private final String url_rel;
public Xowd_core_db_props Db_props() {return db_props;} private final Xowd_core_db_props db_props;
public String Ns_ids() {return ns_ids;} private final String ns_ids;
public int Ns_id_or_fail() {return Int_.parse(ns_ids);}
public int Ns_id_or_fail() {return Int_.Parse(ns_ids);}
public int Part_id() {return part_id;} private final int part_id;
public Guid_adp Guid() {return guid;} private final Guid_adp guid;
public byte Cmd_mode() {return cmd_mode;} public Xow_db_file Cmd_mode_(byte v) {cmd_mode = v; return this;} private byte cmd_mode;

View File

@@ -118,7 +118,7 @@ public class Xow_db_mgr {
int len = hash_by_id.Len();
for (int i = 0; i < len; ++i) {
Xow_db_file db = (Xow_db_file)hash_by_id.Get_at(i);
if (!Byte_.In(db.Tid(), tids)) continue;
if (!Byte_.Match_any(db.Tid(), tids)) continue;
db.Rls();
Io_mgr.Instance.DeleteFil_args(db.Url()).MissingFails_off().Exec();
db.Cmd_mode_(Db_cmd_mode.Tid_delete);
@@ -163,7 +163,7 @@ public class Xow_db_mgr {
add = true; // text will be in db if solo;
break;
case Xow_db_file_.Tid__text: // EX: "en.wikipedia.org-text-ns.000.xowa"
int[] db_ns_ids = Int_.Ary_parse(db.Ns_ids(), "|"); // need to handle both "0" and "0|4"
int[] db_ns_ids = Int_ary_.Parse(db.Ns_ids(), "|"); // need to handle both "0" and "0|4"
for (int db_ns_id : db_ns_ids) {
if (db_ns_id == ns_id) {
add = true; // text will be in db if ns matches; EX: en.wikipedia.org-text-ns.014.xowa

View File

@@ -70,7 +70,7 @@ public class Xowd_site_ns_tbl implements Db_tbl {
.Crt_int(fld_id, ns_id)
.Exec_select__rls_auto();
try {
return rdr.Move_next() ? Int_.cast(rdr.Read_int(fld_count)) : 0;
return rdr.Move_next() ? Int_.Cast(rdr.Read_int(fld_count)) : 0;
} finally {rdr.Rls();}
}
public void Update_ns_count(int ns_id, int ns_count) {

View File

@@ -117,7 +117,7 @@ public class Xodb_load_mgr_txt implements Xodb_load_mgr {
int itm_bgn = xdat_itm.Itm_bgn(), itm_end = xdat_itm.Itm_end();
int pos = Bry_find_.Find_fwd(raw, Byte_ascii.Pipe, itm_bgn, raw.length);
if (pos == Bry_find_.Not_found) throw wiki.Appe().Usr_dlg().Fail_many(GRP_KEY, "invalid_search_file", "search file is invalid");
pos += Int_.Const_dlm_len; // pipe
pos += Byte_ascii.Len_1; // pipe len
while (pos < itm_end) {
int page_id = Base85_.To_int_by_bry(raw, pos, pos + 4);

View File

@@ -70,7 +70,7 @@ public class Xotdb_fsys_mgr {
int len = ns_dirs.length;
Hash_adp rv = Hash_adp_.New();
for (int i = 0; i < len; i++) {
int ns_int = Int_.parse_or(ns_dirs[i].NameOnly(), Int_.Min_value); if (ns_int == Int_.Min_value) continue;
int ns_int = Int_.Parse_or(ns_dirs[i].NameOnly(), Int_.Min_value); if (ns_int == Int_.Min_value) continue;
Xow_ns ns = ns_mgr.Ids_get_or_null(ns_int); if (ns == null) continue;
ns.Exists_(true);
}

View File

@@ -78,7 +78,7 @@ public class Xof_meta_mgr implements Gfo_invk {
} private static final String Invk_regy_depth_ = "depth_";
static final String GRP_KEY = "xowa.file_regy.";
private static Xof_meta_fil Get_fil_or_null_recur(Object[] ary, int depth_max, byte[] md5, int md5_idx) {
int ary_idx = Int_.To_int_hex(md5[md5_idx]);
int ary_idx = Int_.By_hex_byte(md5[md5_idx]);
if (ary_idx < 0 || ary_idx > 15) throw Err_.new_wo_type("md5_not_valid", "md5", String_.new_u8(md5), "idx", md5_idx);
Object o = ary[ary_idx];
if (o == null) return null;
@@ -89,7 +89,7 @@ public class Xof_meta_mgr implements Gfo_invk {
return Get_fil_or_null_recur(nxt, depth_max, md5, md5_idx + 1);
}
private static Xof_meta_fil Bld_new(Object[] ary, int depth_max, Xof_meta_mgr regy_mgr, byte[] md5, int md5_idx) {
int ary_idx = Int_.To_int_hex(md5[md5_idx]);
int ary_idx = Int_.By_hex_byte(md5[md5_idx]);
if (ary_idx < 0 || ary_idx > 15) throw Err_.new_wo_type("md5_not_valid", "md", String_.new_u8(md5), "idx", md5_idx);
Object o = ary[ary_idx];
if (md5_idx == depth_max) { // leaf; create itm

View File

@@ -16,7 +16,7 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
package gplx.xowa.wikis.tdbs.metas; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.tdbs.*;
public class Xof_meta_thumb {
public Xof_meta_thumb() {}
public Xof_meta_thumb(byte exists, int width, int height, int[] seeks) {this.exists = exists; this.width = width; this.height = height; this.seeks = seeks; if (seeks == null) seeks = Int_.Ary_empty;}
public Xof_meta_thumb(byte exists, int width, int height, int[] seeks) {this.exists = exists; this.width = width; this.height = height; this.seeks = seeks; if (seeks == null) seeks = Int_ary_.Empty;}
public byte Exists() {return exists;} private byte exists = Xof_meta_itm.Exists_unknown; // default to y, b/c thumbs are usually added if they exist; handle n when it occurs; unknown should never happen;
public boolean State_new() {return state_new;} public Xof_meta_thumb State_new_() {state_new = true; return this;} private boolean state_new;
public Xof_meta_thumb Exists_(byte v) {exists = v; return this;}
@@ -24,7 +24,7 @@ public class Xof_meta_thumb {
public Xof_meta_thumb Exists_n_() {exists = Xof_meta_itm.Exists_n; return this;}
public int Width() {return width;} public Xof_meta_thumb Width_(int v) {width = v; return this;} private int width;
public int Height() {return height;} public Xof_meta_thumb Height_(int v) {height = v; return this;} private int height;
public int[] Seeks() {return seeks;} public Xof_meta_thumb Seeks_(int[] v) {seeks = v; return this;} private int[] seeks = Int_.Ary_empty;
public int[] Seeks() {return seeks;} public Xof_meta_thumb Seeks_(int[] v) {seeks = v; return this;} private int[] seeks = Int_ary_.Empty;
public Xof_meta_thumb Seeks_add(int v) {
int seeks_len = seeks.length;
seeks = (int[])Array_.Resize(seeks, seeks_len + 1);
@@ -35,7 +35,7 @@ public class Xof_meta_thumb {
bfr .Add_int_fixed(exists, 1) .Add_byte(Xof_meta_thumb_parser.Dlm_exists)
.Add_int_variable(width) .Add_byte(Xof_meta_thumb_parser.Dlm_width)
.Add_int_variable(height);
if (seeks != Int_.Ary_empty) {
if (seeks != Int_ary_.Empty) {
bfr.Add_byte(Xof_meta_thumb_parser.Dlm_seek);
int seeks_len = seeks.length;
for (int i = 0; i < seeks_len; i++) {
@@ -45,5 +45,5 @@ public class Xof_meta_thumb {
}
state_new = false;
}
public static final Xof_meta_thumb[] Ary_empty = new Xof_meta_thumb[0];
public static final Xof_meta_thumb[] Ary_empty = new Xof_meta_thumb[0];
}

View File

@@ -49,11 +49,11 @@ public class Xof_meta_thumb_parser extends Obj_ary_parser_base {
switch (b) {
case Dlm_width: // "," found; assume width; note that seek commas will be handled by seek
itm.Width_(number_parser.Parse(bry, num_bgn, pos).Rv_as_int());
num_bgn = pos + Int_.Const_dlm_len;
num_bgn = pos + Byte_ascii.Len_1;
break;
case Dlm_seek:
itm.Height_(number_parser.Parse(bry, num_bgn, pos).Rv_as_int());
num_bgn = pos + Int_.Const_dlm_len;
num_bgn = pos + Byte_ascii.Len_1;
height_found = true;
itm.Seeks_(int_ary_parser.Parse_ary(bry, num_bgn, end, Byte_ascii.Comma));
pos = end;

View File

@@ -142,8 +142,8 @@ public class Xob_xdat_file {
GetAt(itm, itm_idx);
return this;
}
public Xob_xdat_file Clear() {src = null; itm_ends = Int_.Ary_empty; return this;}
private int[] itm_ends = Int_.Ary_empty; private int itm_0_bgn;
public Xob_xdat_file Clear() {src = null; itm_ends = Int_ary_.Empty; return this;}
private int[] itm_ends = Int_ary_.Empty; private int itm_0_bgn;
public Xob_xdat_file Parse(byte[] src, int src_len, Io_url url) {// SEE:NOTE_1;xdat format
if (src_len == 0) throw Err_.new_wo_type("file cannot be empty for parse", "url", url.Raw());
int itm_count = 0, tmp_len = Parse_tmp_len; int[] tmp = Parse_tmp;

View File

@@ -75,7 +75,7 @@ class Dpl_itm {
}
}
else { // known key; set pos to val_bgn
fld_bgn = pos + Int_.Const_dlm_len;
fld_bgn = pos + Byte_ascii.Len_1;
}
ws_bgn_chk = true; ws_bgn_idx = ws_end_idx = -1;
break;
@@ -87,7 +87,7 @@ class Dpl_itm {
byte[] val = Bry_.Mid(src, fld_bgn, fld_end);
Parse_cmd(wiki, key_id, val);
}
fld_bgn = pos + Int_.Const_dlm_len;
fld_bgn = pos + Byte_ascii.Len_1;
ws_bgn_chk = true; ws_bgn_idx = ws_end_idx = -1;
break;
}

View File

@@ -15,8 +15,8 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.xtns.math.texvcs.tkns; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.math.*; import gplx.xowa.xtns.math.texvcs.*;
public class Texvc_regy_tkn {
private int[] ary = Int_.Ary_empty; private int ary_max; private int itms_len;
private final Texvc_root root; private Texvc_tkn_mkr tkn_mkr;
private int[] ary = Int_ary_.Empty; private int ary_max; private int itms_len;
private final Texvc_root root; private Texvc_tkn_mkr tkn_mkr;
public int Len() {return itms_len;}
public Texvc_regy_tkn(Texvc_root root) {
this.root = root;

View File

@@ -26,13 +26,13 @@ public class Pgbnr_xtn_mgr extends Xox_mgr_base implements Bfr_arg {
@Override public void Xtn_init_by_wiki(Xowe_wiki wiki) {
// load config; TODO_OLD: load by file
boolean enabled = false, enable_heading_override = true, enable_default_banner = false;
int[] ns_ary = Int_.Ary(Xow_ns_.Tid__main, Xow_ns_.Tid__user);
int[] ns_ary = Int_ary_.New(Xow_ns_.Tid__main, Xow_ns_.Tid__user);
int[] standard_sizes = new int[] {640, 1280, 2560};
int dflt_img_wdata_prop = 948; byte[] dflt_img_title = Bry_.new_a7("Pagebanner_default.jpg"); // www.wikidata.org/wiki/Property:P948
switch (wiki.Domain_tid()) {
case Xow_domain_tid_.Tid__home:
enabled = true;
ns_ary = Int_.Ary(Xow_ns_.Tid__main);
ns_ary = Int_ary_.New(Xow_ns_.Tid__main);
break;
case Xow_domain_tid_.Tid__wikivoyage:
switch (wiki.Lang().Lang_id()) {
@@ -42,11 +42,11 @@ public class Pgbnr_xtn_mgr extends Xox_mgr_base implements Bfr_arg {
enabled = true;
break;
case Xol_lang_stub_.Id_ru:
ns_ary = Int_.Ary(0, 1, 10, 11, 12, 13, 14, 15, 2, 2300, 2301, 2302, 2303, 2600, 3, 4, 5, 6, 7, 8, 828, 829, 9);
ns_ary = Int_ary_.New(0, 1, 10, 11, 12, 13, 14, 15, 2, 2300, 2301, 2302, 2303, 2600, 3, 4, 5, 6, 7, 8, 828, 829, 9);
enabled = true;
break;
case Xol_lang_stub_.Id_uk:
ns_ary = Int_.Ary(Xow_ns_.Tid__main, Xow_ns_.Tid__user, Xow_ns_.Tid__project);
ns_ary = Int_ary_.New(Xow_ns_.Tid__main, Xow_ns_.Tid__user, Xow_ns_.Tid__project);
enabled = true;
break;
}
@@ -55,7 +55,7 @@ public class Pgbnr_xtn_mgr extends Xox_mgr_base implements Bfr_arg {
switch (wiki.Lang().Lang_id()) {
case Xol_lang_stub_.Id_ca:
// enabled = enable_default_banner = true;
ns_ary = Int_.Ary(102, Xow_ns_.Tid__user);
ns_ary = Int_ary_.New(102, Xow_ns_.Tid__user);
break;
case Xol_lang_stub_.Id_en:
// enabled = enable_default_banner = true;

View File

@@ -216,7 +216,7 @@ public class Pp_pages_nde implements Xox_xnde, Mwh_atr_itm_owner1 {
}
private List_adp Get_ttls_from_xnde_args__include(List_adp list) {
if (Bry_.Len_eq_0(include)) return list; // include is blank; exit early;
int[] include_pages = Int_ary_.Parse_list_or(include, null);
int[] include_pages = Int_ary_.Parse_or(include, null);
if (include_pages == null) return list; // ignore invalid include; DATE:2014-02-22
int include_pages_len = include_pages.length;
for (int i = 0; i < include_pages_len; i++)
@@ -272,7 +272,7 @@ public class Pp_pages_nde implements Xox_xnde, Mwh_atr_itm_owner1 {
} private static Xowd_page_itm tmp_page = new Xowd_page_itm(); // tmp_page passed to Load_ttls_for_all_pages; values are never looked at, so use static instance
private List_adp Get_ttls_from_xnde_args__exclude(List_adp list) {
if (Bry_.Len_eq_0(exclude)) return list; // exclude is blank; exit early;
int[] exclude_pages = Int_ary_.Parse_list_or(exclude, null);
int[] exclude_pages = Int_ary_.Parse_or(exclude, null);
if (exclude_pages == null) return list; // ignore invalid exclude; DATE:2014-02-22
Hash_adp exclude_pages_hash = Hash_adp_.New();
int exclude_pages_len = exclude_pages.length;

View File

@@ -210,7 +210,7 @@ class Scrib_lua_rsp_bldr {
}
private void Bld_obj(Bry_bfr bfr, Object v) {
Class<?> v_type = v.getClass();
if (Object_.Eq(v_type, Int_.Cls_ref_type)) Bld_int(bfr, Int_.cast(v));
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, Double_.Cls_ref_type)) Bld_double(bfr, Double_.cast(v));

View File

@@ -51,7 +51,7 @@ class Luaj_value_ {
// val is function
if (itm_val.type() == LuaValue.TFUNCTION) {
String func_key = itm_key.tojstring();
int func_id = Int_.cast(itm_val_obj);
int func_id = Int_.Cast(itm_val_obj);
Scrib_lua_proc lua_func = new Scrib_lua_proc(func_key, func_id);
if (itm_key.type() == LuaValue.TSTRING) // most functions are named
kv = Keyval_.new_(func_key, lua_func);
@@ -140,7 +140,7 @@ class Luaj_value_ {
LuaValue itm_val = Obj_to_lua_val(server, itm.Val());
switch (itm.Key_tid()) {
case Type_ids_.Id__int:
rv.set(Int_.cast(itm.Key_as_obj()), itm_val);
rv.set(Int_.Cast(itm.Key_as_obj()), itm_val);
break;
case Type_ids_.Id__str:
case Type_ids_.Id__obj:

View File

@@ -30,7 +30,7 @@ public class Process_engine implements Scrib_engine {
public Scrib_server Server() {return server;} public void Server_(Scrib_server v) {server = v;} Scrib_server server;
public Scrib_lua_proc LoadString(String name, String text) {
Keyval[] rslt = this.Dispatch("op", "loadString", "text", text, "chunkName", name);
return new Scrib_lua_proc(name, Int_.cast(rslt[0].Val()));
return new Scrib_lua_proc(name, Int_.Cast(rslt[0].Val()));
}
public Keyval[] CallFunction(int id, Keyval[] args) {
return this.Dispatch("op", "call", "id", id, "nargs", args.length, "args", args);

View File

@@ -81,7 +81,7 @@ public class Process_send_wtr {
if (o == null) {bfr.Add(CONST_nil); return true;}
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, 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;}
else if (Object_.Eq(c, String.class)) {if (!Encode_str(bfr, (String)o)) return false;}

View File

@@ -110,7 +110,7 @@ public class Scrib_lib_mw implements Scrib_lib {
Xot_invk frame = Scrib_frame_.Get_frame(core, frame_id);
int frame_arg_adj = Scrib_frame_.Get_arg_adj(frame.Frame_tid());
String idx_str = args.Pull_str(1);
int idx_int = Int_.parse_or(idx_str, Int_.Min_value); // NOTE: should not receive int value < -1; idx >= 0
int idx_int = Int_.Parse_or(idx_str, Int_.Min_value); // NOTE: should not receive int value < -1; idx >= 0
Bry_bfr tmp_bfr = Bry_bfr_.New(); // NOTE: do not make modular level variable, else random failures; DATE:2013-10-14
if (idx_int != Int_.Min_value) { // idx is integer
Arg_nde_tkn nde = Get_arg(frame, idx_int, frame_arg_adj);
@@ -389,12 +389,12 @@ class Scrib_lib_mw_callParserFunction_sorter implements gplx.core.lists.Comparer
Keyval rhs = (Keyval)rhsObj;
Object lhs_key = lhs.Key_as_obj();
Object rhs_key = rhs.Key_as_obj();
boolean lhs_is_int = Int_.TypeMatch(lhs_key.getClass());
boolean rhs_is_int = Int_.TypeMatch(rhs_key.getClass());
boolean lhs_is_int = Type_.Eq(lhs_key.getClass(), Int_.Cls_ref_type);
boolean rhs_is_int = Type_.Eq(rhs_key.getClass(), Int_.Cls_ref_type);
if (lhs_is_int != rhs_is_int) // different types (int vs String or String vs int)
return lhs_is_int ? CompareAble_.Less : CompareAble_.More; // sort ints before strings
if (lhs_is_int) // both are ints
return Int_.Compare(Int_.cast(lhs_key), Int_.cast(rhs_key));
return Int_.Compare(Int_.Cast(lhs_key), Int_.Cast(rhs_key));
else // both are strings
return String_.Compare(String_.cast(lhs_key), String_.cast(rhs_key));
}

View File

@@ -35,7 +35,7 @@ class Scrib_lib_text__json_util {
}
if (is_sequence) {
if (kv.Key_tid() == Type_ids_.Id__int) {
int kv_key_as_int = Int_.cast(kv.Key_as_obj());
int kv_key_as_int = Int_.Cast(kv.Key_as_obj());
is_sequence = next++ == kv_key_as_int;
}
else {
@@ -93,7 +93,7 @@ class Scrib_lib_text__json_util {
Json_kv json_kv = root.Get_at_as_kv(i);
String kv_str = json_kv.Key_as_str();
Object kv_val = Decode_obj(json_kv.Val());
int kv_int = Int_.parse_or(kv_str, Int_.Min_value);
int kv_int = Int_.Parse_or(kv_str, Int_.Min_value);
decode_rslt_as_nde[i] = kv_int == Int_.Min_value ? Keyval_.new_(kv_str, kv_val) : Keyval_.int_(kv_int, kv_val); // use int_key if applicable; PAGE:it.s:Il_Re_Cervo; DATE:2015-12-06
}
return Bool_.Y_byte;
@@ -132,7 +132,7 @@ class Scrib_lib_text__json_util {
for (int i = 0; i < len; ++i) {
Json_kv itm = nde.Get_at_as_kv(i);
String kv_str = itm.Key_as_str();
int kv_int = Int_.parse_or(kv_str, Int_.Min_value);
int kv_int = Int_.Parse_or(kv_str, Int_.Min_value);
Object kv_val = Decode_obj(itm.Val());
rv[i] = kv_int == Int_.Min_value ? Keyval_.new_(kv_str, kv_val) : Keyval_.int_(kv_int, kv_val); // use int_key if applicable; PAGE:it.s:Il_Re_Cervo; DATE:2015-12-06
}
@@ -172,7 +172,7 @@ class Scrib_lib_text__json_util {
Encode_ary(kv_val);
wtr.Ary_end();
}
else if (Type_.Eq(type, Int_.Cls_ref_type)) wtr.Kv_int(kv.Key(), Int_.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));
@@ -203,8 +203,8 @@ class KeyVal__sorter__key_is_numeric implements gplx.core.lists.ComparerAble {
public int compare(Object lhsObj, Object rhsObj) {
Keyval lhs_itm = (Keyval)lhsObj;
Keyval rhs_itm = (Keyval)rhsObj;
int lhs_int = Int_.parse_or(lhs_itm.Key(), Int_.Min_value);
int rhs_int = Int_.parse_or(rhs_itm.Key(), Int_.Min_value);
int lhs_int = Int_.Parse_or(lhs_itm.Key(), Int_.Min_value);
int rhs_int = Int_.Parse_or(rhs_itm.Key(), Int_.Min_value);
return CompareAble_.Compare(lhs_int, rhs_int);
}
public static final KeyVal__sorter__key_is_numeric Instance = new KeyVal__sorter__key_is_numeric(); KeyVal__sorter__key_is_numeric() {}

View File

@@ -108,7 +108,7 @@ public class Scrib_lib_title implements Scrib_lib {
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);
int ns_id = Int_.Cast(ns_obj);
Xow_ns ns = wiki.Ns_mgr().Ids_get_or_null(ns_id);
if (ns != null)
return ns.Name_db();

View File

@@ -219,7 +219,7 @@ class Scrib_lib_ustring_gsub_mgr {
}
else if (Object_.Eq(repl_type, Int_.Cls_ref_type)) { // NOTE:@replace sometimes int; PAGE:en.d:λύω; DATE:2014-09-02
tmp_repl_tid = Repl_tid_string;
tmp_repl_bry = Bry_.new_u8(Int_.To_str(Int_.cast(repl_obj)));
tmp_repl_bry = Bry_.new_u8(Int_.To_str(Int_.Cast(repl_obj)));
}
else if (Object_.Eq(repl_type, Keyval[].class)) {
tmp_repl_tid = Repl_tid_table;

View File

@@ -154,7 +154,7 @@ public class Scrib_regx_converter {
}
}
}
if (grps_open.Count() > 0) throw Err_.new_wo_type("Unclosed capture beginning at pattern character " + Int_.cast(grps_open.Get_at(0)));
if (grps_open.Count() > 0) throw Err_.new_wo_type("Unclosed capture beginning at pattern character " + Int_.Cast(grps_open.Get_at(0)));
// bfr.Add(Bry_regx_end); // NOTE: do not add PHP /us at end; u=PCRE_UTF8 which is not needed for Java; s=PCRE_DOTALL which will be specified elsewhere
regx = bfr.To_str_and_clear();
return regx;
@@ -227,7 +227,7 @@ public class Scrib_regx_converter {
int len = list.Count();
for (int i = 0; i < len; i++) {
Object o = list.Get_at(i);
if (Int_.cast(o) == v) return true;
if (Int_.Cast(o) == v) return true;
}
return false;
}

View File

@@ -29,7 +29,7 @@ public class Scrib_proc_args {
int v_max = -1;
for (int i = 0; i < v_len; ++i) {
Keyval kv = v[i];
int idx = Int_.cast(kv.Key_as_obj());
int idx = Int_.Cast(kv.Key_as_obj());
if (v_max < idx) v_max = idx;
}
this.ary_len = v_max;
@@ -42,7 +42,7 @@ public class Scrib_proc_args {
ary = new Keyval[ary_len];
for (int i = 0; i < v_len; i++) {
Keyval kv = v[i];
int idx = Int_.cast(kv.Key_as_obj());
int idx = Int_.Cast(kv.Key_as_obj());
ary[idx - List_adp_.Base1] = kv;
}
}
@@ -54,7 +54,7 @@ public class Scrib_proc_args {
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) {
try {return Int_.coerce_(Get_or_fail(i));} // coerce to handle "1" and 1; will still fail if "abc" is passed
try {return Int_.Coerce(Get_or_fail(i));} // coerce to handle "1" and 1; will still fail if "abc" is passed
catch (Exception e) {
Err_.Noop(e);
throw Err_.new_wo_type("bad argument; int expected", "idx", i, "len", ary_len);
@@ -63,7 +63,7 @@ public class Scrib_proc_args {
public long Pull_long(int i) {return (long)Pull_double(i);}
public double Pull_double(int i) {
Object rv = Get_or_fail(i);
try {return Int_.coerce_(rv);} // coerce to handle "1" and 1; will still fail if "abc" is passed
try {return Int_.Coerce(rv);} // coerce to handle "1" and 1; will still fail if "abc" is passed
catch (Exception e) {
Err_.Noop(e);
try {return Double_.coerce_(rv);} // coerce to handle "1" and 1; will still fail if "abc" is passed
@@ -92,7 +92,7 @@ public class Scrib_proc_args {
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
int actl_key = Int_.cast(kv.Key_as_obj()); // EX: i=1; actl_key=3
int actl_key = Int_.Cast(kv.Key_as_obj()); // EX: i=1; actl_key=3
if (actl_key != expd_key) { // mismatch; gaps exist; EX:[1:a,3:c]
// 1st mismatch; create list, and add everything before itm in array to list;
if (list == null) {
@@ -122,7 +122,7 @@ public class Scrib_proc_args {
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 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 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));
if (params_idx < 0 || params_idx >= ary_len) return Bry_.Ary_empty;

View File

@@ -25,12 +25,12 @@ public class Xop_tvar_lxr implements Xop_lxr {
public int Make_tkn(Xop_ctx ctx, Xop_tkn_mkr tkn_mkr, Xop_root_tkn root, byte[] src, int src_len, int bgn_pos, int cur_pos) {
int rhs_end = Bry_find_.Find_fwd(src, Byte_ascii.Gt, cur_pos); if (rhs_end == Bry_find_.Not_found) return ctx.Lxr_make_txt_(cur_pos);
int lhs_bgn = Bry_find_.Find_fwd(src, Close_nde , rhs_end); if (lhs_bgn == Bry_find_.Not_found) return ctx.Lxr_make_txt_(cur_pos);
byte[] body = Bry_.Mid(src, rhs_end + Int_.Const_position_after_char, lhs_bgn);
byte[] body = Bry_.Mid(src, rhs_end + Int_.Offset_1, lhs_bgn);
Xop_ctx sub_ctx = Xop_ctx.New__sub__reuse_page(ctx);
Xop_root_tkn sub_root = tkn_mkr.Root(body);
body = ctx.Wiki().Parser_mgr().Main().Expand_tmpl(sub_root, sub_ctx, tkn_mkr, body); // NOTE: must parse inner text for templates; EX:<tvar|a>{{B}}</>; PAGE:mw:Download; DATE:2014-04-27
int end_pos = lhs_bgn + Close_nde.length;
ctx.Subs_add(root, tkn_mkr.Tvar(bgn_pos, end_pos, cur_pos, rhs_end, rhs_end + Int_.Const_position_after_char, lhs_bgn, body));
ctx.Subs_add(root, tkn_mkr.Tvar(bgn_pos, end_pos, cur_pos, rhs_end, rhs_end + Int_.Offset_1, lhs_bgn, body));
return end_pos;
}
public static final Xop_tvar_lxr Instance = new Xop_tvar_lxr(); Xop_tvar_lxr() {}

View File

@@ -113,9 +113,9 @@ public class Wdata_prop_val_visitor_ {
byte val_tid = Wbase_claim_time_.Reg.Get_tid_or_max_and_log(page_url, kv.Key()); if (val_tid == Byte_.Max_value_127) continue;
switch (val_tid) {
case Wbase_claim_time_.Tid__time: time = To_bry_by_str(kv.Val()); break;
case Wbase_claim_time_.Tid__before: before = Int_.cast(kv.Val()); break;
case Wbase_claim_time_.Tid__after: after = Int_.cast(kv.Val()); break;
case Wbase_claim_time_.Tid__precision: precision = Int_.cast(kv.Val()); break;
case Wbase_claim_time_.Tid__before: before = Int_.Cast(kv.Val()); break;
case Wbase_claim_time_.Tid__after: after = Int_.Cast(kv.Val()); break;
case Wbase_claim_time_.Tid__precision: precision = Int_.Cast(kv.Val()); break;
case Wbase_claim_time_.Tid__calendarmodel: calendar = To_bry_by_str(kv.Val()); break;
case Wbase_claim_time_.Tid__timezone: break;
}

View File

@@ -23,7 +23,7 @@ public class Wbase_date_tst {
fxt.Test_parse("-98765432109-02-03T04:05:06Z", -98765432109L, 2, 3, 4, 5, 6);
}
@Test public void Julian() {
fxt.Test_julian(Int_.Ary(1600, 1, 2), Int_.Ary(1600, 1, 18));
fxt.Test_julian(Int_ary_.New(1600, 1, 2), Int_ary_.New(1600, 1, 18));
}
@Test public void Xto_str() {
String date = "+00000002001-02-03T04:05:06Z";

View File

@@ -28,7 +28,7 @@ public class Xob_wdata_db_cmd extends Xob_dump_mgr_base implements Xob_cmd {
public Xob_wdata_db_cmd(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki);}
@Override public String Cmd_key() {return Xob_cmd_keys.Key_wbase_db;}
@Override public byte Init_redirect() {return Bool_.N_byte;} // json will never be found in a redirect
@Override public int[] Init_ns_ary() {return Int_.Ary(Xow_ns_.Tid__main, Wdata_wiki_mgr.Ns_property);}
@Override public int[] Init_ns_ary() {return Int_ary_.New(Xow_ns_.Tid__main, Wdata_wiki_mgr.Ns_property);}
@Override protected void Init_reset(Db_conn conn) {
Db_cfg_tbl cfg_tbl = gplx.xowa.wikis.data.Xowd_cfg_tbl_.New(conn);
cfg_tbl.Delete_all();

View File

@@ -163,7 +163,7 @@ public class Wdata_doc_parser_v1 implements Wdata_doc_parser {
rv.Wguid_(kv.Data_bry());
break;
case Prop_tid_rank:
rv.Rank_tid_((byte)Int_.cast(((Json_itm_int)kv.Val()).Data_as_int()));
rv.Rank_tid_((byte)Int_.Cast(((Json_itm_int)kv.Val()).Data_as_int()));
break;
case Prop_tid_q:
break;

View File

@@ -239,7 +239,7 @@ public class Wdata_doc_parser_v2__basic__tst {
, " }"
, " ]"
, "}"
), Int_.Ary(2, 3), fxt.Make_claim_entity_qid(2, 21), fxt.Make_claim_entity_qid(3, 31))
), Int_ary_.New(2, 3), fxt.Make_claim_entity_qid(2, 21), fxt.Make_claim_entity_qid(3, 31))
;
}
@Test public void References_empty() { // PURPOSE:sometimes references can have 0 snaks; return back an empty Wbase_claim_grp_list, not null; PAGE:Птичкин,_Евгений_Николаевич; DATE:2015-02-16
@@ -252,7 +252,7 @@ public class Wdata_doc_parser_v2__basic__tst {
, " }"
, " ]"
, "}"
), Int_.Ary_empty)
), Int_ary_.Empty)
;
}
}