mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.8.5.1
This commit is contained in:
@@ -47,10 +47,10 @@ public class App_cmd_arg {
|
||||
}
|
||||
public Object Val() {return val;} public App_cmd_arg Val_(Object v) {this.val = v; return this;} Object val;
|
||||
public Object Dflt() {return dflt;} public App_cmd_arg Dflt_(Object v) {dflt = v; return this;} Object dflt;
|
||||
public boolean Val_as_bool() {return Bool_.cast_(val);}
|
||||
public boolean Val_as_bool() {return Bool_.cast(val);}
|
||||
public String Val_as_str_or(String or) {return val == null ? or : (String)val;}
|
||||
public String Val_as_str() {return (String)val;}
|
||||
public int Val_as_int_or(int or) {return val == null ? or : Int_.parse_or_((String)val, or);}
|
||||
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(owner_dir, or, true);}
|
||||
public Io_url Val_as_url_rel_fil_or(Io_url owner_dir, Io_url or) {return Val_as_url_rel_url_or(owner_dir, or, false);}
|
||||
public Io_url Val_as_url_rel_url_or(Io_url owner_dir, Io_url or, boolean dir) {return Val_as_url_rel_url_or(Val_as_str(), owner_dir, or, dir);}
|
||||
|
||||
@@ -30,5 +30,5 @@ public class Gfo_usr_dlg_fmt {
|
||||
rv.fmt = fmt; rv.end = end; rv.endLen = Int_.DigitCount(end); rv.prog_interval = (int)((float)end * (float)(pct / (float)100));;
|
||||
return rv;
|
||||
} String grp_key, msg_key;
|
||||
int prog_interval; int prog_prv = Int_.MinValue;
|
||||
int prog_interval; int prog_prv = Int_.Min_value;
|
||||
}
|
||||
|
||||
@@ -33,11 +33,11 @@ public class Int_2_ref {
|
||||
Int_2_ref comp = (Int_2_ref)obj;
|
||||
return val_0 == comp.val_0 && val_1 == comp.val_1;
|
||||
}
|
||||
public static Int_2_ref parse_(String raw) {
|
||||
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);}
|
||||
}
|
||||
@@ -48,8 +48,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;
|
||||
|
||||
@@ -22,11 +22,11 @@ public class Int_2_val {
|
||||
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 Int_2_val parse_(String raw) {
|
||||
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_.MinValue); if (v0 == Int_.MinValue) return Null_ptr;
|
||||
int v1 = Int_.parse_or_(itms[1], Int_.MinValue); if (v1 == Int_.MinValue) 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).Xto_str_and_clear();}
|
||||
|
||||
@@ -42,5 +42,27 @@ public class Int_ary {
|
||||
ary[len] = v;
|
||||
++len;
|
||||
}
|
||||
public int Pop_or(int or) {
|
||||
if (len == 0) return or;
|
||||
int rv = ary[len - 1];
|
||||
--len;
|
||||
return rv;
|
||||
}
|
||||
public int Idx_of(int key) {
|
||||
for (int i = len - 1; i > -1; --i) {
|
||||
int val = ary[i];
|
||||
if (val == key) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
public boolean Del_by_key_from_end(int key) {
|
||||
int key_idx = Idx_of(key); if (key_idx == -1) return false;
|
||||
int last_idx = len - 1;
|
||||
for (int i = key_idx; i < last_idx; ++i)
|
||||
ary[i] = ary[i + 1];
|
||||
ary[last_idx] = 0;
|
||||
--len;
|
||||
return true;
|
||||
}
|
||||
public int Get_at(int i) {return ary[i];}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx;
|
||||
public class Number_parser {
|
||||
public int Rv_as_int() {return (int)int_val;} long int_val = 0;
|
||||
public Decimal_adp Rv_as_dec() {return dec_val == null ? Decimal_adp_.long_(int_val) : dec_val;} Decimal_adp dec_val = null;
|
||||
public int Rv_as_int() {return (int)int_val;} private long int_val = 0;
|
||||
public Decimal_adp Rv_as_dec() {return dec_val == null ? Decimal_adp_.long_(int_val) : dec_val;} private Decimal_adp dec_val = null;
|
||||
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;
|
||||
|
||||
@@ -29,19 +29,19 @@ public class Number_parser_tst {
|
||||
fxt.Test_int("00001", 1);
|
||||
}
|
||||
@Test public void Decimal() {
|
||||
fxt.Test_dec("1.23", Decimal_adp_.parse_("1.23"));
|
||||
fxt.Test_dec("1.023", Decimal_adp_.parse_("1.023"));
|
||||
fxt.Test_dec("-1.23", Decimal_adp_.parse_("-1.23"));
|
||||
fxt.Test_dec("1.23", Decimal_adp_.parse("1.23"));
|
||||
fxt.Test_dec("1.023", Decimal_adp_.parse("1.023"));
|
||||
fxt.Test_dec("-1.23", Decimal_adp_.parse("-1.23"));
|
||||
}
|
||||
@Test public void Double_long() {
|
||||
fxt.Test_dec(".42190046219457", Decimal_adp_.parse_(".42190046219457"));
|
||||
fxt.Test_dec(".42190046219457", Decimal_adp_.parse(".42190046219457"));
|
||||
}
|
||||
@Test public void Exponent() {
|
||||
fxt.Test_int("1E2", 100);
|
||||
fxt.Test_dec("1.234E2", Decimal_adp_.parse_("123.4"));
|
||||
fxt.Test_dec("1.234E-2", Decimal_adp_.parse_(".01234"));
|
||||
fxt.Test_dec("123.4E-2", Decimal_adp_.parse_("1.234"));
|
||||
fxt.Test_dec("+6.0E-3", Decimal_adp_.parse_(".006"));
|
||||
fxt.Test_dec("1.234E2", Decimal_adp_.parse("123.4"));
|
||||
fxt.Test_dec("1.234E-2", Decimal_adp_.parse(".01234"));
|
||||
fxt.Test_dec("123.4E-2", Decimal_adp_.parse("1.234"));
|
||||
fxt.Test_dec("+6.0E-3", Decimal_adp_.parse(".006"));
|
||||
}
|
||||
@Test public void Err() {
|
||||
fxt.Test_err("+", true);
|
||||
|
||||
@@ -58,8 +58,8 @@ class StatRng_fxt {
|
||||
}
|
||||
class StatRng {
|
||||
// public String Key;
|
||||
public int Lo = Int_.MaxValue;
|
||||
public int Hi = Int_.MinValue;
|
||||
public int Lo = Int_.Max_value;
|
||||
public int Hi = Int_.Min_value;
|
||||
public long Sum = 0;
|
||||
public int Count = 0;
|
||||
public float Avg() {return Sum / Count;}
|
||||
@@ -73,21 +73,21 @@ class StatRng {
|
||||
public int Slot_ary_len;
|
||||
public StatRng(int lo_ary_len, int hi_ary_len, int... slot_hi_ary) {
|
||||
this.Lo_ary_len = lo_ary_len;
|
||||
this.Lo_ary_bound = Int_.MaxValue;
|
||||
this.Lo_ary = NewBoundAry(lo_ary_len, Int_.MaxValue);
|
||||
this.Lo_ary_bound = Int_.Max_value;
|
||||
this.Lo_ary = NewBoundAry(lo_ary_len, Int_.Max_value);
|
||||
this.Hi_ary_len = hi_ary_len;
|
||||
this.Hi_ary_bound = Int_.MinValue;
|
||||
this.Hi_ary = NewBoundAry(hi_ary_len, Int_.MinValue);
|
||||
this.Hi_ary_bound = Int_.Min_value;
|
||||
this.Hi_ary = NewBoundAry(hi_ary_len, Int_.Min_value);
|
||||
if (slot_hi_ary != null && slot_hi_ary.length > 0) {
|
||||
Slot_ary_len = slot_hi_ary.length + 1; // + 1 to hold max value
|
||||
Slot_ary = new StatRng[Slot_ary_len];
|
||||
int slot_lo = Int_.MinValue;
|
||||
int slot_lo = Int_.Min_value;
|
||||
for (int i = 0; i < Slot_ary_len - 1; i++) {
|
||||
int slot_hi = slot_hi_ary[i];
|
||||
Slot_ary[i] = NewSlot(slot_lo, slot_hi);
|
||||
slot_lo = slot_hi;
|
||||
}
|
||||
Slot_ary[Slot_ary_len - 1] = NewSlot(slot_lo, Int_.MaxValue);
|
||||
Slot_ary[Slot_ary_len - 1] = NewSlot(slot_lo, Int_.Max_value);
|
||||
}
|
||||
}
|
||||
public void Assign(Object key, int val) {
|
||||
@@ -104,10 +104,10 @@ class StatRng {
|
||||
}
|
||||
}
|
||||
if (val < Lo_ary_bound) {
|
||||
Lo_ary_bound = CalcCutoff(Lo_ary, CompareAble_.More, Int_.MinValue, key, val);
|
||||
Lo_ary_bound = CalcCutoff(Lo_ary, CompareAble_.More, Int_.Min_value, key, val);
|
||||
}
|
||||
if (val > Hi_ary_bound) {
|
||||
Hi_ary_bound = CalcCutoff(Hi_ary, CompareAble_.Less, Int_.MaxValue, key, val);
|
||||
Hi_ary_bound = CalcCutoff(Hi_ary, CompareAble_.Less, Int_.Max_value, key, val);
|
||||
}
|
||||
}
|
||||
int CalcCutoff(StatItm[] ary, int comp, int bgn_bound, Object key, int val) {
|
||||
|
||||
Reference in New Issue
Block a user