mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.11.4.1
This commit is contained in:
@@ -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.core.brys; import gplx.*; import gplx.core.*;
|
||||
import gplx.lists.*;
|
||||
import gplx.core.lists.*;
|
||||
public class Bry_comparer implements ComparerAble {
|
||||
public int compare(Object lhsObj, Object rhsObj) {
|
||||
byte[] lhs = (byte[])lhsObj, rhs = (byte[])rhsObj;
|
||||
|
||||
@@ -16,6 +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.core.brys; import gplx.*; import gplx.core.*;
|
||||
import gplx.core.errs.*;
|
||||
public class Bry_rdr {
|
||||
private final gplx.core.primitives.Int_obj_ref pos_ref = gplx.core.primitives.Int_obj_ref.neg1_();
|
||||
private String ctx; private String wkr; private int err_bgn;
|
||||
@@ -144,10 +145,16 @@ public class Bry_rdr {
|
||||
pos = find_end;
|
||||
return pos;
|
||||
}
|
||||
public byte Chk(gplx.core.btries.Btrie_slim_mgr trie) {return Chk(trie, pos, src_end);}
|
||||
public byte Chk(gplx.core.btries.Btrie_slim_mgr trie) {return Chk(trie, pos, src_end);}
|
||||
public byte Chk_or(gplx.core.btries.Btrie_slim_mgr trie, byte or) {return Chk_or(trie, pos, src_end, or);}
|
||||
public byte Chk(gplx.core.btries.Btrie_slim_mgr trie, int itm_bgn, int itm_end) {
|
||||
byte rv = Chk_or(trie, itm_bgn, itm_end, Byte_.Max_value_127);
|
||||
if (rv == Byte_.Max_value_127) {Fail("failed trie check", "mid", String_.new_u8(Bry_.Mid_by_len_safe(src, pos, 16))); return Byte_.Max_value_127;}
|
||||
return rv;
|
||||
}
|
||||
public byte Chk_or(gplx.core.btries.Btrie_slim_mgr trie, int itm_bgn, int itm_end, byte or) {
|
||||
Object rv_obj = trie.Match_bgn(src, itm_bgn, itm_end);
|
||||
if (rv_obj == null) {Fail("failed trie check", "mid", String_.new_u8(Bry_.Mid_by_len_safe(src, pos, 16))); return Byte_.Max_value_127;}
|
||||
if (rv_obj == null) return or;
|
||||
pos = trie.Match_pos();
|
||||
return ((gplx.core.primitives.Byte_obj_val)rv_obj).Val();
|
||||
}
|
||||
@@ -162,9 +169,9 @@ public class Bry_rdr {
|
||||
public Err Err_make(String msg, String arg_key, Object arg_val, int excerpt_bgn, int excerpt_end) {return Err_.new_("Bry_rdr", Msg_make(msg, arg_key, arg_val, excerpt_bgn, excerpt_end));}
|
||||
private String Msg_make(String msg, String arg_key, Object arg_val, int excerpt_bgn, int excerpt_end) {
|
||||
if (String_.EqEmpty(arg_key))
|
||||
return String_.Replace(Err_msg.To_str(msg, "ctx", ctx, "wkr", wkr, "excerpt", Bry_.Mid_safe(src, excerpt_bgn, excerpt_end)), "\n", "\\n");
|
||||
return Err_msg.To_str(msg, "ctx", ctx, "wkr", wkr, "excerpt", Bry_.Escape_ws(Bry_.Mid_safe(src, excerpt_bgn, excerpt_end)));
|
||||
else
|
||||
return String_.Replace(Err_msg.To_str(msg, arg_key, arg_val, "ctx", ctx, "wkr", wkr, "excerpt", Quote(String_.new_u8(Bry_.Mid_safe(src, excerpt_bgn, excerpt_end)))), "\n", "\\n");
|
||||
return Err_msg.To_str(msg, arg_key, arg_val, "ctx", ctx, "wkr", wkr, "excerpt", Bry_.Escape_ws(Bry_.Mid_safe(src, excerpt_bgn, excerpt_end)));
|
||||
}
|
||||
private static String Quote(String v) {return "'" + v + "'";}
|
||||
}
|
||||
|
||||
@@ -58,6 +58,8 @@ class Int_flag_bldr__fxt {
|
||||
public void Test__to_int(int[] seg_ary, int[] val_ary, int expd) {
|
||||
int[] pow_ary = Int_flag_bldr_.Bld_pow_ary(seg_ary);
|
||||
Tfds.Eq(expd, Int_flag_bldr_.To_int(pow_ary, val_ary));
|
||||
int[] actl_val_ary = Int_flag_bldr_.To_int_ary(pow_ary, expd);
|
||||
Tfds.Eq_ary(val_ary, actl_val_ary);
|
||||
}
|
||||
public void Test__to_int_ary(int[] seg_ary, int val, int[] expd) {
|
||||
int[] pow_ary = Int_flag_bldr_.Bld_pow_ary(seg_ary);
|
||||
|
||||
@@ -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.core.caches; import gplx.*; import gplx.core.*;
|
||||
import org.junit.*;
|
||||
import org.junit.*; import gplx.core.envs.*;
|
||||
public class GfoCacheMgr_tst {
|
||||
@Before public void init() {fxt = new GfoCacheMgr_fxt();} GfoCacheMgr_fxt fxt;
|
||||
@Test public void teardown() {Env_.TickCount_Test = -1;}
|
||||
|
||||
@@ -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.core.caches; import gplx.*; import gplx.core.*;
|
||||
import gplx.core.consoles.*;
|
||||
import gplx.core.consoles.*; import gplx.core.envs.*;
|
||||
public class Gfo_cache_mgr {
|
||||
private Ordered_hash hash = Ordered_hash_.New_bry();
|
||||
private Ordered_hash recent = Ordered_hash_.New_bry();
|
||||
|
||||
@@ -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.core.caches; import gplx.*; import gplx.core.*;
|
||||
import gplx.core.primitives.*;
|
||||
import gplx.core.primitives.*; import gplx.core.envs.*;
|
||||
public class Gfo_cache_mgr_bry extends Gfo_cache_mgr_base {
|
||||
public Object Get_or_null(byte[] key) {return Base_get_or_null(key);}
|
||||
public void Add(byte[] key, Object val) {Base_add(key, val);}
|
||||
@@ -29,7 +29,7 @@ class Gfo_cache_itm {
|
||||
public long Touched() {return touched;} private long touched;
|
||||
public Gfo_cache_itm Touched_update() {touched = Env_.TickCount(); return this;}
|
||||
}
|
||||
class Gfo_cache_itm_comparer implements gplx.lists.ComparerAble {
|
||||
class Gfo_cache_itm_comparer implements gplx.core.lists.ComparerAble {
|
||||
public int compare(Object lhsObj, Object rhsObj) {
|
||||
Gfo_cache_itm lhs = (Gfo_cache_itm)lhsObj;
|
||||
Gfo_cache_itm rhs = (Gfo_cache_itm)rhsObj;
|
||||
|
||||
@@ -16,6 +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.core.consoles; import gplx.*; import gplx.core.*;
|
||||
import gplx.core.envs.*;
|
||||
public class Gfo_cmd_arg_itm_ {
|
||||
public static final int Tid_general = 0, Tid_system = 1;
|
||||
public static final int Val_tid_string = 0, Val_tid_yn = 1, Val_tid_url = 2, Val_tid_list_string = 3;
|
||||
|
||||
@@ -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.core.consoles; import gplx.*; import gplx.core.*;
|
||||
import org.junit.*; import gplx.core.tests.*;
|
||||
import org.junit.*; import gplx.core.tests.*; import gplx.core.envs.*;
|
||||
public class Gfo_cmd_arg_mgr_tst {
|
||||
@Before public void init() {fxt.Clear();} private final Gfo_cmd_arg_mgr_fxt fxt = new Gfo_cmd_arg_mgr_fxt();
|
||||
@Test public void Val__many() {
|
||||
|
||||
@@ -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.core.ios; import gplx.*; import gplx.core.*;
|
||||
import gplx.lists.*;
|
||||
import gplx.core.lists.*;
|
||||
class BinaryHeap_Io_line_rdr {
|
||||
public BinaryHeap_Io_line_rdr(ComparerAble comparer) {this.comparer = comparer;} ComparerAble comparer;
|
||||
Io_line_rdr[] ary = Ary_empty; int ary_len = 0, ary_max = 0;
|
||||
|
||||
@@ -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.core.ios; import gplx.*; import gplx.core.*;
|
||||
import org.junit.*;
|
||||
import org.junit.*; import gplx.core.envs.*;
|
||||
public class Io_line_rdr_tst {
|
||||
Io_line_rdr_fxt fxt;
|
||||
@Before public void init() {
|
||||
|
||||
@@ -16,7 +16,8 @@ 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.core.ios; import gplx.*; import gplx.core.*;
|
||||
import gplx.lists.*;
|
||||
import gplx.core.envs.*;
|
||||
import gplx.core.lists.*;
|
||||
public class Io_sort {
|
||||
public Io_sort Memory_max_(int v) {memory_max = v; return this;} private int memory_max = Io_mgr.Len_kb;
|
||||
public Io_url[] Split(Gfo_usr_dlg usr_dlg, Io_url_gen src_fil_gen, Io_url_gen trg_fil_gen, Io_line_rdr_key_gen key_gen) {return Split(usr_dlg, src_fil_gen, trg_fil_gen, Io_sort_split_itm_sorter.Instance, key_gen);}
|
||||
|
||||
@@ -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.core.ios; import gplx.*; import gplx.core.*;
|
||||
public class Io_sort_split_itm_sorter implements gplx.lists.ComparerAble {
|
||||
public class Io_sort_split_itm_sorter implements gplx.core.lists.ComparerAble {
|
||||
public int compare(Object lhsObj, Object rhsObj) {
|
||||
Io_sort_split_itm lhs = (Io_sort_split_itm)lhsObj, rhs = (Io_sort_split_itm)rhsObj;
|
||||
// Tfds.Write(String_.new_u8(lhs.Bfr(), lhs.Key_bgn(), lhs.Key_end()), String_.new_u8(rhs.Bfr(), rhs.Key_bgn(), rhs.Key_end()));
|
||||
|
||||
@@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.core.ios; import gplx.*; import gplx.core.*;
|
||||
import java.io.*;
|
||||
import java.util.zip.*;
|
||||
import gplx.core.envs.*;
|
||||
public class Io_zip_mgr_base implements Io_zip_mgr {
|
||||
public void Zip_fil(Io_url src_fil, Io_url trg_fil) {
|
||||
byte[] src_bry = Io_mgr.Instance.LoadFilBry(src_fil);
|
||||
|
||||
@@ -73,10 +73,10 @@ public class Gfo_qarg_mgr {
|
||||
public byte[] To_bry() {
|
||||
int len = list.Count(); if (len == 0) return Bry_.Empty;
|
||||
Bry_bfr bfr = Bry_bfr.new_();
|
||||
To_bry(bfr, gplx.xowa.Xoa_app_.Utl__encoder_mgr().Href(), false);
|
||||
To_bry(bfr, gplx.langs.htmls.encoders.Gfo_url_encoder_.Href, false);
|
||||
return bfr.To_bry_and_clear();
|
||||
}
|
||||
public void To_bry(Bry_bfr bfr, Url_encoder href_encoder, boolean encode) {
|
||||
public void To_bry(Bry_bfr bfr, Gfo_url_encoder href_encoder, boolean encode) {
|
||||
int len = list.Count(); if (len == 0) return;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Gfo_qarg_itm itm = (Gfo_qarg_itm)list.Get_at(i);
|
||||
@@ -86,8 +86,8 @@ public class Gfo_qarg_mgr {
|
||||
Write_or_encode(bfr, href_encoder, encode, itm.Val_bry());
|
||||
}
|
||||
}
|
||||
public static void Concat_bfr(Bry_bfr bfr, Url_encoder href_encoder, Gfo_qarg_itm[] ary) {Concat_bfr(bfr, href_encoder, ary, true);}
|
||||
private static void Concat_bfr(Bry_bfr bfr, Url_encoder href_encoder, Gfo_qarg_itm[] ary, boolean encode) {
|
||||
public static void Concat_bfr(Bry_bfr bfr, Gfo_url_encoder href_encoder, Gfo_qarg_itm[] ary) {Concat_bfr(bfr, href_encoder, ary, true);}
|
||||
private static void Concat_bfr(Bry_bfr bfr, Gfo_url_encoder href_encoder, Gfo_qarg_itm[] ary, boolean encode) {
|
||||
int ary_len = ary.length;
|
||||
for (int i = 0; i < ary_len; i++) {
|
||||
Gfo_qarg_itm itm = ary[i];
|
||||
@@ -97,7 +97,7 @@ public class Gfo_qarg_mgr {
|
||||
Write_or_encode(bfr, href_encoder, encode, itm.Val_bry());
|
||||
}
|
||||
}
|
||||
private static void Write_or_encode(Bry_bfr bfr, Url_encoder href_encoder, boolean encode, byte[] bry) {
|
||||
private static void Write_or_encode(Bry_bfr bfr, Gfo_url_encoder href_encoder, boolean encode, byte[] bry) {
|
||||
if (bry == null) return; // NOTE: need null check b/c itm.Val_bry can be null
|
||||
if (encode)
|
||||
href_encoder.Encode(bfr, bry);
|
||||
|
||||
@@ -16,11 +16,10 @@ 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.core.net; import gplx.*; import gplx.core.*;
|
||||
import gplx.core.primitives.*; import gplx.core.btries.*; import gplx.langs.htmls.encoders.*;
|
||||
import gplx.core.primitives.*; import gplx.core.btries.*;
|
||||
public class Gfo_url_parser {
|
||||
private final Btrie_slim_mgr protocols = Btrie_slim_mgr.ci_a7(); // ASCII:url_protocol; EX:"http:", "ftp:", etc
|
||||
private final Bry_ary segs_ary = new Bry_ary(4), qargs = new Bry_ary(4);
|
||||
private final Url_encoder encoder = Url_encoder.new_html_href_mw_().Itms_raw_same_many(Byte_ascii.Underline);
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr.reset_(500);
|
||||
public byte[] Relative_url_protocol_bry() {return Gfo_protocol_itm.Itm_https.Key_w_colon_bry();} // NOTE: https b/c any WMF wiki will now default to WMF; DATE:2015-07-26
|
||||
public Gfo_url_parser() {
|
||||
@@ -223,7 +222,7 @@ public class Gfo_url_parser {
|
||||
return pos + 1;
|
||||
}
|
||||
private byte[] Make_bry(int bgn, int end) {
|
||||
return encoded ? encoder.Decode(tmp_bfr, src, bgn, end) : Bry_.Mid(src, bgn, end);
|
||||
return encoded ? gplx.langs.htmls.encoders.Gfo_url_encoder_.Xourl.Decode(tmp_bfr, Bool_.N, src, bgn, end).To_bry_and_clear() : Bry_.Mid(src, bgn, end);
|
||||
}
|
||||
private Gfo_qarg_itm[] Make_qargs() {
|
||||
int qargs_len = qargs.Len(); if (qargs_len == 0) return Gfo_qarg_itm.Ary_empty;
|
||||
|
||||
@@ -16,12 +16,12 @@ 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.core.threads; import gplx.*; import gplx.core.*;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
import gplx.core.brys.fmtrs.*; import gplx.core.envs.*;
|
||||
import gplx.gfui.*; import gplx.xowa.bldrs.cmds.utils.*;
|
||||
public class Gfo_thread_cmd_unzip implements Gfo_thread_cmd {
|
||||
public Gfo_thread_cmd_unzip Init(Gfo_usr_dlg usr_dlg, Gfui_kit kit, ProcessAdp bzip2_process, ProcessAdp zip_process, ProcessAdp gz_process, Io_url src, Io_url trg) {
|
||||
public Gfo_thread_cmd_unzip Init(Gfo_usr_dlg usr_dlg, Gfui_kit kit, Process_adp bzip2_process, Process_adp zip_process, Process_adp gz_process, Io_url src, Io_url trg) {
|
||||
this.src = src; this.trg = trg; this.kit = kit; this.usr_dlg = usr_dlg;
|
||||
unzip_wkr = new Xob_unzip_wkr().Init(bzip2_process, zip_process, gz_process).Process_run_mode_(ProcessAdp.Run_mode_async);
|
||||
unzip_wkr = new Xob_unzip_wkr().Init(bzip2_process, zip_process, gz_process).Process_run_mode_(Process_adp.Run_mode_async);
|
||||
return this;
|
||||
} private Io_url src, trg; private Gfui_kit kit; private Gfo_usr_dlg usr_dlg; private Xob_unzip_wkr unzip_wkr;
|
||||
public GfoInvkAble Owner() {return owner;} public Gfo_thread_cmd_unzip Owner_(GfoInvkAble v) {owner = v; return this;} GfoInvkAble owner;
|
||||
@@ -55,7 +55,7 @@ public class Gfo_thread_cmd_unzip implements Gfo_thread_cmd {
|
||||
}
|
||||
return Gfo_thread_cmd_.Init_ok;
|
||||
}
|
||||
public boolean Async_running() {return unzip_wkr.Process_exit_code() == ProcessAdp.Exit_init;}
|
||||
public boolean Async_running() {return unzip_wkr.Process_exit_code() == Process_adp.Exit_init;}
|
||||
public void Async_run() {
|
||||
usr_dlg.Prog_many(GRP_KEY, "bgn", "unzipping");
|
||||
unzip_wkr.Decompress(src, trg);
|
||||
|
||||
Reference in New Issue
Block a user