mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
'v3.8.1.1'
This commit is contained in:
@@ -22,5 +22,5 @@ public class Bry_comparer implements ComparerAble {
|
||||
byte[] lhs = (byte[])lhsObj, rhs = (byte[])rhsObj;
|
||||
return Bry_.Compare(lhs, 0, lhs.length, rhs, 0, rhs.length);
|
||||
}
|
||||
public static final Bry_comparer Instance = new Bry_comparer(); Bry_comparer() {}
|
||||
public static final Bry_comparer Instance = new Bry_comparer(); Bry_comparer() {} // TS.static
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ class Gfo_cache_itm_comparer implements gplx.core.lists.ComparerAble {
|
||||
Gfo_cache_itm rhs = (Gfo_cache_itm)rhsObj;
|
||||
return Long_.Compare(lhs.Touched(), rhs.Touched());
|
||||
}
|
||||
public static final Gfo_cache_itm_comparer Touched_asc = new Gfo_cache_itm_comparer();
|
||||
public static final Gfo_cache_itm_comparer Touched_asc = new Gfo_cache_itm_comparer(); // TS.static
|
||||
}
|
||||
class Io_url_exists_mgr {
|
||||
private gplx.core.caches.Gfo_cache_mgr_bry cache_mgr = new gplx.core.caches.Gfo_cache_mgr_bry();
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.core.flds; import gplx.*; import gplx.core.*;
|
||||
import gplx.core.encoders.*;
|
||||
public class Gfo_fld_rdr extends Gfo_fld_base {
|
||||
private Bry_bfr bfr = Bry_bfr_.New(); private static final byte[] Bry_nil = Bry_.new_a7("\\0");
|
||||
private Bry_bfr bfr = Bry_bfr_.New();
|
||||
public byte[] Data() {return data;} public Gfo_fld_rdr Data_(byte[] v) {data = v; data_len = v.length; pos = 0; return this;} private byte[] data; int data_len;
|
||||
public int Pos() {return pos;} public Gfo_fld_rdr Pos_(int v) {pos = v; return this;} private int pos;
|
||||
public int Fld_bgn() {return fld_bgn;} public Gfo_fld_rdr Fld_bgn_(int v) {fld_bgn = v; return this;} private int fld_bgn;
|
||||
@@ -122,4 +122,5 @@ public class Gfo_fld_rdr extends Gfo_fld_base {
|
||||
public Gfo_fld_rdr Ctor_sql() {return (Gfo_fld_rdr)super.Ctor_sql_base();}
|
||||
public static Gfo_fld_rdr xowa_() {return new Gfo_fld_rdr().Ctor_xdat();}
|
||||
public static Gfo_fld_rdr sql_() {return new Gfo_fld_rdr().Ctor_sql();}
|
||||
private static final byte[] Bry_nil = Bry_.new_a7("\\0");
|
||||
}
|
||||
|
||||
@@ -25,5 +25,5 @@ class Io_sort_filCmd_null implements Io_sort_filCmd {
|
||||
public void Bfr_add(Io_line_rdr stream) {}
|
||||
public void Fil_bgn(Io_line_rdr stream) {}
|
||||
public void Fil_end() {}
|
||||
public static final Io_sort_filCmd_null Instance = new Io_sort_filCmd_null(); Io_sort_filCmd_null() {}
|
||||
public static final Io_sort_filCmd_null Instance = new Io_sort_filCmd_null(); Io_sort_filCmd_null() {} // TS.static
|
||||
}
|
||||
|
||||
@@ -19,8 +19,7 @@ package gplx.core.ios; import gplx.*; import gplx.core.*;
|
||||
public class Io_sort_split_itm_sorter implements gplx.core.lists.ComparerAble {
|
||||
public int compare(Object lhsObj, Object rhsObj) {
|
||||
Io_sort_split_itm lhs = (Io_sort_split_itm)lhsObj, rhs = (Io_sort_split_itm)rhsObj;
|
||||
// Tfds.Dbg(String_.new_u8(lhs.Bfr(), lhs.Key_bgn(), lhs.Key_end()), String_.new_u8(rhs.Bfr(), rhs.Key_bgn(), rhs.Key_end()));
|
||||
return Bry_.Compare(lhs.Bfr(), lhs.Key_bgn(), lhs.Key_end(), rhs.Bfr(), rhs.Key_bgn(), rhs.Key_end());
|
||||
}
|
||||
public static final Io_sort_split_itm_sorter Instance = new Io_sort_split_itm_sorter(); Io_sort_split_itm_sorter() {}
|
||||
public static final Io_sort_split_itm_sorter Instance = new Io_sort_split_itm_sorter(); Io_sort_split_itm_sorter() {} // TS.static
|
||||
}
|
||||
|
||||
@@ -16,21 +16,21 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.core.primitives; import gplx.*; import gplx.core.*;
|
||||
public class Number_parser {
|
||||
public class Gfo_number_parser {
|
||||
public int Rv_as_int() {return (int)num_val;} private long num_val = 0;
|
||||
public long Rv_as_long() {return num_val;}
|
||||
public Decimal_adp Rv_as_dec() {return dec_val == null ? Decimal_adp_.long_(num_val) : dec_val;} private Decimal_adp dec_val = null;
|
||||
public boolean Is_int() {return dec_val == null && (num_val >= Int_.Min_value && num_val <= Int_.Max_value);}
|
||||
public boolean Has_err() {return has_err;} private boolean has_err;
|
||||
public boolean Has_frac() {return has_frac;} private boolean has_frac;
|
||||
public boolean Hex_enabled() {return hex_enabled;} public Number_parser Hex_enabled_(boolean v) {hex_enabled = v; return this;} private boolean hex_enabled;
|
||||
public Number_parser Ignore_chars_(byte[] v) {this.ignore_chars = v; return this;} private byte[] ignore_chars;
|
||||
public Number_parser Ignore_space_at_end_y_() {this.ignore_space_at_end = true; return this;} private boolean ignore_space_at_end;
|
||||
public boolean Hex_enabled() {return hex_enabled;} public Gfo_number_parser Hex_enabled_(boolean v) {hex_enabled = v; return this;} private boolean hex_enabled;
|
||||
public Gfo_number_parser Ignore_chars_(byte[] v) {this.ignore_chars = v; return this;} private byte[] ignore_chars;
|
||||
public Gfo_number_parser Ignore_space_at_end_y_() {this.ignore_space_at_end = true; return this;} private boolean ignore_space_at_end;
|
||||
public void Clear() {
|
||||
ignore_chars = null;
|
||||
}
|
||||
public Number_parser Parse(byte[] src) {return Parse(src, 0, src.length);}
|
||||
public Number_parser Parse(byte[] ary, int bgn, int end) {
|
||||
public Gfo_number_parser Parse(byte[] src) {return Parse(src, 0, src.length);}
|
||||
public Gfo_number_parser Parse(byte[] ary, int bgn, int end) {
|
||||
int loop_bgn = end - 1, loop_end = bgn - 1, exp_multiplier = 1, factor = 10;
|
||||
long multiplier = 1, frc_multiplier = 1;
|
||||
num_val = 0; dec_val = null; boolean comma_nil = true;
|
||||
@@ -183,5 +183,5 @@ public class Number_parser {
|
||||
}
|
||||
return this;
|
||||
}
|
||||
private Number_parser Has_err_y_() {has_err = true; return this;}
|
||||
private Gfo_number_parser Has_err_y_() {has_err = true; return this;}
|
||||
}
|
||||
@@ -17,9 +17,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.core.primitives; import gplx.*; import gplx.core.*;
|
||||
import org.junit.*;
|
||||
public class Number_parser_tst {
|
||||
private final Number_parser_fxt fxt = new Number_parser_fxt();
|
||||
@Before public void init() {fxt.Clear();}
|
||||
public class Gfo_number_parser_tst {
|
||||
@Before public void init() {fxt.Clear();} private final Gfo_number_parser_fxt fxt = new Gfo_number_parser_fxt();
|
||||
@Test public void Integer() {
|
||||
fxt.Test_int("1", 1);
|
||||
fxt.Test_int("1234", 1234);
|
||||
@@ -71,8 +70,8 @@ public class Number_parser_tst {
|
||||
fxt.Test_err("1\r" , true);
|
||||
}
|
||||
}
|
||||
class Number_parser_fxt {
|
||||
private final Number_parser parser = new Number_parser();
|
||||
class Gfo_number_parser_fxt {
|
||||
private final Gfo_number_parser parser = new Gfo_number_parser();
|
||||
public void Clear() {parser.Clear();}
|
||||
public void Init_ignore(String chars) {parser.Ignore_chars_(Bry_.new_a7(chars));}
|
||||
public void Test_int(String raw, int expd) {
|
||||
29
400_xowa/src/gplx/core/primitives/Hash_adp__primitive.java
Normal file
29
400_xowa/src/gplx/core/primitives/Hash_adp__primitive.java
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.core.primitives; import gplx.*; import gplx.core.*;
|
||||
public class Hash_adp__primitive {
|
||||
private final Hash_adp hash = Hash_adp_.New();
|
||||
public byte Get_by_str_or_max(String key) {
|
||||
Byte_obj_val rv = (Byte_obj_val)hash.Get_by(key);
|
||||
return rv == null ? Byte_.Max_value_127 : rv.Val();
|
||||
}
|
||||
public Hash_adp__primitive Add_byte(String key, byte val) {
|
||||
hash.Add(key, Byte_obj_val.new_(val));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.core.primitives; import gplx.*; import gplx.core.*;
|
||||
public class Int_ary_parser extends Obj_ary_parser_base {
|
||||
Number_parser parser = new Number_parser(); int[] ary; int ary_idx;
|
||||
private final Gfo_number_parser parser = new Gfo_number_parser();
|
||||
private int[] ary; private int ary_idx;
|
||||
public int[] Parse_ary(String str, byte dlm) {byte[] bry = Bry_.new_u8(str); return Parse_ary(bry, 0, bry.length, dlm);}
|
||||
public int[] Parse_ary(byte[] bry, int bgn, int end, byte dlm) {
|
||||
Parse_core(bry, bgn, end, dlm, Byte_ascii.Null);
|
||||
@@ -35,5 +36,4 @@ public class Int_ary_parser extends Obj_ary_parser_base {
|
||||
parser.Parse(bry, bgn, end); if (parser.Has_err() || parser.Has_frac()) throw Err_.new_wo_type("failed to parse number", "val", String_.new_u8(bry, bgn, end));
|
||||
ary[ary_idx++] = parser.Rv_as_int();
|
||||
}
|
||||
public static final Int_ary_parser Instance = new Int_ary_parser();
|
||||
}
|
||||
|
||||
@@ -16,13 +16,15 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.core.primitives; import gplx.*; import gplx.core.*;
|
||||
import org.junit.*;
|
||||
import org.junit.*; import gplx.core.tests.*;
|
||||
public class Int_ary_parser_tst {
|
||||
@Test public void Many() {tst_ints("1,2,3,4,5" , 0, 9, Int_.Ary(1, 2, 3, 4, 5));}
|
||||
@Test public void One() {tst_ints("1" , 0, 1, Int_.Ary(1));}
|
||||
@Test public void None() {tst_ints("" , 0, 0, Int_.Ary());}
|
||||
private void tst_ints(String raw, int bgn, int end, int[] expd) {
|
||||
int[] actl = Int_ary_parser.Instance.Parse_ary(Bry_.new_a7(raw), bgn, end, Byte_ascii.Comma);
|
||||
Tfds.Eq_ary(expd, actl);
|
||||
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());}
|
||||
}
|
||||
class Int_ary_parser_fxt {
|
||||
public void Test__Parse_ary(String raw, int bgn, int end, int[] expd) {
|
||||
Gftest.Eq__ary(expd, new Int_ary_parser().Parse_ary(Bry_.new_a7(raw), bgn, end, Byte_ascii.Comma), "parse_ary failed");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public class Int_pool {
|
||||
return;
|
||||
}
|
||||
if (available_len == uid_max) {
|
||||
available_list.Add(Int_obj_val.new_(v));
|
||||
available_list.Add(new Int_obj_val(v));
|
||||
available_list.Sort();
|
||||
for (int i = 0; i < available_len; ++i) {
|
||||
Int_obj_val itm = (Int_obj_val)available_list.Get_at(i);
|
||||
@@ -62,7 +62,7 @@ public class Int_pool {
|
||||
}
|
||||
else {
|
||||
// dbg_bfr.Add_str("-:a:").Add_int_variable(v).Add_byte_nl();
|
||||
available_list.Add(Int_obj_val.new_(v));
|
||||
available_list.Add(new Int_obj_val(v));
|
||||
++available_len;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user