mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v3.1.4.1
This commit is contained in:
@@ -63,12 +63,12 @@ public class KeyVal_ {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static String Ary_to_str_nested(KeyVal... ary) {
|
||||
public static String Ary__to_str__nest(KeyVal... ary) {
|
||||
Bry_bfr bfr = Bry_bfr.new_();
|
||||
Ary_to_str_nested(bfr, 0, ary);
|
||||
Ary__to_str__nest(bfr, 0, ary);
|
||||
return bfr.To_str_and_clear();
|
||||
}
|
||||
private static void Ary_to_str_nested(Bry_bfr bfr, int indent, KeyVal[] ary) {
|
||||
private static void Ary__to_str__nest(Bry_bfr bfr, int indent, KeyVal[] ary) {
|
||||
int len = ary.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
KeyVal itm = ary[i];
|
||||
@@ -82,7 +82,7 @@ public class KeyVal_ {
|
||||
Class<?> val_type = Type_adp_.ClassOf_obj(val);
|
||||
if (Type_adp_.Eq(val_type, KeyVal[].class)) { // val is KeyVal[]; recurse
|
||||
bfr.Add_byte_nl(); // add nl : "\n"
|
||||
Ary_to_str_nested(bfr, indent + 1, (KeyVal[])val);
|
||||
Ary__to_str__nest(bfr, indent + 1, (KeyVal[])val);
|
||||
continue; // don't add \n below
|
||||
}
|
||||
else if (Type_adp_.Eq(val_type, Bool_.Cls_ref_type)) { // val is boolean
|
||||
|
||||
@@ -117,7 +117,7 @@ public class String_ implements GfoInvkAble {
|
||||
public static boolean EqNot(String lhs, String rhs) {return !Object_.Eq(lhs, rhs);}
|
||||
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_as_ordinals(String lhs, String rhs) {return lhs.compareTo(rhs);}
|
||||
public static int Compare_ignoreCase(String lhs, String rhs) {
|
||||
if (lhs == null && rhs != null) return CompareAble_.Less;
|
||||
else if (lhs != null && rhs == null) return CompareAble_.More;
|
||||
@@ -131,8 +131,8 @@ public class String_ implements GfoInvkAble {
|
||||
else return lhs.compareToIgnoreCase(rhs);
|
||||
*/
|
||||
}
|
||||
public static int Compare_strict(String lhs, String rhs) {
|
||||
int compare = String_.Compare(lhs, rhs);
|
||||
public static int Compare(String lhs, String rhs) {
|
||||
int compare = lhs.compareTo(rhs);
|
||||
if (compare == CompareAble_.Same) return CompareAble_.Same;
|
||||
else if (compare < CompareAble_.Same) return CompareAble_.Less;
|
||||
else /* (compare > CompareAble_.Same) */ return CompareAble_.More;
|
||||
|
||||
@@ -166,7 +166,7 @@ public class String__tst {
|
||||
tst_Compare_byteAry("ac", "ab", CompareAble_.More);
|
||||
tst_Compare_byteAry("a", "ab", CompareAble_.Less);
|
||||
tst_Compare_byteAry("ab", "a", CompareAble_.More);
|
||||
tst_Compare_byteAry("101", "1-0-1", CompareAble_.More); // NOTE: regular String_.Compare returns Less in .NET, More in Java
|
||||
tst_Compare_byteAry("101", "1-0-1", CompareAble_.More); // NOTE: regular String_.Compare_as_ordinals returns Less in .NET, More in Java
|
||||
tst_Compare_byteAry("1-0-1", "101 (album)", CompareAble_.Less);
|
||||
} void tst_Compare_byteAry(String lhs, String rhs, int expd) {Tfds.Eq(expd, String_.Compare_byteAry(lhs, rhs));}
|
||||
@Test public void FindBwd() { // WORKAROUND.CS:String.LastIndexOf returns -1 for multi-chars;
|
||||
|
||||
@@ -71,6 +71,15 @@ public class Btrie_slim_mgr implements Btrie_mgr {
|
||||
Add_obj(ary[i], obj);
|
||||
return this;
|
||||
}
|
||||
public Btrie_slim_mgr Add_ary_byte(byte... ary) {
|
||||
int len = ary.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
byte b = ary[i];
|
||||
Byte_obj_val bval = Byte_obj_val.new_(b);
|
||||
Add_obj(Bry_.New_by_byte(b), bval);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public Btrie_slim_mgr Add_replace_many(String trg_str, String... src_ary) {return Add_replace_many(Bry_.new_u8(trg_str), src_ary);}
|
||||
public Btrie_slim_mgr Add_replace_many(byte[] trg_bry, String... src_ary) {
|
||||
int len = src_ary.length;
|
||||
|
||||
@@ -21,7 +21,7 @@ public class String_obj_val implements CompareAble {
|
||||
@Override public String toString() {return val;}
|
||||
public int compareTo(Object obj) {
|
||||
String_obj_val comp = (String_obj_val)obj;
|
||||
return String_.Compare_strict(val, comp.val);
|
||||
return String_.Compare(val, comp.val);
|
||||
}
|
||||
public static String_obj_val new_(String val) {return new String_obj_val(val);} String_obj_val(String val) {this.val = val;}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user