1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00
This commit is contained in:
gnosygnu
2014-09-28 23:43:46 -04:00
parent 314de43d76
commit 81c8e2554c
117 changed files with 3079 additions and 2223 deletions

View File

@@ -208,6 +208,32 @@ public class Bry_ {
if (b == find) src[i] = repl;
}
}
public static byte[] Add_w_dlm(byte[] dlm, byte[]... ary) {
int ary_len = ary.length;
if (ary_len == 0) return Bry_.Empty;
int dlm_len = dlm.length;
int rv_len = dlm_len * (ary_len - 1); // rv will have at least as many dlms as itms - 1
for (int i = 0; i < ary_len; i++) {
byte[] itm = ary[i];
if (itm != null) rv_len += itm.length;
}
int rv_pos = 0;
byte[] rv = new byte[rv_len];
for (int i = 0; i < ary_len; i++) {
byte[] itm = ary[i];
if (i != 0) {
for (int j = 0; j < dlm_len; j++) {
rv[rv_pos++] = dlm[j];
}
}
if (itm == null) continue;
int itm_len = itm.length;
for (int j = 0; j < itm_len; j++) {
rv[rv_pos++] = itm[j];
}
}
return rv;
}
public static byte[] Add_w_dlm(byte dlm, byte[]... ary) {
int ary_len = ary.length;
if (ary_len == 0) return Bry_.Empty;

View File

@@ -228,15 +228,6 @@ public class Bry__tst {
rv[i] = String_.new_utf8_(lines[i]);
return rv;
}
@Test public void Add_w_dlm() {
Tst_add_w_dlm(Byte_ascii.Pipe, String_.Ary("a", "b", "c") , "a|b|c"); // basic
Tst_add_w_dlm(Byte_ascii.Pipe, String_.Ary("a") , "a"); // one item
Tst_add_w_dlm(Byte_ascii.Pipe, String_.Ary("a", null, "c") , "a||c"); // null
}
void Tst_add_w_dlm(byte dlm, String[] itms, String expd) {
byte[] actl = Bry_.Add_w_dlm(dlm, Bry_.Ary(itms));
Tfds.Eq(expd, String_.new_ascii_(actl));
}
@Test public void Match_bwd_any() {
Tst_match_bwd_any("abc", 2, 0, "c", true);
Tst_match_bwd_any("abc", 2, 0, "b", false);
@@ -268,6 +259,14 @@ public class Bry__tst {
fxt.Test_new_utf8_("" , Bry_.ints_(226, 130, 172)); // bry_len=3; euro
fxt.Test_new_utf8_("𤭢" , Bry_.ints_(240, 164, 173, 162)); // bry_len=3; example from en.w:UTF-8
}
@Test public void Add_w_dlm() {
fxt.Test_add_w_dlm(Byte_ascii.Pipe, String_.Ary("a", "b", "c") , "a|b|c"); // basic
fxt.Test_add_w_dlm(Byte_ascii.Pipe, String_.Ary("a") , "a"); // one item
fxt.Test_add_w_dlm(Byte_ascii.Pipe, String_.Ary("a", null, "c") , "a||c"); // null
}
@Test public void Add_w_dlm_bry() {
fxt.Test_add_w_dlm("<>", String_.Ary("a","b","c"), "a<>b<>c");
}
}
class Bry__fxt {
public void Test_trim_end(String raw, byte trim, String expd) {
@@ -276,4 +275,6 @@ class Bry__fxt {
}
public void Test_new_utf8_(String raw, byte[] expd) {Tfds.Eq_ary(expd, Bry_.new_utf8_(raw));}
public void Test_new_ascii_(String raw, byte[] expd) {Tfds.Eq_ary(expd, Bry_.new_ascii_(raw));}
public void Test_add_w_dlm(String dlm, String[] itms, String expd) {Tfds.Eq(expd, String_.new_utf8_(Bry_.Add_w_dlm(Bry_.new_utf8_(dlm), Bry_.Ary(itms))));}
public void Test_add_w_dlm(byte dlm, String[] itms, String expd) {Tfds.Eq(expd, String_.new_utf8_(Bry_.Add_w_dlm(dlm, Bry_.Ary(itms))));}
}

View File

@@ -76,6 +76,7 @@ public class Byte_ascii {
, Dot_bry = new byte[] {Byte_ascii.Dot}
, Comma_bry = new byte[] {Byte_ascii.Comma}
, Colon_bry = new byte[] {Byte_ascii.Colon}
, Amp_bry = new byte[] {Byte_ascii.Amp}
, Lt_bry = new byte[] {Byte_ascii.Lt}
, Gt_bry = new byte[] {Byte_ascii.Gt}
, Brack_bgn_bry = new byte[] {Byte_ascii.Brack_bgn}

View File

@@ -66,7 +66,6 @@ public class Io_mgr { // exists primarily to gather all cmds under gplx namespac
}
public void AliasDir_sysEngine(String srcRoot, String trgRoot) {AliasDir(srcRoot, trgRoot, IoEngine_.SysKey);}
public void AliasDir(String srcRoot, String trgRoot, String engineKey) {IoUrlInfoRegy._.Reg(IoUrlInfo_.alias_(srcRoot, trgRoot, engineKey));}
// public IoStream OpenStreamRead2(Io_url url) {return IoEngine_xrg_openRead.new_(url).ExecAsIoStreamOrFail();}
public IoStream OpenStreamRead(Io_url url) {return OpenStreamRead_args(url).ExecAsIoStreamOrFail();}
public IoEngine_xrg_openRead OpenStreamRead_args(Io_url url) {return IoEngine_xrg_openRead.new_(url);}
public String LoadFilStr(String url) {return LoadFilStr_args(Io_url_.new_fil_(url)).Exec();}