mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
v2.11.4.1
This commit is contained in:
parent
8a5d58a973
commit
097e6c7f80
@ -2,13 +2,7 @@
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="src_100_interface"/>
|
||||
<classpathentry kind="src" path="src_101_types_object"/>
|
||||
<classpathentry kind="src" path="src_120_basicDataType"/>
|
||||
<classpathentry kind="src" path="src_130_brys"/>
|
||||
<classpathentry kind="src" path="src_140_list"/>
|
||||
<classpathentry kind="src" path="src_300_classXtn"/>
|
||||
<classpathentry kind="src" path="src_311_gfoObj"/>
|
||||
<classpathentry kind="src" path="src_330_store"/>
|
||||
<classpathentry kind="src" path="src_420_usrMsg"/>
|
||||
<classpathentry kind="src" path="tst"/>
|
||||
<classpathentry kind="src" path="xtn"/>
|
||||
|
@ -17,11 +17,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx;
|
||||
import java.lang.reflect.Array;
|
||||
import gplx.core.strings.*;
|
||||
import gplx.core.strings.*; import gplx.core.lists.*;
|
||||
public class Array_ {
|
||||
public static Object cast(Object o) {return (Object)o;}
|
||||
public static void Sort(Object[] obj) {List_adp_sorter.new_().Sort(obj, obj.length);}
|
||||
public static void Sort(Object[] obj, gplx.lists.ComparerAble comparer) {List_adp_sorter.new_().Sort(obj, obj.length, true, comparer);}
|
||||
public static void Sort(Object[] obj, gplx.core.lists.ComparerAble comparer) {List_adp_sorter.new_().Sort(obj, obj.length, true, comparer);}
|
||||
public static Object[] Insert(Object[] cur, Object[] add, int addPos) {
|
||||
int curLen = cur.length, addLen = add.length;
|
||||
Object[] rv = (Object[])Array_.Create(Array_.Component_type(cur), curLen + addLen);
|
@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx;
|
||||
import java.lang.*;
|
||||
import gplx.core.primitives.*; import gplx.core.ios.*;
|
||||
import gplx.core.brys.*; import gplx.core.primitives.*; import gplx.core.ios.*;
|
||||
public class Bry_ {
|
||||
public static final String Cls_val_name = "byte[]";
|
||||
public static final byte[] Empty = new byte[0];
|
||||
@ -944,4 +944,28 @@ public class Bry_ {
|
||||
return rv;
|
||||
}
|
||||
public static byte[] Null_if_empty(byte[] v) {return Len_eq_0(v) ? null : v;}
|
||||
|
||||
public static byte[] Escape_ws(byte[] bry) {Bry_bfr bfr = Bry_bfr_.Get(); byte[] rv = Escape_ws(bfr, bry); bfr.Mkr_rls(); return rv;}
|
||||
public static byte[] Escape_ws(Bry_bfr bfr, byte[] src) {
|
||||
boolean dirty = false;
|
||||
int len = src.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
byte b = src[i];
|
||||
byte escape = Byte_.Zero;
|
||||
switch (b) {
|
||||
case Byte_ascii.Tab: escape = Byte_ascii.Ltr_t; break;
|
||||
case Byte_ascii.Nl: escape = Byte_ascii.Ltr_n; break;
|
||||
case Byte_ascii.Cr: escape = Byte_ascii.Ltr_r; break;
|
||||
default: if (dirty) bfr.Add_byte(b); break;
|
||||
}
|
||||
if (escape != Byte_.Zero) {
|
||||
if (!dirty) {
|
||||
dirty = true;
|
||||
bfr.Add_mid(src, 0, i);
|
||||
}
|
||||
bfr.Add_byte_backslash().Add_byte(escape);
|
||||
}
|
||||
}
|
||||
return dirty ? bfr.To_bry_and_clear() : src;
|
||||
}
|
||||
}
|
@ -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;
|
||||
import org.junit.*; import gplx.core.primitives.*;
|
||||
import org.junit.*; import gplx.core.primitives.*; import gplx.core.brys.*;
|
||||
public class Bry__tst {
|
||||
private final Bry__fxt fxt = new Bry__fxt();
|
||||
@Test public void new_ascii_() {
|
@ -108,6 +108,7 @@ public class Bry_bfr {
|
||||
bfr_len += len;
|
||||
return this;
|
||||
}
|
||||
public Bry_bfr Add_bry_ref_obj(Bry_obj_ref v) {v.Bfr_arg__add(this); return this;}
|
||||
public Bry_bfr Add_bfr_and_preserve(Bry_bfr src) {
|
||||
int len = src.bfr_len;
|
||||
if (bfr_len + len > bfr_max) Resize((bfr_max + len) * 2);
|
||||
@ -564,10 +565,10 @@ public class Bry_bfr {
|
||||
bfr_max = v;
|
||||
bfr = Bry_.Resize(bfr, 0, v);
|
||||
}
|
||||
@gplx.Internal protected int Mkr_idx() {return mkr_idx;} private int mkr_idx = -1;
|
||||
@gplx.Internal protected boolean Mkr_idx_is_null() {return mkr_idx == -1;}
|
||||
@gplx.Internal protected int Bfr_max() {return bfr_max;} private int bfr_max;
|
||||
@gplx.Internal protected Bry_bfr Mkr_init(Bry_bfr_mkr_mgr mkr_mgr, int itm) {
|
||||
public int Mkr_idx() {return mkr_idx;} private int mkr_idx = -1;
|
||||
public boolean Mkr_idx_is_null() {return mkr_idx == -1;}
|
||||
public int Bfr_max() {return bfr_max;} private int bfr_max;
|
||||
public Bry_bfr Mkr_init(Bry_bfr_mkr_mgr mkr_mgr, int itm) {
|
||||
synchronized (this) {
|
||||
this.mkr_mgr = mkr_mgr; this.mkr_idx = itm;
|
||||
}
|
@ -16,8 +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 gplx.core.brys.*;
|
||||
public class Bry_bfr_ {
|
||||
public static Bry_bfr[] Ary_empty = new Bry_bfr[0];
|
||||
public static final Bry_bfr[] Ary_empty = new Bry_bfr[0];
|
||||
private static Bry_bfr_mkr_mgr dflt;
|
||||
public static Bry_bfr Get() {if (dflt == null) dflt = new Bry_bfr_mkr_mgr(Bry_bfr_mkr.Tid_b128, 128); return dflt.Get();} // NOTE: lazy else "Object synchronization" error; DATE:2015-11-18
|
||||
public static void Assert_at_end(Bry_bfr bfr, byte assert_byte) {
|
||||
int len = bfr.Len(); if (len == 0) return;
|
||||
int assert_count = 0;
|
@ -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;
|
||||
import gplx.core.errs.*;
|
||||
public class Err extends RuntimeException {
|
||||
private final boolean is_gplx;
|
||||
private final String trace;
|
||||
|
@ -52,6 +52,7 @@ public class Err_ {
|
||||
}
|
||||
|
||||
public static String Message_lang(Throwable e) {return e.getMessage();}
|
||||
public static String To_str(Exception e) {return e.toString();} // e.getMessage() is sometimes null?
|
||||
public static String Trace_lang(Throwable e) {return Trace_lang_exec(e.getStackTrace());}
|
||||
private static String Trace_lang_exec(StackTraceElement[] ary) {
|
||||
String rv = "";
|
||||
|
@ -16,12 +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;
|
||||
public interface Hash_adp extends gplx.lists.EnumerAble {
|
||||
public interface Hash_adp extends gplx.core.lists.EnumerAble {
|
||||
int Count();
|
||||
boolean Has(Object key);
|
||||
Object Get_by(Object key);
|
||||
Object Get_by_or_fail(Object key);
|
||||
Object Get_by_or_new(Object key, NewAble prototype);
|
||||
void Add(Object key, Object val);
|
||||
void Add_as_key_and_val(Object val);
|
||||
boolean Add_if_dupe_use_1st(Object key, Object val);
|
@ -21,18 +21,17 @@ public class Hash_adp_ {
|
||||
public static Hash_adp new_() {return new Hash_adp_obj();}
|
||||
public static final Hash_adp Noop = new Hash_adp_noop();
|
||||
}
|
||||
class Hash_adp_obj extends gplx.lists.Hash_adp_base implements Hash_adp {}//_20110428
|
||||
class Hash_adp_obj extends gplx.core.lists.Hash_adp_base implements Hash_adp {}//_20110428
|
||||
class Hash_adp_noop implements Hash_adp {
|
||||
public int Count() {return 0;}
|
||||
public boolean Has(Object key) {return false;}
|
||||
public Object Get_by(Object key) {return null;}
|
||||
public Object Get_by_or_fail(Object key) {throw Err_.new_missing_key(Object_.Xto_str_strict_or_null_mark(key));}
|
||||
public Object Get_by_or_new(Object key, NewAble proto) {throw Err_.new_wo_type("could not add to null hash");}
|
||||
public void Add(Object key, Object val) {}
|
||||
public void Add_as_key_and_val(Object val) {}
|
||||
public void Add_if_dupe_use_nth(Object key, Object val) {}
|
||||
public boolean Add_if_dupe_use_1st(Object key, Object val) {return false;}
|
||||
public void Del(Object key) {}
|
||||
public void Clear() {}
|
||||
public java.util.Iterator iterator() {return gplx.lists.Iterator_null.Instance;}
|
||||
public java.util.Iterator iterator() {return gplx.core.lists.Iterator_null.Instance;}
|
||||
}
|
@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx;
|
||||
import gplx.core.primitives.*;
|
||||
import gplx.core.intls.*;
|
||||
public class Hash_adp_bry extends gplx.lists.Hash_adp_base implements Hash_adp {
|
||||
public class Hash_adp_bry extends gplx.core.lists.Hash_adp_base implements Hash_adp {
|
||||
private final Hash_adp_bry_itm_base proto, key_ref;
|
||||
Hash_adp_bry(Hash_adp_bry_itm_base proto) {
|
||||
this.proto = proto;
|
@ -16,8 +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;
|
||||
import gplx.core.strings.*; import gplx.core.ios.*; /*IoUrlInfo*/
|
||||
public class Io_url implements CompareAble, EqAble, ParseAble, GfoInvkAble { //_20101005 URL:doc/Io_url.txt
|
||||
import gplx.core.strings.*; import gplx.core.ios.*; /*IoUrlInfo*/ import gplx.core.envs.*;
|
||||
public class Io_url implements CompareAble, ParseAble, GfoInvkAble { //_20101005 URL:doc/Io_url.txt
|
||||
public IoUrlInfo Info() {return info;} IoUrlInfo info;
|
||||
public String Raw() {return raw;} final String raw;
|
||||
public byte[] RawBry() {return Bry_.new_u8(raw);}
|
@ -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;
|
||||
import gplx.core.ios.*; /*IoUrlInfo_*/
|
||||
import gplx.core.ios.*; /*IoUrlInfo_*/ import gplx.core.stores.*; import gplx.core.envs.*;
|
||||
public class Io_url_ {
|
||||
public static final Io_url Empty = new Io_url("", IoUrlInfo_.Nil);
|
||||
public static final Io_url NullPtr = null;
|
@ -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;
|
||||
import gplx.lists.*; /*EnumerAble,ComparerAble*/
|
||||
import gplx.core.lists.*; /*EnumerAble,ComparerAble*/
|
||||
public interface List_adp extends EnumerAble {
|
||||
int Count();
|
||||
Object Get_at(int i);
|
@ -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;
|
||||
import gplx.lists.*; /*EnumerAble,ComparerAble*/
|
||||
import gplx.core.lists.*; /*EnumerAble,ComparerAble*/
|
||||
public class List_adp_ {
|
||||
public static final List_adp Noop = new List_adp_noop();
|
||||
public static List_adp as_(Object obj) {return obj instanceof List_adp ? (List_adp)obj : null;}
|
@ -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;
|
||||
import gplx.core.strings.*; import gplx.lists.*;
|
||||
import gplx.core.strings.*; import gplx.core.lists.*;
|
||||
public abstract class List_adp_base implements List_adp, GfoInvkAble {
|
||||
private Object[] list; private int count;
|
||||
public List_adp_base(int capacity) {
|
@ -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;
|
||||
import gplx.lists.*; /*EnumerAble,ComparerAble*/
|
||||
import gplx.core.lists.*; /*EnumerAble,ComparerAble*/
|
||||
public interface Ordered_hash extends Hash_adp {
|
||||
Object Get_at(int i);
|
||||
void Add_at(int i, Object o);
|
@ -16,8 +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;
|
||||
import gplx.core.strings.*;
|
||||
import gplx.lists.*; /*EnumerAble,ComparerAble*/
|
||||
import gplx.core.strings.*; import gplx.core.envs.*;
|
||||
import gplx.core.lists.*; /*EnumerAble,ComparerAble*/
|
||||
public class Ordered_hash_base extends Hash_adp_base implements Ordered_hash, GfoInvkAble {
|
||||
@Override protected void Add_base(Object key, Object val) {
|
||||
super.Add_base(key, val);
|
||||
@ -59,7 +59,7 @@ public class Ordered_hash_base extends Hash_adp_base implements Ordered_hash, Gf
|
||||
public void Resize_bounds(int i) {if (locked) Lock_fail(); ordered.Resize_bounds(i);}
|
||||
public void Lock() {locked = true;} private boolean locked = false;
|
||||
void Lock_fail() {throw Err_.new_wo_type("collection is locked");}
|
||||
static final String GRP_KEY = "gplx.lists.ordered_hash";
|
||||
static final String GRP_KEY = "gplx.core.lists.ordered_hash";
|
||||
public void Add_at(int i, Object o) {if (locked) Lock_fail(); ordered.Add_at(i, o);}
|
||||
public Object Get_at(int i) {return Get_at_base(i);}
|
||||
public int Idx_of(Object obj) {return this.IndexOf_base(obj);}
|
@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx;
|
||||
import java.lang.*;
|
||||
import gplx.core.strings.*; import gplx.langs.gfs.*;
|
||||
import gplx.core.strings.*; import gplx.langs.gfs.*; import gplx.core.envs.*;
|
||||
public class String_ implements GfoInvkAble {
|
||||
public static final Class<?> Cls_ref_type = String.class;
|
||||
public static final String Cls_val_name = "str" + "ing";
|
@ -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;
|
||||
import gplx.core.strings.*; import gplx.core.consoles.*;
|
||||
import gplx.core.strings.*; import gplx.core.consoles.*; import gplx.core.tests.*;
|
||||
public class Tfds { // URL:doc/gplx.tfds/Tfds.txt
|
||||
public static boolean SkipDb = false;
|
||||
public static void Eq_bool (boolean expd , boolean actl) {Eq_exec_y(expd, actl, "", Object_.Ary_empty);}
|
||||
@ -31,8 +31,6 @@ public class Tfds { // URL:doc/gplx.tfds/Tfds.txt
|
||||
public static void Eq_str (String expd, String actl, String fmt, Object... args) {Eq_exec_y(expd, actl, fmt, args);}
|
||||
|
||||
public static void Eq(Object expd, Object actl) {Eq_wkr(expd, actl, true, EmptyStr);}
|
||||
public static void Eq_able(EqAble expd, EqAble actl) {Eq_able_wkr(expd, actl, true, EmptyStr);}
|
||||
public static void Eq_able(EqAble expd, EqAble actl, String fmt, Object... args) {Eq_able_wkr(expd, actl, true, String_.Format(fmt, args));}
|
||||
public static void Eq_byte(byte expd, byte actl) {Eq_wkr(expd, actl, true, EmptyStr);}
|
||||
public static void Eq_long(long expd, long actl) {Eq_wkr(expd, actl, true, EmptyStr);}
|
||||
public static void Eq_float(float expd, float actl) {Eq_wkr(expd, actl, true, EmptyStr);}
|
||||
@ -75,15 +73,6 @@ public class Tfds { // URL:doc/gplx.tfds/Tfds.txt
|
||||
String msg = msgBldr.Eq_xtoStr(lhs, rhs, String_.Format(fmt, args));
|
||||
throw Err_.new_wo_type(msg);
|
||||
}
|
||||
static void Eq_able_wkr(EqAble lhs, EqAble rhs, boolean expd, String customMsg) {
|
||||
boolean actl = false;
|
||||
if (lhs == null && rhs != null) actl = false;
|
||||
else if (lhs != null && rhs == null) actl = false;
|
||||
else actl = lhs.Eq(rhs);
|
||||
if (expd == actl) return;
|
||||
String msg = msgBldr.Eq_xtoStr(lhs, rhs, customMsg);
|
||||
throw Err_.new_wo_type(msg);
|
||||
}
|
||||
static void Eq_wkr(Object lhs, Object rhs, boolean expd, String customMsg) {
|
||||
boolean actl = Object_.Eq(lhs, rhs);
|
||||
if (expd == actl) return;
|
||||
@ -168,6 +157,7 @@ public class Tfds { // URL:doc/gplx.tfds/Tfds.txt
|
||||
public static void WriteText(String text) {Console_adp__sys.Instance.Write_str(text);}
|
||||
public static void Write(byte[] s, int b, int e) {Write(Bry_.Mid(s, b, e));}
|
||||
public static void Write() {Write("tmp");}
|
||||
public static void Dbg(Object... ary) {Write(ary);}
|
||||
public static void Write(Object... ary) {
|
||||
String_bldr sb = String_bldr_.new_();
|
||||
int aryLen = Array_.Len(ary);
|
||||
|
@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx;
|
||||
import gplx.core.strings.*;
|
||||
public class TimeSpanAdp implements CompareAble, EqAble {
|
||||
public class TimeSpanAdp implements CompareAble {
|
||||
public long Fracs() {return fracs;} long fracs; public int FracsAsInt() {return (int)fracs;}
|
||||
public Decimal_adp TotalSecs() {
|
||||
return Decimal_adp_.divide_(fracs, TimeSpanAdp_.Divisors[TimeSpanAdp_.Idx_Sec]);
|
@ -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;
|
||||
import gplx.core.strings.*;
|
||||
import gplx.core.strings.*; import gplx.core.envs.*;
|
||||
public class TimeSpanAdp_ {
|
||||
public static final TimeSpanAdp Zero = new TimeSpanAdp(0);
|
||||
public static final TimeSpanAdp Null = new TimeSpanAdp(-1);
|
@ -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;
|
||||
import gplx.core.stores.*;
|
||||
public class Yn {
|
||||
public static final String Y = "y", N = "n";
|
||||
public static boolean parse_by_char_or(String v, boolean or) {
|
||||
|
44
100_core/src/gplx/core/brys/Bry_bfr_mkr.java
Normal file
44
100_core/src/gplx/core/brys/Bry_bfr_mkr.java
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.*;
|
||||
public class Bry_bfr_mkr {
|
||||
private final Bry_bfr_mkr_mgr mkr_b128 = new Bry_bfr_mkr_mgr(Tid_b128, 128);
|
||||
public Bry_bfr Get_b128() {return mkr_b128.Get();}
|
||||
public Bry_bfr Get_b512() {return mkr_b512.Get();} private final Bry_bfr_mkr_mgr mkr_b512 = new Bry_bfr_mkr_mgr(Tid_b512, 512);
|
||||
public Bry_bfr Get_k004() {return mkr_k004.Get();} private final Bry_bfr_mkr_mgr mkr_k004 = new Bry_bfr_mkr_mgr(Tid_k004, 4 * Io_mgr.Len_kb);
|
||||
public Bry_bfr Get_m001() {return mkr_m001.Get();} private final Bry_bfr_mkr_mgr mkr_m001 = new Bry_bfr_mkr_mgr(Tid_m001, 1 * Io_mgr.Len_mb);
|
||||
public void Rls(Bry_bfr v) {v.Mkr_rls();}
|
||||
public void Clear() {
|
||||
for (byte i = Tid_b128; i <= Tid_m001; i++)
|
||||
mkr(i).Clear();
|
||||
}
|
||||
public void Clear_fail_check() {
|
||||
for (byte i = Tid_b128; i <= Tid_m001; i++)
|
||||
mkr(i).Clear_fail_check();
|
||||
}
|
||||
private Bry_bfr_mkr_mgr mkr(byte tid) {
|
||||
switch (tid) {
|
||||
case Tid_b128: return mkr_b128;
|
||||
case Tid_b512: return mkr_b512;
|
||||
case Tid_k004: return mkr_k004;
|
||||
case Tid_m001: return mkr_m001;
|
||||
default: throw Err_.new_unhandled(tid);
|
||||
}
|
||||
}
|
||||
public static final byte Tid_b128 = 0, Tid_b512 = 1, Tid_k004 = 2, Tid_m001 = 3;
|
||||
}
|
100
100_core/src/gplx/core/brys/Bry_bfr_mkr_mgr.java
Normal file
100
100_core/src/gplx/core/brys/Bry_bfr_mkr_mgr.java
Normal file
@ -0,0 +1,100 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.*;
|
||||
public class Bry_bfr_mkr_mgr {
|
||||
private final Object thread_lock = new Object();
|
||||
private Bry_bfr[] used = Bry_bfr_.Ary_empty; private int used_len = 0, used_max = 0;
|
||||
private int[] free; private int free_len; private int reset;
|
||||
public Bry_bfr_mkr_mgr(byte mgr_id, int reset) {// NOTE: random IndexOutOfBounds errors in Get around free[--free_len] with free_len being -1; put member variable initialization within thread_lock to try to avoid; DATE:2014-09-21
|
||||
this.mgr_id = mgr_id;
|
||||
this.reset = reset;
|
||||
this.free = Int_.Ary_empty;
|
||||
this.free_len = 0;
|
||||
}
|
||||
public byte Mgr_id() {return mgr_id;} private byte mgr_id;
|
||||
public Bry_bfr Get() {
|
||||
synchronized (thread_lock) {
|
||||
Bry_bfr rv = null; int rv_idx = -1;
|
||||
if (free_len > 0) {
|
||||
try {rv_idx = free[--free_len];} catch (Exception e) {throw Err_.new_exc(e, "core", "failed to get free", "idx", free_len, "free_len", free.length);}
|
||||
try {rv = used[rv_idx];} catch (Exception e) {throw Err_.new_exc(e, "core", "failed to get used", "idx", rv_idx, "used_len", used.length);}
|
||||
}
|
||||
else {
|
||||
if (used_len == used_max) Expand();
|
||||
rv_idx = used_len++;
|
||||
rv = used[rv_idx];
|
||||
if (rv == null) {
|
||||
rv = Bry_bfr.reset_(reset);
|
||||
used[rv_idx] = rv;
|
||||
}
|
||||
}
|
||||
rv.Mkr_init(this, rv_idx);
|
||||
return rv.Clear(); // NOTE: ALWAYS call Clear when doing Get. caller may forget to call Clear, and reused bfr may have leftover bytes. unit tests will not catch, and difficult to spot in app
|
||||
}
|
||||
}
|
||||
public void Rls(int idx) {
|
||||
synchronized (thread_lock) {
|
||||
if (idx == -1) throw Err_.new_wo_type("rls called on bfr that was not created by factory");
|
||||
int new_used_len = used_len - 1;
|
||||
if (idx == new_used_len)
|
||||
used_len = new_used_len;
|
||||
else
|
||||
free[free_len++] = idx;
|
||||
}
|
||||
}
|
||||
public void Clear_fail_check() {
|
||||
synchronized (thread_lock) {
|
||||
for (int i = 0; i < used_max; i++) {
|
||||
Bry_bfr itm = used[i];
|
||||
if (itm != null) {
|
||||
if (!itm.Mkr_idx_is_null()) throw Err_.new_wo_type("failed to clear bfr", "idx", Int_.To_str(i));
|
||||
itm.Clear();
|
||||
}
|
||||
used[i] = null;
|
||||
}
|
||||
used = Bry_bfr_.Ary_empty;
|
||||
free = Int_.Ary_empty;
|
||||
free_len = used_len = used_max = 0;
|
||||
}
|
||||
}
|
||||
public void Clear() {
|
||||
synchronized (thread_lock) {
|
||||
for (int i = 0; i < used_max; i++) {
|
||||
Bry_bfr itm = used[i];
|
||||
if (itm != null) itm.Clear();
|
||||
used[i] = null;
|
||||
}
|
||||
used = Bry_bfr_.Ary_empty;
|
||||
free = Int_.Ary_empty;
|
||||
free_len = 0;
|
||||
used_len = used_max = 0;
|
||||
}
|
||||
}
|
||||
@gplx.Internal protected Bry_bfr[] Used() {return used;}
|
||||
@gplx.Internal protected int Used_len() {return used_len;}
|
||||
private void Expand() {
|
||||
int new_max = used_max == 0 ? 2 : used_max * 2;
|
||||
Bry_bfr[] new_ary = new Bry_bfr[new_max];
|
||||
Array_.Copy_to(used, 0, new_ary, 0, used_max);
|
||||
used = new_ary;
|
||||
used_max = new_max;
|
||||
int[] new_free = new int[used_max];
|
||||
Array_.Copy_to(free, 0, new_free, 0, free_len);
|
||||
free = new_free;
|
||||
}
|
||||
}
|
57
100_core/src/gplx/core/brys/Bry_bfr_mkr_tst.java
Normal file
57
100_core/src/gplx/core/brys/Bry_bfr_mkr_tst.java
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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 org.junit.*;
|
||||
public class Bry_bfr_mkr_tst {
|
||||
private final Bry_bfr_mkr_fxt fxt = new Bry_bfr_mkr_fxt();
|
||||
@Before public void setup() {fxt.Clear();}
|
||||
@Test public void Get_1() {fxt.Clear().Get().Test__used(0);}
|
||||
@Test public void Get_2() {fxt.Clear().Get().Get().Test__used(0, 1);}
|
||||
@Test public void Get_3() {fxt.Clear().Get().Get().Get().Test__used(0, 1, 2);}
|
||||
@Test public void Rls() {fxt.Clear().Get().Rls(0).Test__used();}
|
||||
@Test public void Rls_skip_1() {
|
||||
fxt.Clear().Get().Get().Rls(0).Test__used(-1, 1);
|
||||
fxt.Get().Test__used(0, 1);
|
||||
}
|
||||
@Test public void Rls_skip_2_1() {
|
||||
fxt.Clear().Get().Get().Get().Rls(1).Rls(0).Test__used(-1, -1, 2);
|
||||
fxt.Get().Test__used(0, -1, 2);
|
||||
fxt.Get().Test__used(0, 1, 2);
|
||||
fxt.Get().Test__used(0, 1, 2, 3);
|
||||
}
|
||||
@Test public void Get_rls_get() { // PURPOSE: defect in which last rls failed b/c was not doing ++ if rv existed
|
||||
fxt.Clear().Get().Rls(0).Get().Get().Rls(1).Rls(0).Test__used();
|
||||
}
|
||||
}
|
||||
class Bry_bfr_mkr_fxt {
|
||||
private final Bry_bfr_mkr_mgr mkr = new Bry_bfr_mkr_mgr(Byte_.Zero, 32);
|
||||
public Bry_bfr_mkr_fxt Clear() {mkr.Clear(); return this;}
|
||||
public Bry_bfr_mkr_fxt Get() {mkr.Get(); return this;}
|
||||
public Bry_bfr_mkr_fxt Rls(int i) {mkr.Used()[i].Mkr_rls(); return this;}
|
||||
public Bry_bfr_mkr_fxt Test__used(int... expd) {
|
||||
int actl_len = mkr.Used_len();
|
||||
int[] actl = new int[actl_len];
|
||||
for (int i = 0; i < actl_len; i++) {
|
||||
Bry_bfr bfr = mkr.Used()[i];
|
||||
int actl_val = bfr == null ? -2 : bfr.Mkr_idx();
|
||||
actl[i] = actl_val;
|
||||
}
|
||||
Tfds.Eq_ary(expd, actl);
|
||||
return this;
|
||||
}
|
||||
}
|
@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
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;
|
||||
package gplx.core.brys; import gplx.*; import gplx.core.*;
|
||||
public class Bry_rdr_old {
|
||||
private byte[] scope = Bry_.Empty;
|
||||
public byte[] Src() {return src;} protected byte[] src;
|
@ -17,7 +17,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.core.brys.args; import gplx.*; import gplx.core.*; import gplx.core.brys.*;
|
||||
public class Bfr_arg__bry extends gplx.core.brys.Bfr_arg_base {
|
||||
private final byte[] bry;
|
||||
private byte[] bry;
|
||||
public Bfr_arg__bry(byte[] v) {this.bry = v;}
|
||||
public void Set(byte[] v) {this.bry = v;}
|
||||
@Override public void Bfr_arg__add(Bry_bfr bfr) {bfr.Add(bry);}
|
||||
}
|
||||
|
@ -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 Console_adp__sys implements Console_adp {
|
||||
private String tmp_txt;
|
||||
public Console_adp__sys() {
|
||||
|
@ -15,20 +15,20 @@ GNU Affero General Public License for more details.
|
||||
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;
|
||||
package gplx.core.envs; import gplx.*; import gplx.core.*;
|
||||
import gplx.core.threads.*;
|
||||
public class Env_ {
|
||||
public static void Init(String[] args, String appNameAndExt, Class<?> type) {
|
||||
mode_testing = false;
|
||||
mode_debug = String_.In("GPLX_DEBUG_MODE_ENABLED", args);
|
||||
appArgs = args;
|
||||
appUrl = JarAdp_.Url_type(type).OwnerDir().GenSubFil(appNameAndExt);
|
||||
appUrl = Jar_adp_.Url_type(type).OwnerDir().GenSubFil(appNameAndExt);
|
||||
}
|
||||
public static void Init_swt(String[] args, Class<?> type) { // DATE:2014-06-23
|
||||
mode_testing = false;
|
||||
mode_debug = String_.In("GPLX_DEBUG_MODE_ENABLED", args);
|
||||
appArgs = args;
|
||||
appUrl = JarAdp_.Url_type(type);
|
||||
appUrl = Jar_adp_.Url_type(type);
|
||||
}
|
||||
public static void Init_drd() {
|
||||
mode_testing = mode_debug = false;
|
@ -15,8 +15,8 @@ GNU Affero General Public License for more details.
|
||||
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 JarAdp_ {
|
||||
package gplx.core.envs; import gplx.*; import gplx.core.*;
|
||||
public class Jar_adp_ {
|
||||
public static DateAdp ModifiedTime_type(Class<?> type) {if (type == null) throw Err_.new_null();
|
||||
Io_url url = Url_type(type);
|
||||
return Io_mgr.Instance.QueryFil(url).ModifiedTime();
|
@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
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;
|
||||
package gplx.core.envs; import gplx.*; import gplx.core.*;
|
||||
public class Op_sys {
|
||||
Op_sys(byte tid, byte sub_tid, String os_name, byte bitness, String nl_str, byte fsys_dir_spr_byte, boolean fsys_case_match) {
|
||||
this.tid = tid; this.sub_tid = sub_tid; this.os_name = os_name; this.bitness = bitness; this.nl_str = nl_str; this.fsys_dir_spr_byte = fsys_dir_spr_byte; this.fsys_dir_spr_str = Char_.To_str((char)fsys_dir_spr_byte); this.fsys_case_match = fsys_case_match;
|
@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
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;
|
||||
package gplx.core.envs; import gplx.*; import gplx.core.*;
|
||||
public class Op_sys_ {
|
||||
public static boolean Wnt_invalid_char(byte b) {
|
||||
switch (b) {
|
@ -15,7 +15,26 @@ GNU Affero General Public License for more details.
|
||||
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;
|
||||
package gplx.core.envs; import gplx.*; import gplx.core.*;
|
||||
import gplx.Bool_;
|
||||
import gplx.Bry_;
|
||||
import gplx.Bry_bfr;
|
||||
import gplx.Err_;
|
||||
import gplx.GfoInvkAble;
|
||||
import gplx.GfoInvkAbleCmd;
|
||||
import gplx.GfoInvkAble_;
|
||||
import gplx.GfoMsg;
|
||||
import gplx.Gfo_usr_dlg;
|
||||
import gplx.Gfo_usr_dlg_;
|
||||
import gplx.GfsCtx;
|
||||
import gplx.Io_url;
|
||||
import gplx.Io_url_;
|
||||
import gplx.List_adp;
|
||||
import gplx.List_adp_;
|
||||
import gplx.RlsAble;
|
||||
import gplx.String_;
|
||||
import gplx.Tfds;
|
||||
import gplx.Virtual;
|
||||
import gplx.core.threads.*;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
@ -24,40 +43,40 @@ import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
import javax.management.RuntimeErrorException;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
import gplx.core.strings.*; import gplx.langs.gfs.*;
|
||||
public class ProcessAdp implements GfoInvkAble, RlsAble {
|
||||
public boolean Enabled() {return enabled;} public ProcessAdp Enabled_(boolean v) {enabled = v; return this;} private boolean enabled = true;
|
||||
public byte Exe_exists() {return exe_exists;} public ProcessAdp Exe_exists_(byte v) {exe_exists = v; return this;} private byte exe_exists = Bool_.__byte;
|
||||
public Io_url Exe_url() {return exe_url;} public ProcessAdp Exe_url_(Io_url val) {exe_url = val; exe_exists = Bool_.__byte; return this;} Io_url exe_url;
|
||||
public String Args_str() {return args_str;} public ProcessAdp Args_str_(String val) {args_str = val; return this;} private String args_str = "";
|
||||
import gplx.core.brys.fmtrs.*; import gplx.core.strings.*;
|
||||
import gplx.langs.gfs.*;
|
||||
public class Process_adp implements GfoInvkAble, RlsAble {
|
||||
public boolean Enabled() {return enabled;} public Process_adp Enabled_(boolean v) {enabled = v; return this;} private boolean enabled = true;
|
||||
public byte Exe_exists() {return exe_exists;} public Process_adp Exe_exists_(byte v) {exe_exists = v; return this;} private byte exe_exists = Bool_.__byte;
|
||||
public Io_url Exe_url() {return exe_url;} public Process_adp Exe_url_(Io_url val) {exe_url = val; exe_exists = Bool_.__byte; return this;} Io_url exe_url;
|
||||
public String Args_str() {return args_str;} public Process_adp Args_str_(String val) {args_str = val; return this;} private String args_str = "";
|
||||
public Bry_fmtr Args_fmtr() {return args_fmtr;} Bry_fmtr args_fmtr = Bry_fmtr.new_("");
|
||||
public byte Run_mode() {return run_mode;} public ProcessAdp Run_mode_(byte v) {run_mode = v; return this;} private byte run_mode = Run_mode_sync_block;
|
||||
public byte Run_mode() {return run_mode;} public Process_adp Run_mode_(byte v) {run_mode = v; return this;} private byte run_mode = Run_mode_sync_block;
|
||||
public static final byte Run_mode_async = 0, Run_mode_sync_block = 1, Run_mode_sync_timeout = 2;
|
||||
public int Exit_code() {return exit_code;} int exit_code;
|
||||
public boolean Exit_code_pass() {return exit_code == Exit_pass;}
|
||||
public String Rslt_out() {return rslt_out;} private String rslt_out;
|
||||
public Io_url Working_dir() {return working_dir;} public ProcessAdp Working_dir_(Io_url v) {working_dir = v; return this;} Io_url working_dir;
|
||||
public ProcessAdp Cmd_args(String cmd, String args) {this.Exe_url_(Io_url_.new_fil_(cmd)); this.args_fmtr.Fmt_(args); return this;}
|
||||
public ProcessAdp WhenBgn_add(GfoInvkAbleCmd cmd) {whenBgnList.Add(cmd); return this;}
|
||||
public ProcessAdp WhenBgn_del(GfoInvkAbleCmd cmd) {whenBgnList.Del(cmd); return this;}
|
||||
public int Thread_timeout() {return thread_timeout;} public ProcessAdp Thread_timeout_seconds_(int v) {thread_timeout = v * 1000; return this;} int thread_timeout = 0;
|
||||
public int Thread_interval() {return thread_interval;} public ProcessAdp Thread_interval_(int v) {thread_interval = v; return this;} int thread_interval = 20;
|
||||
public String Thread_kill_name() {return thread_kill_name;} public ProcessAdp Thread_kill_name_(String v) {thread_kill_name = v; return this;} private String thread_kill_name = "";
|
||||
public Io_url Tmp_dir() {return tmp_dir;} @gplx.Virtual public ProcessAdp Tmp_dir_(Io_url v) {tmp_dir = v; return this;} Io_url tmp_dir;
|
||||
private ProcessAdp WhenBgn_run() {return Invk_cmds(whenBgnList);} List_adp whenBgnList = List_adp_.new_();
|
||||
public ProcessAdp WhenEnd_add(GfoInvkAbleCmd cmd) {whenEndList.Add(cmd); return this;}
|
||||
public ProcessAdp WhenEnd_del(GfoInvkAbleCmd cmd) {whenEndList.Del(cmd); return this;}
|
||||
public Gfo_usr_dlg Prog_dlg() {return prog_dlg;} public ProcessAdp Prog_dlg_(Gfo_usr_dlg v) {prog_dlg = v; return this;} Gfo_usr_dlg prog_dlg;
|
||||
public String Prog_fmt() {return prog_fmt;} public ProcessAdp Prog_fmt_(String v) {prog_fmt = v; return this;} private String prog_fmt = ""; // NOTE: set to "", else cmds that do not set prog_fmt will fail on fmtr.Fmt(null)
|
||||
public Io_url Working_dir() {return working_dir;} public Process_adp Working_dir_(Io_url v) {working_dir = v; return this;} Io_url working_dir;
|
||||
public Process_adp Cmd_args(String cmd, String args) {this.Exe_url_(Io_url_.new_fil_(cmd)); this.args_fmtr.Fmt_(args); return this;}
|
||||
public Process_adp WhenBgn_add(GfoInvkAbleCmd cmd) {whenBgnList.Add(cmd); return this;}
|
||||
public Process_adp WhenBgn_del(GfoInvkAbleCmd cmd) {whenBgnList.Del(cmd); return this;}
|
||||
public int Thread_timeout() {return thread_timeout;} public Process_adp Thread_timeout_seconds_(int v) {thread_timeout = v * 1000; return this;} int thread_timeout = 0;
|
||||
public int Thread_interval() {return thread_interval;} public Process_adp Thread_interval_(int v) {thread_interval = v; return this;} int thread_interval = 20;
|
||||
public String Thread_kill_name() {return thread_kill_name;} public Process_adp Thread_kill_name_(String v) {thread_kill_name = v; return this;} private String thread_kill_name = "";
|
||||
public Io_url Tmp_dir() {return tmp_dir;} @gplx.Virtual public Process_adp Tmp_dir_(Io_url v) {tmp_dir = v; return this;} Io_url tmp_dir;
|
||||
private Process_adp WhenBgn_run() {return Invk_cmds(whenBgnList);} List_adp whenBgnList = List_adp_.new_();
|
||||
public Process_adp WhenEnd_add(GfoInvkAbleCmd cmd) {whenEndList.Add(cmd); return this;}
|
||||
public Process_adp WhenEnd_del(GfoInvkAbleCmd cmd) {whenEndList.Del(cmd); return this;}
|
||||
public Gfo_usr_dlg Prog_dlg() {return prog_dlg;} public Process_adp Prog_dlg_(Gfo_usr_dlg v) {prog_dlg = v; return this;} Gfo_usr_dlg prog_dlg;
|
||||
public String Prog_fmt() {return prog_fmt;} public Process_adp Prog_fmt_(String v) {prog_fmt = v; return this;} private String prog_fmt = ""; // NOTE: set to "", else cmds that do not set prog_fmt will fail on fmtr.Fmt(null)
|
||||
private GfoInvkAble owner;
|
||||
private ProcessAdp WhenEnd_run() {return Invk_cmds(whenEndList);} List_adp whenEndList = List_adp_.new_();
|
||||
private ProcessAdp Invk_cmds(List_adp list) {
|
||||
private Process_adp WhenEnd_run() {return Invk_cmds(whenEndList);} List_adp whenEndList = List_adp_.new_();
|
||||
private Process_adp Invk_cmds(List_adp list) {
|
||||
for (Object o : list)
|
||||
((GfoInvkAbleCmd)o).Invk();
|
||||
return this;
|
||||
}
|
||||
public ProcessAdp Run(Object... args) {
|
||||
public Process_adp Run(Object... args) {
|
||||
if (String_.Len_eq_0(exe_url.Raw())) return this; // noop if exe_url is "";
|
||||
if (!args_fmtr.Fmt_null()) {
|
||||
Bry_bfr tmp_bfr = Bry_bfr.new_();
|
||||
@ -94,7 +113,7 @@ public class ProcessAdp implements GfoInvkAble, RlsAble {
|
||||
}
|
||||
static final String Invk_cmd = "cmd", Invk_cmd_ = "cmd_", Invk_args = "args", Invk_args_ = "args_", Invk_cmd_args_ = "cmd_args_", Invk_enabled = "enabled", Invk_enabled_ = "enabled_", Invk_mode_ = "mode_", Invk_timeout_ = "timeout_", Invk_tmp_dir_ = "tmp_dir_", Invk_owner = "owner";
|
||||
Bry_fmtr_eval_mgr cmd_url_eval;
|
||||
public static ProcessAdp ini_(GfoInvkAble owner, Gfo_usr_dlg usr_dlg, ProcessAdp process, Bry_fmtr_eval_mgr cmd_url_eval, byte run_mode, int timeout, String cmd_url_fmt, String args_fmt, String... args_keys) {
|
||||
public static Process_adp ini_(GfoInvkAble owner, Gfo_usr_dlg usr_dlg, Process_adp process, Bry_fmtr_eval_mgr cmd_url_eval, byte run_mode, int timeout, String cmd_url_fmt, String args_fmt, String... args_keys) {
|
||||
process.Run_mode_(run_mode).Thread_timeout_seconds_(timeout);
|
||||
process.cmd_url_eval = cmd_url_eval;
|
||||
Io_url cmd_url = Bry_fmtr_eval_mgr_.Eval_url(cmd_url_eval, Bry_.new_u8(cmd_url_fmt));
|
||||
@ -114,27 +133,27 @@ public class ProcessAdp implements GfoInvkAble, RlsAble {
|
||||
private Bry_fmtr notify_fmtr = Bry_fmtr.new_("", "process_exe_name", "process_exe_args", "process_seconds"); Bry_bfr notify_bfr = Bry_bfr.reset_(255);
|
||||
public Process UnderProcess() {return process;} Process process;
|
||||
public void Rls() {if (process != null) process.destroy();}
|
||||
public ProcessAdp Run_wait_sync() {
|
||||
public Process_adp Run_wait_sync() {
|
||||
if (Env_.Mode_testing()) return Test_runs_add();
|
||||
Process_bgn();
|
||||
Process_start();
|
||||
Process_run_and_end();
|
||||
return this;
|
||||
}
|
||||
public ProcessAdp Run_start() {
|
||||
public Process_adp Run_start() {
|
||||
if (Env_.Mode_testing()) return Test_runs_add();
|
||||
Process_bgn();
|
||||
Process_start();
|
||||
return this;
|
||||
}
|
||||
public ProcessAdp Run_async() {
|
||||
public Process_adp Run_async() {
|
||||
if (Env_.Mode_testing()) return Test_runs_add();
|
||||
Process_bgn();
|
||||
Thread_ProcessAdp_async thread = new Thread_ProcessAdp_async(this);
|
||||
thread.start();
|
||||
return this;
|
||||
}
|
||||
public ProcessAdp Run_wait() {
|
||||
public Process_adp Run_wait() {
|
||||
if (Env_.Mode_testing()) return Test_runs_add();
|
||||
int notify_interval = 100; int notify_checkpoint = notify_interval;
|
||||
int elapsed = 0;
|
||||
@ -203,7 +222,7 @@ public class ProcessAdp implements GfoInvkAble, RlsAble {
|
||||
kill_args = "-9 ";
|
||||
}
|
||||
kill_args += thread_kill_name;
|
||||
ProcessAdp kill_process = new ProcessAdp().Exe_url_(Io_url_.new_fil_(kill_exe)).Args_str_(kill_args).Thread_kill_name_("");
|
||||
Process_adp kill_process = new Process_adp().Exe_url_(Io_url_.new_fil_(kill_exe)).Args_str_(kill_args).Thread_kill_name_("");
|
||||
boolean pass = kill_process.Run_wait().Exit_code_pass();
|
||||
return "killed|" + kill_exe + "|" + kill_args + "|" + pass + "|" + exe_url.Raw() + "|" + args_str;
|
||||
}
|
||||
@ -252,15 +271,15 @@ public class ProcessAdp implements GfoInvkAble, RlsAble {
|
||||
process.destroy();
|
||||
}
|
||||
public static void run_wait_(Io_url url) {
|
||||
ProcessAdp process = new ProcessAdp().Exe_url_(url);
|
||||
Process_adp process = new Process_adp().Exe_url_(url);
|
||||
process.Run_start();
|
||||
process.Process_run_and_end();
|
||||
return;
|
||||
}
|
||||
public static final List_adp Test_runs = List_adp_.new_();
|
||||
private ProcessAdp Test_runs_add() {Test_runs.Add(exe_url.Raw() + " " + args_str); exit_code = Exit_pass; return this;}
|
||||
private Process_adp Test_runs_add() {Test_runs.Add(exe_url.Raw() + " " + args_str); exit_code = Exit_pass; return this;}
|
||||
public static int run_wait_arg_(Io_url url, String arg) {
|
||||
ProcessAdp process = new ProcessAdp();
|
||||
Process_adp process = new Process_adp();
|
||||
process.Exe_url_(url).Args_str_(arg).Run_wait();
|
||||
return process.Exit_code();
|
||||
}
|
||||
@ -288,7 +307,7 @@ public class ProcessAdp implements GfoInvkAble, RlsAble {
|
||||
}
|
||||
}
|
||||
class Thread_ProcessAdp_async extends Thread {
|
||||
public Thread_ProcessAdp_async(ProcessAdp process_adp) {this.process_adp = process_adp;} ProcessAdp process_adp;
|
||||
public Thread_ProcessAdp_async(Process_adp process_adp) {this.process_adp = process_adp;} Process_adp process_adp;
|
||||
public boolean Done() {return done;} boolean done = false;
|
||||
public void Cancel() {process_adp.UnderProcess().destroy();}
|
||||
public void run() {
|
||||
@ -296,7 +315,7 @@ class Thread_ProcessAdp_async extends Thread {
|
||||
}
|
||||
}
|
||||
class Thread_ProcessAdp_sync extends Thread {
|
||||
public Thread_ProcessAdp_sync(ProcessAdp process_adp) {this.process_adp = process_adp;} private final ProcessAdp process_adp;
|
||||
public Thread_ProcessAdp_sync(Process_adp process_adp) {this.process_adp = process_adp;} private final Process_adp process_adp;
|
||||
public boolean Done() {return done;} private boolean done = false;
|
||||
public void Cancel() {
|
||||
process_adp.UnderProcess().destroy();
|
@ -15,18 +15,18 @@ GNU Affero General Public License for more details.
|
||||
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;
|
||||
package gplx.core.envs; import gplx.*; import gplx.core.*;
|
||||
import org.junit.*;
|
||||
public class ProcessAdp_tst {
|
||||
private ProcessAdp_fxt fxt = new ProcessAdp_fxt();
|
||||
public class Process_adp_tst {
|
||||
private Process_adp_fxt fxt = new Process_adp_fxt();
|
||||
@Test public void Escape_ampersands_if_process_is_cmd() {
|
||||
fxt.Test_Escape_ampersands_if_process_is_cmd(Bool_.Y, "cmd" , "/c \"http://a.org?b=c&d=e\"", "/c \"http://a.org?b=c^&d=e\"");
|
||||
fxt.Test_Escape_ampersands_if_process_is_cmd(Bool_.Y, "cmd1", "/c \"http://a.org?b=c&d=e\"", "/c \"http://a.org?b=c&d=e\"");
|
||||
fxt.Test_Escape_ampersands_if_process_is_cmd(Bool_.N, "cmd" , "/c \"http://a.org?b=c&d=e\"", "/c \"http://a.org?b=c&d=e\"");
|
||||
}
|
||||
}
|
||||
class ProcessAdp_fxt {
|
||||
class Process_adp_fxt {
|
||||
public void Test_Escape_ampersands_if_process_is_cmd(boolean os_is_wnt, String exe_url, String exe_args, String expd) {
|
||||
Tfds.Eq(expd, ProcessAdp.Escape_ampersands_if_process_is_cmd(os_is_wnt, exe_url, exe_args));
|
||||
Tfds.Eq(expd, Process_adp.Escape_ampersands_if_process_is_cmd(os_is_wnt, exe_url, exe_args));
|
||||
}
|
||||
}
|
@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
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;
|
||||
package gplx.core.errs; import gplx.*; import gplx.core.*;
|
||||
public class Err_msg {
|
||||
private final String msg; private Object[] args;
|
||||
public Err_msg(String type, String msg, Object[] args) {
|
@ -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.gfo_ndes; import gplx.*; import gplx.core.*;
|
||||
import gplx.core.type_xtns.*;
|
||||
public class GfoFld {
|
||||
public String Key() {return key;} private String key;
|
||||
public ClassXtn Type() {return type;} ClassXtn type;
|
||||
|
@ -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.gfo_ndes; import gplx.*; import gplx.core.*;
|
||||
import gplx.core.type_xtns.*;
|
||||
public interface GfoFldList {
|
||||
int Count();
|
||||
boolean Has(String key);
|
||||
|
@ -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.gfo_ndes; import gplx.*; import gplx.core.*;
|
||||
import gplx.core.strings.*;
|
||||
import gplx.core.strings.*; import gplx.core.type_xtns.*;
|
||||
public class GfoFldList_ {
|
||||
public static final GfoFldList Null = new GfoFldList_null();
|
||||
public static GfoFldList new_() {return new GfoFldList_base();}
|
||||
|
@ -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.gfo_ndes; import gplx.*; import gplx.core.*;
|
||||
import gplx.core.strings.*;
|
||||
import gplx.core.strings.*; import gplx.core.stores.*;
|
||||
public class GfoNde implements GfoInvkAble {
|
||||
public GfoFldList Flds() {return flds;} GfoFldList flds;
|
||||
public Hash_adp EnvVars() {return envVars;} Hash_adp envVars = Hash_adp_.new_();
|
||||
|
@ -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.gfo_ndes; import gplx.*; import gplx.core.*;
|
||||
import gplx.core.type_xtns.*;
|
||||
public class GfoNdeFxt {
|
||||
public GfoNde root_(GfoNde... subs) {return GfoNde_.root_(subs);}
|
||||
public GfoNde tbl_(String name, GfoNde... rows) {return GfoNde_.tbl_(name, GfoFldList_.Null, rows);}
|
||||
|
@ -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.gfo_ndes; import gplx.*; import gplx.core.*;
|
||||
import gplx.lists.*; /*ComparerAble*/
|
||||
import gplx.core.lists.*; /*ComparerAble*/
|
||||
public interface GfoNdeList {
|
||||
int Count();
|
||||
GfoNde FetchAt_asGfoNde(int index);
|
||||
|
@ -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.gfo_ndes; import gplx.*; import gplx.core.*;
|
||||
import gplx.lists.*; /*ComparerAble*/
|
||||
import gplx.core.lists.*; /*ComparerAble*/
|
||||
public class GfoNdeList_ {
|
||||
public static final GfoNdeList Null = new GfoNdeList_null();
|
||||
public static GfoNdeList new_() {return new GfoNdeList_base();}
|
||||
|
@ -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.gfo_ndes; import gplx.*; import gplx.core.*;
|
||||
import gplx.core.type_xtns.*; import gplx.core.stores.*;
|
||||
public class GfoNde_ {
|
||||
public static final GfoNde[] Ary_empty = new GfoNde[0];
|
||||
public static GfoNde[] ary_(GfoNde... ary) {return 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.gfo_regys; import gplx.*; import gplx.core.*;
|
||||
import gplx.langs.gfs.*;
|
||||
import gplx.langs.gfs.*; import gplx.core.type_xtns.*;
|
||||
public class GfoRegy implements GfoInvkAble {
|
||||
public int Count() {return hash.Count();}
|
||||
public Hash_adp Parsers() {return parsers;} Hash_adp parsers = Hash_adp_.new_();
|
||||
|
@ -27,7 +27,7 @@ import java.util.Date;
|
||||
|
||||
import javax.print.FlavorException;
|
||||
import javax.tools.JavaCompiler;
|
||||
import gplx.core.criterias.*;
|
||||
import gplx.core.criterias.*; import gplx.core.envs.*;
|
||||
public class IoEngine_system extends IoEngine_base {
|
||||
@Override public String Key() {return IoEngine_.SysKey;}
|
||||
@Override public void DeleteDirDeep(IoEngine_xrg_deleteDir args) {utl.DeleteDirDeep(this, args.Url(), args);}
|
||||
|
@ -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.core.texts.*;
|
||||
import gplx.core.texts.*; import gplx.core.envs.*;
|
||||
public class IoEngine_xrg_loadFilStr {
|
||||
public Io_url Url() {return url;} public IoEngine_xrg_loadFilStr Url_(Io_url val) {url = val; return this;} Io_url url;
|
||||
public boolean MissingIgnored() {return missingIgnored;} public IoEngine_xrg_loadFilStr MissingIgnored_() {return MissingIgnored_(true);} public IoEngine_xrg_loadFilStr MissingIgnored_(boolean v) {missingIgnored = v; return this;} private boolean missingIgnored = false;
|
||||
|
@ -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.ios; import gplx.*; import gplx.core.*;
|
||||
import gplx.core.type_xtns.*;
|
||||
public class IoItmClassXtn extends ClassXtn_base implements ClassXtn {
|
||||
public String Key() {return Key_const;} public static final String Key_const = "ioItemType";
|
||||
@Override public Class<?> UnderClass() {return int.class;}
|
||||
|
@ -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.*; /*Ordered_hash_base*/
|
||||
import gplx.core.lists.*; /*Ordered_hash_base*/
|
||||
public class IoItmList extends Ordered_hash_base {
|
||||
public boolean Has(Io_url url) {return Has_base(MakeKey(url));}
|
||||
public void Add(IoItm_base itm) {
|
||||
|
@ -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.ios; import gplx.*; import gplx.core.*;
|
||||
import gplx.core.envs.*;
|
||||
public interface IoUrlInfo {
|
||||
String Key();
|
||||
byte DirSpr_byte();
|
||||
|
@ -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.ios; import gplx.*; import gplx.core.*;
|
||||
import gplx.core.envs.*;
|
||||
import gplx.langs.gfs.*;
|
||||
public class IoUrlInfoRegy implements GfoInvkAble {
|
||||
public void Reg(IoUrlInfo info) {hash.Add_if_dupe_use_nth(info.Key(), info);}
|
||||
|
@ -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.stores.*; /*GfoNdeRdr_*/
|
||||
import gplx.core.envs.*; import gplx.core.stores.*; /*GfoNdeRdr_*/
|
||||
import gplx.core.gfo_regys.*;
|
||||
public class IoZipWkr {
|
||||
public Io_url ExeUrl() {return (Io_url)GfoRegy.Instance.FetchValOrFail(Regy_ExeUrl);}
|
||||
@ -29,7 +29,7 @@ public class IoZipWkr {
|
||||
@gplx.Internal protected String Expand_genCmdString(Io_url srcUrl, Io_url trgUrl) {
|
||||
return String_.Format(this.ExeArgFmt(), srcUrl.Xto_api(), trgUrl.Xto_api());
|
||||
}
|
||||
ProcessAdp process = new ProcessAdp();
|
||||
Process_adp process = new Process_adp();
|
||||
public static IoZipWkr regy_() {return new IoZipWkr();}
|
||||
static final String Regy_ExeUrl = "gplx.core.ios.IoZipWkr.ExeUrl", Regy_ExeArgFmt = "gplx.core.ios.IoZipWkr.ExeArgFmt";
|
||||
public static IoZipWkr new_(Io_url exeUrl, String expandArgs) {
|
||||
|
@ -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.core.brys.args.*; import gplx.core.brys.fmtrs.*;
|
||||
import gplx.core.brys.args.*; import gplx.core.brys.fmtrs.*; import gplx.core.envs.*;
|
||||
public class Io_download_fmt {
|
||||
private final Io_size_fmtr_arg size_fmtr_arg = new Io_size_fmtr_arg(), rate_fmtr_arg = new Io_size_fmtr_arg().Suffix_(Bry_.new_a7("ps"));
|
||||
private final Bfr_arg__time prog_left_fmtr_arg = new Bfr_arg__time(); private final Bfr_arg__decimal_int prog_pct_fmtr_arg = new Bfr_arg__decimal_int().Places_(2);
|
||||
|
@ -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_download_fmt_tst {
|
||||
Io_download_fmt_fxt fxt = new Io_download_fmt_fxt();
|
||||
@Before public void init() {fxt.Clear();}
|
||||
|
@ -15,6 +15,6 @@ GNU Affero General Public License for more details.
|
||||
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.lists; import gplx.*;
|
||||
package gplx.core.lists; import gplx.*; import gplx.core.*;
|
||||
public interface ComparerAble extends java.util.Comparator {} //_20110320
|
||||
// public int compare(Object lhsObj, Object rhsObj) {}
|
@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
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.lists; import gplx.*;
|
||||
package gplx.core.lists; import gplx.*; import gplx.core.*;
|
||||
public class ComparerAble_ {
|
||||
public static int Compare(ComparerAble comparer, Object lhs, Object rhs) {return comparer.compare(lhs, rhs);}
|
||||
}
|
@ -15,5 +15,5 @@ GNU Affero General Public License for more details.
|
||||
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.lists; import gplx.*;
|
||||
package gplx.core.lists; import gplx.*; import gplx.core.*;
|
||||
public interface EnumerAble extends java.lang.Iterable {}//_20110320
|
@ -15,19 +15,19 @@ GNU Affero General Public License for more details.
|
||||
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.lists; import gplx.*;
|
||||
package gplx.core.lists; import gplx.*; import gplx.core.*;
|
||||
public abstract class Hash_adp_base implements Hash_adp {
|
||||
public boolean Has(Object key) {return Has_base(key);}
|
||||
public Object Get_by(Object key) {return Fetch_base(key);}
|
||||
public Object Get_by_or_fail(Object key) {return Get_by_or_fail_base(key);}
|
||||
public Object Get_by_or_new(Object key, NewAble proto) {
|
||||
Object rv = Fetch_base(key);
|
||||
if (rv == null) {
|
||||
rv = proto.NewByKey(key);
|
||||
Add_base(key, rv);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
// public Object Get_by_or_new(Object key, NewAble proto) {
|
||||
// Object rv = Fetch_base(key);
|
||||
// if (rv == null) {
|
||||
// rv = proto.NewByKey(key);
|
||||
// Add_base(key, rv);
|
||||
// }
|
||||
// return rv;
|
||||
// }
|
||||
public void Add(Object key, Object val) {Add_base(key, val);}
|
||||
public void Add_as_key_and_val(Object val) {Add_base(val, val);}
|
||||
public void Add_if_dupe_use_nth(Object key, Object val) {
|
@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
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.lists; import gplx.*;
|
||||
package gplx.core.lists; import gplx.*; import gplx.core.*;
|
||||
public class Hash_adp_list extends Hash_adp_base {
|
||||
@gplx.New public List_adp Get_by(Object key) {return List_adp_.as_(Fetch_base(key));}
|
||||
public List_adp Get_by_or_new(Object key) {
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user