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

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