mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v1.10.2.1
This commit is contained in:
@@ -23,7 +23,7 @@ public class App_cmd_mgr {
|
||||
public String Arg_prefix() {return arg_prefix;} public App_cmd_mgr Arg_prefix_(String v) {arg_prefix = v; prefix_len = String_.Len(v); return this;} private String arg_prefix = "--"; int prefix_len = 2;
|
||||
public void Clear() {expd_args.Clear(); actl_args.Clear(); errs.Clear(); key_help = key_header = null;}
|
||||
public int Actl_len() {return actl_args.Count();}
|
||||
public App_cmd_arg[] Actl_ary() {return (App_cmd_arg[])actl_args.XtoAry(App_cmd_arg.class);}
|
||||
public App_cmd_arg[] Actl_ary() {return (App_cmd_arg[])actl_args.Xto_ary(App_cmd_arg.class);}
|
||||
public App_cmd_mgr Expd_add_many(App_cmd_arg... ary) {for (App_cmd_arg o : ary) Expd_add(o); return this;}
|
||||
public App_cmd_mgr Expd_add(App_cmd_arg prm) {
|
||||
expd_args.Add(prm.Key(), prm);
|
||||
@@ -99,7 +99,7 @@ public class App_cmd_mgr {
|
||||
for (int i = 0; i < len; i++)
|
||||
sb.Add_fmt_line(" [{0}] = '{1}'", i, orig_ary[i]);
|
||||
}
|
||||
usr_dlg.Note_none(GRP_KEY, "print.args", sb.XtoStrAndClear());
|
||||
usr_dlg.Note_none(GRP_KEY, "print.args", sb.Xto_str_and_clear());
|
||||
} String_bldr sb = String_bldr_.new_();
|
||||
public void Print_fail(Gfo_usr_dlg usr_dlg) {
|
||||
sb.Add("** error: ").Add_char_crlf();
|
||||
@@ -110,7 +110,7 @@ public class App_cmd_mgr {
|
||||
}
|
||||
sb.Add_char_crlf();
|
||||
sb.Add_str_w_crlf(String_.Repeat("-", 80));
|
||||
usr_dlg.Note_none(GRP_KEY, "print.fail", sb.XtoStrAndClear());
|
||||
usr_dlg.Note_none(GRP_KEY, "print.fail", sb.Xto_str_and_clear());
|
||||
}
|
||||
public void Print_help(Gfo_usr_dlg usr_dlg, String app_name) {
|
||||
sb.Add_str_w_crlf("example:");
|
||||
@@ -140,7 +140,7 @@ public class App_cmd_mgr {
|
||||
// sb.Add(" ").Add(String_.PadEnd(expdInf.Key(), key_max + 1, " ")).Add_str_w_crlf(expdInf.Descrip());
|
||||
// }
|
||||
}
|
||||
usr_dlg.Note_gui_none(GRP_KEY, "print.info", sb.XtoStrAndClear());
|
||||
usr_dlg.Note_gui_none(GRP_KEY, "print.info", sb.Xto_str_and_clear());
|
||||
}
|
||||
private OrderedHash Expd_copy() {
|
||||
OrderedHash rv = OrderedHash_.new_();
|
||||
|
||||
@@ -80,7 +80,7 @@ public class Gfo_log_wtr_base implements Gfo_log_wtr {
|
||||
}
|
||||
catch (Exception e) {Err_.Noop(e);} // java.lang.StringBuilder can throw exceptions in some situations when called on a different thread; ignore errors
|
||||
} private String_bldr sb = String_bldr_.new_thread(); // NOTE: use java.lang.StringBuffer to try to avoid random exceptions when called on a different thread
|
||||
private String Bld_msg(String s) {return sb.Add(DateAdp_.Now().XtoUtc().XtoStr_fmt_yyyyMMdd_HHmmss_fff()).Add(" ").Add(s).Add_char_nl().XtoStrAndClear();}
|
||||
private String Bld_msg(String s) {return sb.Add(DateAdp_.Now().XtoUtc().XtoStr_fmt_yyyyMMdd_HHmmss_fff()).Add(" ").Add(s).Add_char_nl().Xto_str_and_clear();}
|
||||
private void Log_msg(Io_url url, String txt) {
|
||||
if (queue_enabled) {
|
||||
String url_raw = url == null ? "mem" : url.Raw();
|
||||
@@ -111,7 +111,7 @@ class Usr_log_fil {
|
||||
public void Flush() {
|
||||
if (sb.Count() == 0) return;
|
||||
try {
|
||||
Io_mgr._.AppendFilStr(url, sb.XtoStrAndClear());
|
||||
Io_mgr._.AppendFilStr(url, sb.Xto_str_and_clear());
|
||||
}
|
||||
catch (Exception e) {
|
||||
ConsoleAdp._.WriteLine(Err_.Message_gplx_brief(e));
|
||||
|
||||
@@ -80,7 +80,7 @@ public class Gfo_url_parser {
|
||||
while (loop) {
|
||||
if (pos == end) {
|
||||
encoder.Decode(src, bgn, end, tmp_bfr, false);
|
||||
url.Site_(tmp_bfr.XtoAryAndClear());
|
||||
url.Site_(tmp_bfr.Xto_bry_and_clear());
|
||||
url.Err_(Gfo_url.Err_protocol_missing); pass = false;
|
||||
break;
|
||||
}
|
||||
@@ -109,7 +109,7 @@ public class Gfo_url_parser {
|
||||
case Byte_ascii.Slash:
|
||||
if (pos == 0 && pos + 1 < end && src[pos + 1] == Byte_ascii.Slash) { // starts with "//"
|
||||
encoder.Decode(src, bgn, pos, tmp_bfr, false);
|
||||
url.Site_(tmp_bfr.XtoAryAndClear());
|
||||
url.Site_(tmp_bfr.Xto_bry_and_clear());
|
||||
url.Protocol_is_relative_(true);
|
||||
url.Protocol_tid_(relative_url_protocol);
|
||||
byte[] protocol_bry = Xoo_protocol_itm.Ary()[relative_url_protocol].Key_w_colon_bry();
|
||||
@@ -119,7 +119,7 @@ public class Gfo_url_parser {
|
||||
}
|
||||
else { // has "/"
|
||||
encoder.Decode(src, bgn, pos, tmp_bfr, false);
|
||||
url.Site_(tmp_bfr.XtoAryAndClear());
|
||||
url.Site_(tmp_bfr.Xto_bry_and_clear());
|
||||
Parse_segs(src, pos + 1, end);
|
||||
loop = false;
|
||||
url.Err_(Gfo_url.Err_protocol_missing); pass = false;
|
||||
@@ -208,7 +208,7 @@ public class Gfo_url_parser {
|
||||
}
|
||||
++pos;
|
||||
}
|
||||
url.Segs_((byte[][])segs.XtoAry(byte[].class));
|
||||
url.Segs_((byte[][])segs.Xto_ary(byte[].class));
|
||||
}
|
||||
private void Parse_anchor(byte[] src, int bgn, int end) {
|
||||
if (bgn == end) return;
|
||||
@@ -263,32 +263,32 @@ public class Gfo_url_parser {
|
||||
++pos;
|
||||
}
|
||||
url.Args_bgn_(bgn - 1); // NOTE: bgn is 1st char after ?; -1 to place at ?
|
||||
url.Args_((Gfo_url_arg[])args.XtoAry(Gfo_url_arg.class));
|
||||
url.Args_((Gfo_url_arg[])args.Xto_ary(Gfo_url_arg.class));
|
||||
}
|
||||
private void Site_set(byte[] src, int bgn, int end, int dot_count, int dot_pos_0, int dot_pos_1) {
|
||||
encoder.Decode(src, bgn, end, tmp_bfr, false);
|
||||
url.Site_(tmp_bfr.XtoAryAndClear());
|
||||
url.Site_(tmp_bfr.Xto_bry_and_clear());
|
||||
switch (dot_count) {
|
||||
default:
|
||||
case 2:
|
||||
encoder.Decode(src, bgn, dot_pos_0, tmp_bfr, false);
|
||||
url.Site_sub_(tmp_bfr.XtoAryAndClear());
|
||||
url.Site_sub_(tmp_bfr.Xto_bry_and_clear());
|
||||
encoder.Decode(src, dot_pos_0 + 1, dot_pos_1, tmp_bfr, false);
|
||||
url.Site_name_(tmp_bfr.XtoAryAndClear());
|
||||
url.Site_name_(tmp_bfr.Xto_bry_and_clear());
|
||||
encoder.Decode(src, dot_pos_1 + 1, end, tmp_bfr, false);
|
||||
url.Site_domain_(tmp_bfr.XtoAryAndClear());
|
||||
url.Site_domain_(tmp_bfr.Xto_bry_and_clear());
|
||||
break;
|
||||
case 1:
|
||||
encoder.Decode(src, bgn, dot_pos_0, tmp_bfr, false);
|
||||
url.Site_name_(tmp_bfr.XtoAryAndClear());
|
||||
url.Site_name_(tmp_bfr.Xto_bry_and_clear());
|
||||
encoder.Decode(src, dot_pos_0 + 1, end, tmp_bfr, false);
|
||||
url.Site_domain_(tmp_bfr.XtoAryAndClear());
|
||||
url.Site_domain_(tmp_bfr.Xto_bry_and_clear());
|
||||
break;
|
||||
}
|
||||
}
|
||||
private void Segs_add(byte[] src, int bgn, int end) {
|
||||
encoder.Decode(src, bgn, end, tmp_bfr, false);
|
||||
byte[] seg = tmp_bfr.XtoAryAndClear();
|
||||
byte[] seg = tmp_bfr.Xto_bry_and_clear();
|
||||
if (url.Page() != null)
|
||||
segs.Add(url.Page());
|
||||
url.Page_(seg);
|
||||
@@ -296,13 +296,13 @@ public class Gfo_url_parser {
|
||||
}
|
||||
private void Anchor_set(byte[] src, int bgn, int end) {
|
||||
encoder.Decode(src, bgn, end, tmp_bfr, false);
|
||||
url.Anchor_(tmp_bfr.XtoAryAndClear());
|
||||
url.Anchor_(tmp_bfr.Xto_bry_and_clear());
|
||||
}
|
||||
private void Args_add(byte[] src, int key_bgn, int key_end, int val_bgn, int val_end) {
|
||||
encoder.Decode(src, key_bgn, key_end, tmp_bfr, false);
|
||||
byte[] key = tmp_bfr.XtoAryAndClear();
|
||||
byte[] key = tmp_bfr.Xto_bry_and_clear();
|
||||
encoder.Decode(src, val_bgn, val_end, tmp_bfr, false);
|
||||
byte[] val = tmp_bfr.XtoAryAndClear();
|
||||
byte[] val = tmp_bfr.Xto_bry_and_clear();
|
||||
Gfo_url_arg arg = new Gfo_url_arg(key, val);
|
||||
args.Add(arg);
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ class Gfo_url_parser_chkr implements Tst_chkr {
|
||||
rv += bry_ary_chkr.Chk(mgr, "segs", actl.Segs());
|
||||
rv += mgr.Tst_val(page == null, path, "page", page, String_.new_utf8_(actl.Page()));
|
||||
rv += mgr.Tst_val(anchor == null, path, "anchor", anchor, String_.new_utf8_(actl.Anchor()));
|
||||
mgr.Tst_sub_ary((Gfo_url_arg_chkr[])args.XtoAry(Gfo_url_arg_chkr.class), actl.Args(), "args", rv);
|
||||
mgr.Tst_sub_ary((Gfo_url_arg_chkr[])args.Xto_ary(Gfo_url_arg_chkr.class), actl.Args(), "args", rv);
|
||||
return rv;
|
||||
}
|
||||
public Gfo_url_parser_chkr Raw_(String v) {this.raw = v; return this;} private String raw;
|
||||
|
||||
@@ -43,11 +43,11 @@ public class Gfo_usr_dlg_base implements Gfo_usr_dlg {
|
||||
}
|
||||
String Bld_msg_many(String grp_key, String msg_key, String fmt, Object[] args) {
|
||||
tmp_fmtr.Fmt_(fmt).Bld_bfr_many(tmp_bfr, args);
|
||||
return tmp_bfr.XtoStrAndClear();
|
||||
return tmp_bfr.Xto_str_and_clear();
|
||||
} private Bry_fmtr tmp_fmtr = Bry_fmtr.tmp_(); Bry_bfr tmp_bfr = Bry_bfr.new_();
|
||||
String Bld_msg_one(String grp_key, String msg_key, String fmt, Object val) {
|
||||
tmp_fmtr.Fmt_(fmt).Bld_bfr_one(tmp_bfr, val);
|
||||
return tmp_bfr.XtoStrAndClear();
|
||||
return tmp_bfr.Xto_str_and_clear();
|
||||
}
|
||||
String Bld_msg_none(String grp_key, String msg_key, String fmt) {
|
||||
return fmt;
|
||||
|
||||
@@ -85,7 +85,7 @@ public class Tst_mgr {
|
||||
Object itm = Array_.FetchAt(ary, i);
|
||||
ary_sb.Add(Object_.Xto_str_strict_or_null_mark(itm)).Add(",");
|
||||
}
|
||||
return ary_sb.XtoStrAndClear();
|
||||
return ary_sb.Xto_str_and_clear();
|
||||
} String_bldr ary_sb = String_bldr_.new_();
|
||||
String Build() {
|
||||
String_bldr sb = String_bldr_.new_();
|
||||
@@ -103,7 +103,7 @@ public class Tst_mgr {
|
||||
if (!itm.Pass())
|
||||
sb.Add_fmt("\n{0} {1} {2} '{3}'", String_.PadEnd("", comp_max, " "), " " + String_.PadEnd("", path_max, " "), " " + String_.PadEnd("", name_max, " ") + " ", itm.Actl());
|
||||
}
|
||||
return sb.XtoStrAndClear();
|
||||
return sb.Xto_str_and_clear();
|
||||
}
|
||||
int Max(int max, String s) {int len = String_.Len(s); return len > max ? len : max;}
|
||||
public static final Tst_chkr Null_chkr = new Tst_chkr_null();
|
||||
|
||||
@@ -75,20 +75,20 @@ public class Url_encoder implements Url_encoder_interface {
|
||||
synchronized (thread_guard) {
|
||||
tmp_bfr.Add(Io_url.Http_file_bry);
|
||||
Encode(tmp_bfr, url.RawBry());
|
||||
return tmp_bfr.XtoAryAndClear();
|
||||
return tmp_bfr.Xto_bry_and_clear();
|
||||
}
|
||||
}
|
||||
public String Encode_str(String str) {
|
||||
synchronized (thread_guard) {
|
||||
byte[] bry = Bry_.new_utf8_(str); Encode(tmp_bfr, bry, 0, bry.length); return tmp_bfr.XtoStrAndClear();
|
||||
byte[] bry = Bry_.new_utf8_(str); Encode(tmp_bfr, bry, 0, bry.length); return tmp_bfr.Xto_str_and_clear();
|
||||
}
|
||||
}
|
||||
public byte[] Encode_bry(String str) {
|
||||
synchronized (thread_guard) {
|
||||
byte[] bry = Bry_.new_utf8_(str); Encode(tmp_bfr, bry, 0, bry.length); return tmp_bfr.XtoAryAndClear();
|
||||
byte[] bry = Bry_.new_utf8_(str); Encode(tmp_bfr, bry, 0, bry.length); return tmp_bfr.Xto_bry_and_clear();
|
||||
}
|
||||
}
|
||||
public byte[] Encode(byte[] bry) {Encode(tmp_bfr, bry, 0, bry.length); return tmp_bfr.XtoAryAndClear();}
|
||||
public byte[] Encode(byte[] bry) {Encode(tmp_bfr, bry, 0, bry.length); return tmp_bfr.Xto_bry_and_clear();}
|
||||
public Bry_bfr Encode(Bry_bfr bfr, byte[] bry) {Encode(bfr, bry, 0, bry.length); return bfr;}
|
||||
public void Encode(Bry_bfr bfr, byte[] bry, int bgn, int end) {
|
||||
synchronized (thread_guard) {
|
||||
@@ -106,17 +106,17 @@ public class Url_encoder implements Url_encoder_interface {
|
||||
}
|
||||
public String Decode_str(String str) {
|
||||
synchronized (thread_guard) {
|
||||
byte[] bry = Bry_.new_utf8_(str); Decode(bry, 0, bry.length, tmp_bfr, true); return tmp_bfr.XtoStrAndClear();
|
||||
byte[] bry = Bry_.new_utf8_(str); Decode(bry, 0, bry.length, tmp_bfr, true); return tmp_bfr.Xto_str_and_clear();
|
||||
}
|
||||
}
|
||||
public byte[] Decode(byte[] bry) {
|
||||
synchronized (thread_guard) {
|
||||
Decode(bry, 0, bry.length, tmp_bfr, false); return tmp_bfr.XtoAryAndClear();
|
||||
Decode(bry, 0, bry.length, tmp_bfr, false); return tmp_bfr.Xto_bry_and_clear();
|
||||
}
|
||||
}
|
||||
public byte[] Decode_lax(byte[] bry) {
|
||||
synchronized (thread_guard) {
|
||||
Decode(bry, 0, bry.length, tmp_bfr, false); return tmp_bfr.XtoAryAndClear();
|
||||
Decode(bry, 0, bry.length, tmp_bfr, false); return tmp_bfr.Xto_bry_and_clear();
|
||||
}
|
||||
}
|
||||
public void Decode(byte[] bry, int bgn, int end, Bry_bfr bfr, boolean fail_when_invalid) {
|
||||
|
||||
@@ -29,7 +29,7 @@ public class Url_encoder_tst {
|
||||
byte[] raw = Bry_.new_ascii_("0%.jpg");
|
||||
Bry_bfr tmp_bfr = Bry_bfr.new_();
|
||||
fxt.Encoder_id().Encoder().Decode(raw, 0, raw.length, tmp_bfr, false);
|
||||
Tfds.Eq("0%.jpg", tmp_bfr.XtoStrAndClear());
|
||||
Tfds.Eq("0%.jpg", tmp_bfr.Xto_str_and_clear());
|
||||
}
|
||||
@Test public void Id_nbsp() {fxt.Encoder_id().Test_encode("a b", "a.C2.A0b");} // NOTE: not just .A0 (160) but utf8-encoded .C2.A0
|
||||
@Test public void Url_syms() {fxt.Encoder_url().Test_encode_decode("!?^~", "%21%3F%5E%7E");}
|
||||
|
||||
Reference in New Issue
Block a user