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

v2.11.2.1

This commit is contained in:
gnosygnu
2015-11-08 23:48:07 -05:00
parent b990ec409f
commit d9f45cec19
298 changed files with 3908 additions and 2141 deletions

View File

@@ -212,10 +212,17 @@ class TfdsMsgBldr {
}
for (int i = 0; i < list.Count(); i++) {
TfdsEqAryItm itm = (TfdsEqAryItm)list.Get_at(i);
String eq_str = itm.Eq() ? "==" : "";
if (!itm.Eq()) {
// if (lhsLenMax < 8 )
// eq_str = "!=";
// else
eq_str = "\n!= ";
}
sb.Add_fmt_line("{0}: {1} {2} {3}"
, Int_.To_str_pad_bgn_zero(itm.Idx(), 4)
, String_.PadBgn(itm.Lhs(), lhsLenMax, " ")
, itm.Eq() ? "==" : "!="
, eq_str
, String_.PadBgn(itm.Rhs(), rhsLenMax, " ")
);
}

View File

@@ -16,7 +16,11 @@ 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;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.ParseException;
import java.util.Locale;
public class Decimal_adp_ {
@@ -53,5 +57,14 @@ import java.math.BigDecimal; import java.math.MathContext; import java.math.Roun
return Decimal_adp_.float_(Float_.Div(dividend, divisor) * 100).To_str(fmt) + "%";
}
public static Decimal_adp divide_safe_(long lhs, long rhs) {return rhs == 0 ? Zero : divide_(lhs, rhs);}
public static Decimal_adp divide_(long lhs, long rhs) {
public static Decimal_adp divide_(long lhs, long rhs) {
return new Decimal_adp(new BigDecimal(lhs).divide(new BigDecimal(rhs), Gplx_rounding_context));
}
public static Decimal_adp int_(int v) {return new Decimal_adp(new BigDecimal(v));}
public static Decimal_adp long_(long v) {return new Decimal_adp(new BigDecimal(v));}
public static Decimal_adp float_(float v) {return new Decimal_adp(new BigDecimal(v));}
public static Decimal_adp double_(double v) {return new Decimal_adp(new BigDecimal(v));}
public static Decimal_adp double_thru_str_(double v) {return new Decimal_adp(BigDecimal.valueOf(v));}
public static Decimal_adp db_(Object v) {return new Decimal_adp((BigDecimal)v);}
public static Decimal_adp parse(String raw) {
try {

View File

@@ -20,6 +20,18 @@ public class Object_ {
public static final String Cls_val_name = "Object";
public static final Object[] Ary_empty = new Object[0];
public static Object[] Ary(Object... ary) {return ary;}
public static Object[] Ary_add(Object[] lhs, Object[] rhs) {
int lhs_len = lhs.length, rhs_len = rhs.length;
if (lhs_len == 0) return rhs;
else if (rhs_len == 0) return lhs;
int rv_len = lhs_len + rhs_len;
Object[] rv = new Object[rv_len];
for (int i = 0; i < lhs_len; ++i)
rv[i] = lhs[i];
for (int i = lhs_len; i < rv_len; ++i)
rv[i] = rhs[i - lhs_len];
return rv;
}
public static boolean Eq(Object lhs, Object rhs) {
if (lhs == null && rhs == null) return true;
else if (lhs == null || rhs == null) return false;

View File

@@ -41,7 +41,7 @@ public class String_ implements GfoInvkAble {
? null
: new String(v, bgn, end - bgn, "UTF-8");
}
catch (Exception e) {throw Err_.new_exc(e, "core", "unsupported encoding");}
catch (Exception e) {Err_.Noop(e); throw Err_.new_("core", "unsupported encoding", "bgn", bgn, "end", end);}
}
public static String new_u8__by_len(byte[] v, int bgn, int len) {
int v_len = v.length;
@@ -115,7 +115,7 @@ public class String_ implements GfoInvkAble {
return false;
}
public static boolean EqNot(String lhs, String rhs) {return !Object_.Eq(lhs, rhs);}
public static boolean EqEmpty(String lhs, String rhs) {return lhs.equals("");}
public static boolean EqEmpty(String lhs) {return lhs.equals("");}
public static String IfNullOrEmpty(String s, String or) {return s == null || s.length() == 0 ? or : s;}
public static int Compare(String lhs, String rhs) {return lhs.compareTo(rhs);} // NOTE: Compare instead of compareTo b/c javafy lowercases compareTo
public static int Compare_ignoreCase(String lhs, String rhs) {

View File

@@ -286,8 +286,13 @@ public class Bry_ {
return String_.new_u8(ary);
}
public static byte[] Mid_safe(byte[] src, int bgn, int end) {
try {return Mid(src, bgn, end);}
catch (Exception e) {Err_.Noop(e); return Bry_.Add_w_dlm(Byte_ascii.Space, Bry_.new_by_int(bgn), Bry_.new_by_int(end));}
if (src == null) return null;
int src_len = src.length;
if (bgn < 0) bgn = 0;
if (end >= src_len) end = src_len;
if (bgn > end) bgn = end;
else if (end < bgn) end = bgn;
return Mid(src, bgn, end);
}
public static byte[] Mid(byte[] src, int bgn) {return Mid(src, bgn, src.length);}
public static byte[] Mid_or(byte[] src, int bgn, int end, byte[] or) {

View File

@@ -16,7 +16,7 @@ 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;
public class Bry_rdr {
public class Bry_rdr_old {
private byte[] scope = Bry_.Empty;
public byte[] Src() {return src;} protected byte[] src;
public int Src_len() {return src_len;} protected int src_len;
@@ -26,7 +26,7 @@ public class Bry_rdr {
this.src = src; this.src_len = src.length; this.pos = pos;
this.scope = scope;
}
public int Pos() {return pos;} public Bry_rdr Pos_(int v) {this.pos = v; return this;} protected int pos;
public int Pos() {return pos;} public Bry_rdr_old Pos_(int v) {this.pos = v; return this;} protected int pos;
public void Pos_add(int v) {pos += v;}
public boolean Pos_is_eos() {return pos == src_len;}
public boolean Pos_is_reading() {return pos < src_len;}
@@ -106,7 +106,7 @@ public class Bry_rdr {
byte[] double_bry = Read_bry_to(to_char);
return Double_.parse(String_.new_a7(double_bry)); // double will never have utf8
}
@gplx.Virtual public Bry_rdr Skip_ws() {
@gplx.Virtual public Bry_rdr_old Skip_ws() {
while (pos < src_len) {
switch (src[pos]) {
case Byte_ascii.Tab: case Byte_ascii.Nl: case Byte_ascii.Cr: case Byte_ascii.Space:
@@ -118,7 +118,7 @@ public class Bry_rdr {
}
return this;
}
public Bry_rdr Skip_alpha_num_under() {
public Bry_rdr_old Skip_alpha_num_under() {
while (pos < src_len) {
switch (src[pos]) {
case Byte_ascii.Num_0: case Byte_ascii.Num_1: case Byte_ascii.Num_2: case Byte_ascii.Num_3: case Byte_ascii.Num_4:

View File

@@ -17,13 +17,34 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx;
public class Gfo_usr_dlg_ {
private static Gfo_usr_dlg_base test__list, test__show;
public static Gfo_usr_dlg Instance = Gfo_usr_dlg_noop.Instance; // NOTE: global instance which can be reassigned
public static final Gfo_usr_dlg Noop = Gfo_usr_dlg_noop.Instance;
public static Gfo_usr_dlg__gui Test__list__init() {
if (test__list == null)
test__list = new Gfo_usr_dlg_base(Gfo_usr_dlg__log_.Noop, Gfo_usr_dlg__gui_.Test);
Gfo_usr_dlg__gui_.Test.Clear();
Instance = test__list;
return Gfo_usr_dlg__gui_.Test;
}
public static String Test__list__term__get_1st() {
Instance = Noop;
String[] rv = ((Gfo_usr_dlg__gui_test)test__list.Gui_wkr()).Warns().To_str_ary_and_clear();
return rv.length == 0 ? "" : rv[0];
}
public static void Test__show__init() {
if (test__show == null)
test__show = new Gfo_usr_dlg_base(Gfo_usr_dlg__log_.Noop, Gfo_usr_dlg__gui_.Console);
Instance = test__show;
}
public static void Test__show__term() {
Instance = Noop;
}
public static Gfo_usr_dlg Test() {
if (test == null)
test = new Gfo_usr_dlg_base(Gfo_usr_dlg__log_.Noop, Gfo_usr_dlg__gui_.Test);
return test;
} private static Gfo_usr_dlg_base test;
if (test__list == null)
test__list = new Gfo_usr_dlg_base(Gfo_usr_dlg__log_.Noop, Gfo_usr_dlg__gui_.Test);
return test__list;
}
public static Gfo_usr_dlg Test_console() {
if (test_console == null)
test_console = new Gfo_usr_dlg_base(Gfo_usr_dlg__log_.Noop, Gfo_usr_dlg__gui_.Console);

View File

@@ -18,13 +18,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx;
import gplx.core.strings.*;
public class Gfo_usr_dlg__gui_test implements Gfo_usr_dlg__gui {
public String[] Xto_str_ary() {return msgs.To_str_ary();}
public String[] Xto_str_ary_and_clear() {String[] rv = msgs.To_str_ary(); this.Clear(); return rv;}
public List_adp Warns() {return warns;}
public String_ring Prog_msgs() {return ring;} String_ring ring = new String_ring().Max_(0);
public List_adp Warns() {return warns;} private final List_adp warns = List_adp_.new_();
public List_adp Msgs() {return msgs;} private final List_adp msgs = List_adp_.new_();
public String_ring Prog_msgs() {return ring;} private final String_ring ring = new String_ring().Max_(0);
public void Clear() {msgs.Clear(); warns.Clear();}
public void Write_prog(String text) {msgs.Add(text);} List_adp msgs = List_adp_.new_();
public void Write_prog(String text) {msgs.Add(text);}
public void Write_note(String text) {msgs.Add(text);}
public void Write_warn(String text) {warns.Add(text);} List_adp warns = List_adp_.new_();
public void Write_warn(String text) {warns.Add(text);}
public void Write_stop(String text) {msgs.Add(text);}
}