mirror of
https://github.com/gnosygnu/xowa.git
synced 2025-06-02 07:24:19 +00:00
v2.12.1.1
This commit is contained in:
parent
097e6c7f80
commit
9509363f46
@ -1,7 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="src_100_interface"/>
|
||||
<classpathentry kind="src" path="src_311_gfoObj"/>
|
||||
<classpathentry kind="src" path="src_420_usrMsg"/>
|
||||
<classpathentry kind="src" path="tst"/>
|
||||
|
@ -447,6 +447,7 @@ public class Bry_ {
|
||||
public static boolean Match(byte[] src, int src_bgn, byte[] find) {return Match(src, src_bgn, src.length, find, 0, find.length);}
|
||||
public static boolean Match(byte[] src, int src_bgn, int src_end, byte[] find) {return Match(src, src_bgn, src_end, find, 0, find.length);}
|
||||
public static boolean Match(byte[] src, int src_bgn, int src_end, byte[] find, int find_bgn, int find_end) {
|
||||
if (src_bgn == -1) return false;
|
||||
int src_len = src.length;
|
||||
if (src_end > src_len) src_end = src_len; // must limit src_end to src_len, else ArrayIndexOutOfBounds below; DATE:2015-01-31
|
||||
int find_len = find_end - find_bgn;
|
||||
@ -968,4 +969,9 @@ public class Bry_ {
|
||||
}
|
||||
return dirty ? bfr.To_bry_and_clear() : src;
|
||||
}
|
||||
public static void Clear(byte[] bry) {
|
||||
int len = bry.length;
|
||||
for (int i = 0; i < len; ++i)
|
||||
bry[i] = Byte_.Zero;
|
||||
}
|
||||
}
|
||||
|
@ -163,6 +163,7 @@ public class Bry_bfr {
|
||||
src.Clear();
|
||||
return this;
|
||||
}
|
||||
public Bry_bfr Add_byte_as_a7(byte v) {return Add_byte((byte)(v + Byte_ascii.Num_0));}
|
||||
public Bry_bfr Add_byte_eq() {return Add_byte(Byte_ascii.Eq);}
|
||||
public Bry_bfr Add_byte_pipe() {return Add_byte(Byte_ascii.Pipe);}
|
||||
public Bry_bfr Add_byte_comma() {return Add_byte(Byte_ascii.Comma);}
|
||||
@ -577,7 +578,11 @@ public class Bry_bfr {
|
||||
public static Bry_bfr new_() {return new Bry_bfr(16);}
|
||||
public static Bry_bfr new_(int v) {return new Bry_bfr(v);}
|
||||
public static Bry_bfr reset_(int v) {return new Bry_bfr(16).Reset_(v);} // PERF: set initial size to 16, not reset val; allows for faster "startup"; DATE:2014-06-14
|
||||
protected Bry_bfr() {}
|
||||
Bry_bfr(int bfr_max) {
|
||||
Init(bfr_max);
|
||||
}
|
||||
protected void Init(int bfr_max) {
|
||||
this.bfr_max = bfr_max;
|
||||
this.bfr = new byte[bfr_max];
|
||||
}
|
||||
|
@ -120,5 +120,6 @@ public class Byte_ascii {
|
||||
, Slash_bry = new byte[] {Byte_ascii.Slash}
|
||||
, Asterisk_bry = new byte[] {Byte_ascii.Star}
|
||||
, Dash_bry = new byte[] {Byte_ascii.Dash}
|
||||
, Cr_lf_bry = new byte[] {Byte_ascii.Cr, Byte_ascii.Nl}
|
||||
;
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
import gplx.core.times.*;
|
||||
public class DateAdp_ implements GfoInvkAble {
|
||||
public static final String Cls_ref_name = "Date";
|
||||
public static final Class<?> Cls_ref_type = DateAdp.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;
|
||||
import org.junit.*;
|
||||
import org.junit.*; import gplx.core.times.*;
|
||||
public class DateAdp__tst {
|
||||
@Test public void Parse_gplx() {
|
||||
tst_Parse_gplx("99991231_235959.999", "99991231_235959.999");
|
||||
|
@ -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.ios.*; /*IoUrlInfo*/ import gplx.core.envs.*;
|
||||
import gplx.core.strings.*; import gplx.core.ios.*; /*IoUrlInfo*/ import gplx.core.envs.*; import gplx.langs.htmls.*; import gplx.core.interfaces.*;
|
||||
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;
|
||||
|
@ -59,7 +59,7 @@ public class List_adp_ {
|
||||
}
|
||||
public static void DisposeAll(List_adp list) {
|
||||
for (int i = 0; i < list.Count(); i++)
|
||||
((RlsAble)list.Get_at(i)).Rls();
|
||||
((Rls_able)list.Get_at(i)).Rls();
|
||||
}
|
||||
public static List_adp new_ary_(Object ary) {
|
||||
int ary_len = Array_.Len(ary);
|
||||
|
@ -16,6 +16,6 @@ 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 RlsAble {
|
||||
public interface Rls_able {
|
||||
void Rls();
|
||||
}
|
@ -16,11 +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 class RlsAble_ {
|
||||
public static RlsAble as_(Object obj) {return obj instanceof RlsAble ? (RlsAble)obj : null;}
|
||||
public static RlsAble cast(Object obj) {try {return (RlsAble)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, RlsAble.class, obj);}}
|
||||
public static final RlsAble Null = new RlsAble__noop();
|
||||
public class Rls_able_ {
|
||||
public static Rls_able as_(Object obj) {return obj instanceof Rls_able ? (Rls_able)obj : null;}
|
||||
public static Rls_able cast(Object obj) {try {return (Rls_able)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, Rls_able.class, obj);}}
|
||||
public static final Rls_able Null = new Rls_able__noop();
|
||||
}
|
||||
class RlsAble__noop implements RlsAble {
|
||||
class Rls_able__noop implements Rls_able {
|
||||
public void Rls() {}
|
||||
}
|
@ -151,10 +151,11 @@ public class TimeSpanAdp_ {
|
||||
3600000, //3,600,000 fracs in an hour (60 minutes * 60,000)
|
||||
};
|
||||
public static final String MajorDelimiter = ":";
|
||||
@gplx.Internal protected static final int Idx_Frac = 0;
|
||||
@gplx.Internal protected static final int Idx_Sec = 1;
|
||||
@gplx.Internal protected static final int Idx_Min = 2;
|
||||
@gplx.Internal protected static final int Idx_Hour = 3;
|
||||
public static final int
|
||||
Idx_Frac = 0
|
||||
, Idx_Sec = 1
|
||||
, Idx_Min = 2
|
||||
, Idx_Hour = 3;
|
||||
static int[] ZeroPadding = {3, 2, 2, 2,};
|
||||
static String[] Sprs = {".", MajorDelimiter, MajorDelimiter, "",};
|
||||
public static TimeSpanAdp cast(Object arg) {try {return (TimeSpanAdp)arg;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, TimeSpanAdp.class, arg);}}
|
||||
|
@ -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.bits; import gplx.*; import gplx.core.*;
|
||||
public class Bitmask_ {
|
||||
public static boolean Has_int(int val, int find) {return find == (val & find);}
|
||||
public static int Flip_int(boolean enable, int val, int find) {
|
@ -27,7 +27,7 @@ public class Btrie_slim_mgr implements Btrie_mgr {
|
||||
return rv == null ? null : match_pos - bgn_pos == end_pos - bgn_pos ? rv : null;
|
||||
}
|
||||
public Object Match_bgn(byte[] src, int bgn_pos, int end_pos) {return bgn_pos < end_pos ? Match_bgn_w_byte(src[bgn_pos], src, bgn_pos, end_pos) : null;} // handle out of bounds gracefully; EX: Match_bgn("abc", 3, 3) should return null not fail
|
||||
public Object Match_bgn_w_byte(byte b, byte[] src, int bgn_pos, int src_len) {
|
||||
public Object Match_bgn_w_byte(byte b, byte[] src, int bgn_pos, int src_end) {
|
||||
Object rv = null; int cur_pos = match_pos = bgn_pos;
|
||||
Btrie_slim_itm cur = root;
|
||||
while (true) {
|
||||
@ -36,7 +36,7 @@ public class Btrie_slim_mgr implements Btrie_mgr {
|
||||
if (nxt.Ary_is_empty()) {match_pos = cur_pos; return nxt.Val();} // nxt is leaf; return nxt.Val() (which should be non-null)
|
||||
Object nxt_val = nxt.Val();
|
||||
if (nxt_val != null) {match_pos = cur_pos; rv = nxt_val;} // nxt is node; cache rv (in case of false match)
|
||||
if (cur_pos == src_len) return rv; // increment cur_pos and exit if src_len
|
||||
if (cur_pos == src_end) return rv; // increment cur_pos and exit if src_end
|
||||
b = src[cur_pos];
|
||||
cur = nxt;
|
||||
}
|
||||
@ -67,6 +67,13 @@ public class Btrie_slim_mgr implements Btrie_mgr {
|
||||
Add_obj(ary[i], obj);
|
||||
return this;
|
||||
}
|
||||
public Btrie_slim_mgr Add_replace_many(String trg_str, String... src_ary) {return Add_replace_many(Bry_.new_u8(trg_str), src_ary);}
|
||||
public Btrie_slim_mgr Add_replace_many(byte[] trg_bry, String... src_ary) {
|
||||
int len = src_ary.length;
|
||||
for (int i = 0; i < len; i++)
|
||||
Add_obj(Bry_.new_u8(src_ary[i]), trg_bry);
|
||||
return this;
|
||||
}
|
||||
public Btrie_slim_mgr Add_stub(String key, byte val) {byte[] bry = Bry_.new_u8(key); return (Btrie_slim_mgr)Add_obj(bry, new Btrie_itm_stub(val, bry));}
|
||||
public Btrie_slim_mgr Add_stubs(byte[][] ary) {return Add_stubs(ary, ary.length);}
|
||||
public Btrie_slim_mgr Add_stubs(byte[][] ary, int ary_len) {
|
||||
|
56
100_core/src/gplx/core/encoders/B85_fp_.java
Normal file
56
100_core/src/gplx/core/encoders/B85_fp_.java
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
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.encoders; import gplx.*; import gplx.core.*;
|
||||
public class B85_fp_ {
|
||||
public static byte[] To_bry(double v) {
|
||||
String str = Double_.To_str(v);
|
||||
byte[] bry = Bry_.new_a7(str); int len = bry.length;
|
||||
int num_len = len; boolean neg = false;
|
||||
int bgn = 0; int dot = -1;
|
||||
if (bry[0] == Byte_ascii.Dash) {neg = true; bgn = 1; --num_len;}
|
||||
boolean skip_zeros = true;
|
||||
for (int i = bgn; i < len; ++i) {
|
||||
byte b = bry[i];
|
||||
switch (b) {
|
||||
case Byte_ascii.Num_0:
|
||||
if (skip_zeros)
|
||||
--num_len;
|
||||
break;
|
||||
case Byte_ascii.Dot:
|
||||
skip_zeros = false;
|
||||
dot = i;
|
||||
--num_len;
|
||||
break;
|
||||
default:
|
||||
skip_zeros = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
int pow = 0;
|
||||
if (dot != -1) {
|
||||
pow = len - (dot + 1);
|
||||
for (int i = 0; i < pow; ++i)
|
||||
v *= 10;
|
||||
}
|
||||
int num = (int)v;
|
||||
byte[] rv = new byte[num_len + 1];
|
||||
rv[0] = (byte)(Byte_ascii.Dot + pow + (neg ? 45 : 0));
|
||||
Base85_.Set_bry(num, rv, 1, 1);
|
||||
return rv;
|
||||
}
|
||||
}
|
31
100_core/src/gplx/core/encoders/B85_fp__tst.java
Normal file
31
100_core/src/gplx/core/encoders/B85_fp__tst.java
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
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.encoders; import gplx.*; import gplx.core.*;
|
||||
import org.junit.*;
|
||||
public class B85_fp__tst {
|
||||
private final B85_fp__fxt fxt = new B85_fp__fxt();
|
||||
@Test public void Double_to_str() {
|
||||
fxt.Test__to_str(.1d, "/\"");
|
||||
}
|
||||
}
|
||||
class B85_fp__fxt {
|
||||
public void Test__to_str(double val, String expd) {
|
||||
byte[] actl = B85_fp_.To_bry(val);
|
||||
Tfds.Eq_str(expd, String_.new_a7(actl));
|
||||
}
|
||||
}
|
@ -31,7 +31,7 @@ import gplx.Io_url;
|
||||
import gplx.Io_url_;
|
||||
import gplx.List_adp;
|
||||
import gplx.List_adp_;
|
||||
import gplx.RlsAble;
|
||||
import gplx.Rls_able;
|
||||
import gplx.String_;
|
||||
import gplx.Tfds;
|
||||
import gplx.Virtual;
|
||||
@ -45,7 +45,7 @@ import java.io.InputStreamReader;
|
||||
import javax.management.RuntimeErrorException;
|
||||
import gplx.core.brys.fmtrs.*; import gplx.core.strings.*;
|
||||
import gplx.langs.gfs.*;
|
||||
public class Process_adp implements GfoInvkAble, RlsAble {
|
||||
public class Process_adp implements GfoInvkAble, Rls_able {
|
||||
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;
|
||||
|
@ -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.core.type_xtns.*;
|
||||
import gplx.langs.gfs.*; import gplx.core.type_xtns.*; import gplx.core.interfaces.*;
|
||||
public class GfoRegy implements GfoInvkAble {
|
||||
public int Count() {return hash.Count();}
|
||||
public Hash_adp Parsers() {return parsers;} Hash_adp parsers = Hash_adp_.new_();
|
||||
|
@ -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.interfaces; import gplx.*; import gplx.core.*;
|
||||
public interface InjectAble {
|
||||
void Inject(Object owner);
|
||||
}
|
@ -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.interfaces; import gplx.*; import gplx.core.*;
|
||||
public interface ParseAble {
|
||||
Object ParseAsObj(String raw);
|
||||
}
|
@ -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.interfaces; import gplx.*; import gplx.core.*;
|
||||
public interface SrlAble {
|
||||
Object Srl(GfoMsg owner);
|
||||
}
|
@ -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.interfaces; import gplx.*; import gplx.core.*;
|
||||
import gplx.core.strings.*;
|
||||
public class SrlAble_ {
|
||||
public static SrlAble as_(Object obj) {return obj instanceof SrlAble ? (SrlAble)obj : null;}
|
@ -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.interfaces; import gplx.*; import gplx.core.*;
|
||||
import org.junit.*;
|
||||
public class SrlAble__tst {
|
||||
@Test public void Basic() {
|
@ -27,7 +27,7 @@ import java.util.Date;
|
||||
|
||||
import javax.print.FlavorException;
|
||||
import javax.tools.JavaCompiler;
|
||||
import gplx.core.criterias.*; import gplx.core.envs.*;
|
||||
import gplx.core.criterias.*; import gplx.core.bits.*; 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.*;
|
||||
public interface IoStream extends RlsAble {
|
||||
public interface IoStream extends Rls_able {
|
||||
Object UnderRdr();
|
||||
Io_url Url();
|
||||
long Pos();
|
||||
|
@ -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 interface Io_stream_rdr extends RlsAble {
|
||||
public interface Io_stream_rdr extends Rls_able {
|
||||
byte Tid();
|
||||
boolean Exists();
|
||||
Io_url Url(); Io_stream_rdr Url_(Io_url v);
|
||||
|
@ -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 interface Io_stream_wtr extends RlsAble {
|
||||
public interface Io_stream_wtr extends Rls_able {
|
||||
byte Tid();
|
||||
Io_url Url(); Io_stream_wtr Url_(Io_url v);
|
||||
void Trg_bfr_(Bry_bfr v);
|
||||
|
@ -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.primitives; import gplx.*; import gplx.core.*;
|
||||
import gplx.core.strings.*;
|
||||
public class EnmMgr {
|
||||
public String BitRngSpr() {return bitRngSpr;} public EnmMgr BitRngSpr_(String val) {bitRngSpr = val; return this;} private String bitRngSpr = "+";
|
@ -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.primitives; import gplx.*; import gplx.core.*;
|
||||
import org.junit.*;
|
||||
public class EnmParser_tst {
|
||||
@Before public void setup() {
|
@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.core.stores; import gplx.*; import gplx.core.*;
|
||||
import gplx.core.strings.*;
|
||||
public interface DataRdr extends SrlMgr, RlsAble {
|
||||
public interface DataRdr extends SrlMgr, Rls_able {
|
||||
String NameOfNode(); String To_str();
|
||||
Io_url Uri(); void Uri_set(Io_url s);
|
||||
Hash_adp EnvVars();
|
||||
|
@ -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.times; import gplx.*; import gplx.core.*;
|
||||
public class DateAdp_parser {
|
||||
public int[] Parse_iso8651_like(String raw_str) {Parse_iso8651_like(tmp_rv, raw_str); return tmp_rv;} int[] tmp_rv = new int[7];
|
||||
public void Parse_iso8651_like(int[] rv, String raw_str) {
|
@ -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.times; import gplx.*; import gplx.core.*;
|
||||
import org.junit.*;
|
||||
public class DateAdp_parser_tst {
|
||||
@Before public void init() {} DateAdp_parser_fxt fxt = new DateAdp_parser_fxt();
|
@ -15,9 +15,9 @@ 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.times; import gplx.*; import gplx.core.*;
|
||||
import org.junit.*;
|
||||
public class TimeSpanAdp_basic_tst {
|
||||
public class TimeSpanAdp__basic_tst {
|
||||
@Test public void seconds_() {
|
||||
TimeSpanAdp expd = TimeSpanAdp_.fracs_(123987);
|
||||
TimeSpanAdp actl = TimeSpanAdp_.seconds_(123.987);
|
@ -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.times; import gplx.*; import gplx.core.*;
|
||||
import org.junit.*;
|
||||
public class TimeSpanAdp__parse_tst {
|
||||
@Test public void Zero() {
|
@ -15,9 +15,9 @@ 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.times; import gplx.*; import gplx.core.*;
|
||||
import org.junit.*;
|
||||
public class TimeSpanAdp_xtoStr_tst {
|
||||
public class TimeSpanAdp__to_str_tst {
|
||||
@Test public void Zero() {
|
||||
tst_Default(0, "0");
|
||||
}
|
22
100_core/src/gplx/langs/htmls/Url_encoder_interface.java
Normal file
22
100_core/src/gplx/langs/htmls/Url_encoder_interface.java
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
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.langs.htmls; import gplx.*; import gplx.langs.*;
|
||||
public interface Url_encoder_interface {
|
||||
String Encode_str(String v);
|
||||
byte[] Encode_bry(String v);
|
||||
}
|
@ -15,12 +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 interface Url_encoder_interface {
|
||||
String Encode_str(String v);
|
||||
byte[] Encode_bry(String v);
|
||||
}
|
||||
class Url_encoder_interface_same implements Url_encoder_interface {
|
||||
package gplx.langs.htmls; import gplx.*; import gplx.langs.*;
|
||||
public class Url_encoder_interface_same implements Url_encoder_interface {
|
||||
public String Encode_str(String v) {return v;}
|
||||
public byte[] Encode_bry(String v) {return Bry_.new_u8(v);}
|
||||
public static final Url_encoder_interface_same Instance = new Url_encoder_interface_same(); Url_encoder_interface_same() {}
|
@ -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.interfaces.*;
|
||||
public interface GfoMsg {
|
||||
String Key();
|
||||
GfoMsg CloneNew();
|
||||
|
@ -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.primitives.*; import gplx.core.strings.*; import gplx.core.brys.*;
|
||||
import gplx.core.primitives.*; import gplx.core.strings.*; import gplx.core.brys.*; import gplx.core.interfaces.*;
|
||||
public class GfoMsg_ {
|
||||
public static GfoMsg as_(Object obj) {return obj instanceof GfoMsg ? (GfoMsg)obj : null;}
|
||||
public static final GfoMsg Null = new GfoMsg_base().ctor_("<<NULL MSG>>", false);
|
||||
|
@ -51,11 +51,11 @@ public class Db_conn {
|
||||
public void Ddl_delete_tbl(String tbl) {engine.Ddl_delete_tbl(tbl);}
|
||||
public boolean Meta_tbl_exists(String tbl) {return engine.Meta_tbl_exists(tbl);}
|
||||
public boolean Meta_fld_exists(String tbl, String fld) {return engine.Meta_fld_exists(tbl, fld);}
|
||||
public void Rls_reg(RlsAble rls) {rls_list.Add(rls);}
|
||||
public void Rls_reg(Rls_able rls) {rls_list.Add(rls);}
|
||||
public void Rls_conn() {
|
||||
int len = rls_list.Count();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
RlsAble itm = (RlsAble)rls_list.Get_at(i);
|
||||
Rls_able itm = (Rls_able)rls_list.Get_at(i);
|
||||
itm.Rls();
|
||||
}
|
||||
engine.Conn_term();
|
||||
|
@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.dbs; import gplx.*;
|
||||
import gplx.dbs.engines.*; import gplx.core.stores.*;
|
||||
public interface Db_stmt extends RlsAble {
|
||||
public interface Db_stmt extends Rls_able {
|
||||
Db_stmt Crt_bool_as_byte(String k, boolean v);
|
||||
Db_stmt Val_bool_as_byte(String k, boolean v);
|
||||
Db_stmt Val_bool_as_byte(boolean v);
|
||||
|
@ -16,6 +16,6 @@ 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.dbs; import gplx.*;
|
||||
public interface Db_tbl extends RlsAble {
|
||||
public interface Db_tbl extends Rls_able {
|
||||
void Create_tbl();
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.dbs; import gplx.*;
|
||||
import gplx.core.stores.*;
|
||||
import gplx.dbs.engines.sqlite.*; import gplx.dbs.engines.mysql.*; import gplx.dbs.engines.postgres.*; import gplx.core.gfo_ndes.*;
|
||||
public class Db_conn_fxt implements RlsAble {
|
||||
public class Db_conn_fxt implements Rls_able {
|
||||
public Db_conn Conn() {return conn;} public Db_conn_fxt Conn_(Db_conn v) {conn = v; return this;} Db_conn conn;
|
||||
public void DmlAffectedAvailable_(boolean v) {dmlAffectedAvailable = v;} private boolean dmlAffectedAvailable = true;
|
||||
public void ini_DeleteAll(String tbl) {conn.Exec_qry(Db_qry_.delete_tbl_(tbl));}
|
||||
|
@ -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.gfui; import gplx.*;
|
||||
import gplx.core.interfaces.*;
|
||||
public class GfuiAlign_ implements ParseAble {
|
||||
public static GfuiAlign as_(Object obj) {return obj instanceof GfuiAlign ? (GfuiAlign)obj : null;}
|
||||
public static GfuiAlign cast(Object obj) {try {return (GfuiAlign)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, GfuiAlign.class, obj);}}
|
||||
|
@ -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.gfui; import gplx.*;
|
||||
import gplx.core.bits.*;
|
||||
public class GfuiBorderEdge {
|
||||
public int Val() {return val;} int val;
|
||||
public boolean Has(GfuiBorderEdge comp) {return Bitmask_.Has_int(val, comp.val);}
|
||||
|
@ -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.gfui; import gplx.*;
|
||||
import gplx.core.interfaces.*;
|
||||
public class SizeAdpF implements ParseAble {
|
||||
public float Width() {return width;} float width;
|
||||
public float Height() {return height;} float height;
|
||||
|
@ -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.gfui; import gplx.*;
|
||||
import gplx.core.texts.*;
|
||||
import gplx.core.texts.*; import gplx.core.interfaces.*;
|
||||
public class ColorAdp_ implements ParseAble {
|
||||
public static ColorAdp as_(Object obj) {return obj instanceof ColorAdp ? (ColorAdp)obj : null;}
|
||||
public static ColorAdp cast(Object obj) {try {return (ColorAdp)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, ColorAdp.class, obj);}}
|
||||
|
@ -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.gfui; import gplx.*;
|
||||
import gplx.core.primitives.*;
|
||||
import gplx.core.primitives.*; import gplx.core.interfaces.*;
|
||||
public class FontStyleAdp_ implements ParseAble {
|
||||
public static final FontStyleAdp
|
||||
Plain = new FontStyleAdp(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.gfui; import gplx.*;
|
||||
public interface GfxAdp extends RlsAble {
|
||||
public interface GfxAdp extends Rls_able {
|
||||
void DrawLine(PenAdp pen, PointAdp src, PointAdp trg);
|
||||
void DrawRect(PenAdp pen, int x, int y, int width, int height);
|
||||
void DrawRect(PenAdp pen, PointAdp location, SizeAdp size);
|
||||
|
@ -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.gfui; import gplx.*;
|
||||
import gplx.core.interfaces.*;
|
||||
public interface IptBnd extends SrlAble {
|
||||
String Key();
|
||||
List_adp Ipts();
|
||||
|
@ -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.gfui; import gplx.*;
|
||||
import gplx.core.interfaces.*;
|
||||
public class IptBndMgr implements SrlAble {
|
||||
@gplx.Internal protected IptEventType EventsToFwd() {return eventsToFwd;}
|
||||
public void EventsToFwd_set(IptEventType v) {eventsToFwd = v;} IptEventType eventsToFwd = IptEventType_.KeyDown;
|
||||
|
@ -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.gfui; import gplx.*;
|
||||
import gplx.core.interfaces.*;
|
||||
public class IptBnd_chkBox implements InjectAble, GfoEvObj {
|
||||
public GfoEvMgr EvMgr() {if (evMgr == null) evMgr = GfoEvMgr.new_(this); return evMgr;} GfoEvMgr evMgr;
|
||||
public void Inject(Object owner) {
|
||||
|
@ -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.gfui; import gplx.*;
|
||||
import gplx.core.type_xtns.*;
|
||||
import gplx.core.type_xtns.*; import gplx.core.interfaces.*;
|
||||
public class IptBnd_txt_cmd implements InjectAble, GfoInvkAble, GfoEvObj {
|
||||
public GfoEvMgr EvMgr() {if (evMgr == null) evMgr = GfoEvMgr.new_(this); return evMgr;} GfoEvMgr evMgr;
|
||||
public void Inject(Object owner) {
|
||||
|
@ -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.gfui; import gplx.*;
|
||||
import gplx.core.interfaces.*;
|
||||
public class IptBnd_txt_range implements InjectAble, GfoInvkAble, GfoEvObj {
|
||||
public GfoEvMgr EvMgr() {if (evMgr == null) evMgr = GfoEvMgr.new_(this); return evMgr;} GfoEvMgr evMgr;
|
||||
public IptBnd_txt_range InitSrc_(GfoEvObj initSrc) {this.initSrc = initSrc; return this;}
|
||||
|
@ -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.gfui; import gplx.*;
|
||||
import gplx.core.type_xtns.*;
|
||||
import gplx.core.type_xtns.*; import gplx.core.interfaces.*;
|
||||
public class IptBnd_upDownRange implements InjectAble, GfoInvkAble, GfoEvObj {
|
||||
public GfoEvMgr EvMgr() {if (evMgr == null) evMgr = GfoEvMgr.new_(this); return evMgr;} GfoEvMgr evMgr;
|
||||
public void Inject(Object owner) {
|
||||
|
@ -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.gfui; import gplx.*;
|
||||
import gplx.core.bits.*; import gplx.core.primitives.*;
|
||||
public class IptEventType_ {
|
||||
static EnmMgr enmMgr = EnmMgr.new_().BitRngEnd_(128);
|
||||
public static final IptEventType
|
||||
|
@ -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.gfui; import gplx.*;
|
||||
import gplx.core.bits.*;
|
||||
public class IptKey implements IptArg {
|
||||
@gplx.Internal protected IptKey(int val, String key) {this.val = val; this.key = key;}
|
||||
public String Key() {return key;} private final String key;
|
||||
|
@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfui; import gplx.*;
|
||||
import java.awt.event.KeyEvent;
|
||||
import gplx.core.primitives.*; import gplx.core.stores.*;
|
||||
import gplx.core.primitives.*; import gplx.core.stores.*; import gplx.core.bits.*;
|
||||
public class IptKey_ {
|
||||
private static EnmMgr enm_mgr = EnmMgr.new_().BitRngBgn_(65536).BitRngEnd_(262144).Prefix_("key.");
|
||||
public static IptKey[] Ary(IptKey... ary) {return ary;}
|
||||
|
@ -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.gfui; import gplx.*;
|
||||
import gplx.core.interfaces.*;
|
||||
public class GfuiCmdForm implements GfoInvkAble, InjectAble {
|
||||
public void Inject(Object ownerObj) {
|
||||
GfuiElem owner = (GfuiElem)ownerObj;
|
||||
|
@ -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.gfui; import gplx.*;
|
||||
import gplx.core.interfaces.*;
|
||||
class GfuiFocusXferBnd implements InjectAble, GfoInvkAble {
|
||||
public void Inject(Object owner) {
|
||||
GfuiElem elem = GfuiElem_.cast(owner);
|
||||
|
@ -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.gfui; import gplx.*;
|
||||
import gplx.core.lists.*; /*Hash_adp_list*/
|
||||
import gplx.core.lists.*; import gplx.core.bits.*;
|
||||
class GfuiWinKeyCmdMgr implements GfuiWinOpenAble, GfoInvkAble, GfoEvObj {
|
||||
private Hash_adp_list listHash = Hash_adp_list.new_();
|
||||
public GfoEvMgr EvMgr() {if (evMgr == null) evMgr = GfoEvMgr.new_(this); return evMgr;} private GfoEvMgr evMgr;
|
||||
|
@ -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.gfui; import gplx.*;
|
||||
import gplx.core.interfaces.*;
|
||||
public interface GfuiElem extends GfoInvkAble, GxwCbkHost, IptBndsOwner, GftItem, GfoEvObj {
|
||||
//% Layout
|
||||
int X(); GfuiElem X_(int val);
|
||||
|
@ -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.gfui; import gplx.*;
|
||||
import gplx.core.strings.*;
|
||||
import gplx.core.strings.*; import gplx.core.interfaces.*;
|
||||
public class GfuiElemBase implements GfuiElem {
|
||||
//% Layout
|
||||
public GfoEvMgr EvMgr() {if (evMgr == null) evMgr = GfoEvMgr.new_(this); return evMgr;} GfoEvMgr evMgr;
|
||||
|
@ -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.gfui; import gplx.*;
|
||||
import gplx.core.interfaces.*;
|
||||
class GfuiBtnClickBnd implements InjectAble, GfoInvkAble {
|
||||
public void Inject(Object owner) {
|
||||
GfuiElem elem = GfuiElem_.cast(owner);
|
||||
|
@ -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.gfui; import gplx.*;
|
||||
import gplx.core.interfaces.*;
|
||||
public class DataBndr_whenEvt_execCmd implements InjectAble, GfoInvkAble, GfoEvObj {
|
||||
public GfoEvMgr EvMgr() {if (evMgr == null) evMgr = GfoEvMgr.new_(this); return evMgr;} GfoEvMgr evMgr;
|
||||
public DataBndr_whenEvt_execCmd WhenArg_(String v) {whenArg = v; return this;} private String whenArg = "v";
|
||||
|
@ -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.gfui; import gplx.*;
|
||||
import gplx.core.interfaces.*;
|
||||
public class GfuiMoveElemBnd implements IptBnd, GfoInvkAble, InjectAble {
|
||||
public String Key() {return "gplx.gfui.moveWidget";}
|
||||
public List_adp Ipts() {return args;} List_adp args = List_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.gfui; import gplx.*;
|
||||
import gplx.core.interfaces.*;
|
||||
public class GfuiStatusBarBnd implements InjectAble {
|
||||
public GfuiStatusBar Bar() {return statusBar;} GfuiStatusBar statusBar = GfuiStatusBar.new_();
|
||||
public void Inject(Object owner) {
|
||||
|
@ -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.gfui; import gplx.*;
|
||||
import gplx.core.interfaces.*;
|
||||
class TabBoxEvt_nameChange {
|
||||
public static String Key = "TabBoxEvt_nameChange";
|
||||
public static void Send(TabBoxMgr mgr, TabPnlItm itm) {
|
||||
|
@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfui; import gplx.*;
|
||||
import java.awt.Image;
|
||||
public interface ImageAdp extends RlsAble {
|
||||
public interface ImageAdp extends Rls_able {
|
||||
Gfui_kit Kit();
|
||||
SizeAdp Size();
|
||||
int Width();
|
||||
|
@ -24,7 +24,7 @@ import java.awt.image.RenderedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import javax.imageio.ImageIO;
|
||||
public class ImageAdp_base implements ImageAdp, RlsAble {
|
||||
public class ImageAdp_base implements ImageAdp, Rls_able {
|
||||
@gplx.Internal protected ImageAdp_base(Image img) {this.under = img;}
|
||||
public Gfui_kit Kit() {return kit;} public void Kit_(Gfui_kit v) {this.kit = v;} Gfui_kit kit;
|
||||
public SizeAdp Size() {
|
||||
|
@ -19,7 +19,7 @@ package gplx.gfui; import gplx.*;
|
||||
import javax.swing.Timer;
|
||||
import java.awt.event.ActionListener;
|
||||
import gplx.core.envs.*;
|
||||
public class TimerAdp implements RlsAble {
|
||||
public class TimerAdp implements Rls_able {
|
||||
public TimerAdp Interval_(int interval) {
|
||||
underTimer.setInitialDelay(interval);
|
||||
underTimer.setDelay(interval);
|
||||
|
@ -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.gfui; import gplx.*;
|
||||
public interface GfuiInvkCmd extends GfoInvkAble, RlsAble {
|
||||
public interface GfuiInvkCmd extends GfoInvkAble, Rls_able {
|
||||
}
|
||||
class GfuiInvkCmd_ {
|
||||
public static final String Invk_sync = "Sync";
|
||||
|
@ -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.gfui; import gplx.*;
|
||||
public interface Gfui_clipboard extends GfoInvkAble, RlsAble {
|
||||
public interface Gfui_clipboard extends GfoInvkAble, Rls_able {
|
||||
void Copy(String s);
|
||||
}
|
||||
class Gfui_clipboard_null implements Gfui_clipboard {
|
||||
|
@ -16,7 +16,6 @@ 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.gfui;
|
||||
import gplx.Bitmask_;
|
||||
import gplx.Byte_ascii;
|
||||
import gplx.Enm_;
|
||||
import gplx.GfoEvMgr_;
|
||||
@ -25,6 +24,7 @@ import gplx.GfoMsg_;
|
||||
import gplx.GfsCtx;
|
||||
import gplx.String_;
|
||||
import gplx.Tfds;
|
||||
import gplx.core.bits.Bitmask_;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.KeyEvent;
|
||||
|
52
400_xowa/src/gplx/core/brys/Bry_diff_.java
Normal file
52
400_xowa/src/gplx/core/brys/Bry_diff_.java
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
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_diff_ {
|
||||
public static byte[][] Diff_1st_line(byte[] lhs, byte[] rhs) {return Diff_1st(lhs, 0, lhs.length, rhs, 0, rhs.length, Byte_ascii.Nl_bry, Byte_ascii.Angle_bgn_bry, 255);}
|
||||
public static byte[][] Diff_1st(byte[] lhs, int lhs_bgn, int lhs_end, byte[] rhs, int rhs_bgn, int rhs_end, byte[] stop, byte[] show, int diff_max) {
|
||||
int lhs_len = lhs_end - lhs_bgn;
|
||||
int rhs_len = rhs_end - rhs_bgn;
|
||||
int len = lhs_len < rhs_len ? lhs_len : rhs_len;
|
||||
int lhs_idx = -1, rhs_idx = -1;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
byte lhs_byte = lhs[i + lhs_bgn];
|
||||
byte rhs_byte = rhs[i + rhs_bgn];
|
||||
if (lhs_byte != rhs_byte) {lhs_idx = rhs_idx = i; break;} // diff; stop iterating
|
||||
}
|
||||
if (lhs_idx == -1 && rhs_idx == -1) {
|
||||
switch (Int_.Compare(lhs_len, rhs_len)) {
|
||||
case CompareAble_.Same: return null;
|
||||
case CompareAble_.Less: lhs_idx = rhs_idx = lhs_len; break;
|
||||
case CompareAble_.More: lhs_idx = rhs_idx = rhs_len; break;
|
||||
}
|
||||
}
|
||||
byte[] lhs_diff = Get_1st(stop, show, lhs, lhs_idx, lhs_len, diff_max);
|
||||
byte[] rhs_diff = Get_1st(stop, show, rhs, rhs_idx, rhs_len, diff_max);
|
||||
return new byte[][] {lhs_diff, rhs_diff};
|
||||
}
|
||||
private static byte[] Get_1st(byte[] stop, byte[] show, byte[] src, int bgn, int end, int diff_max) {
|
||||
if (bgn == end) return Bry__eos;
|
||||
int prv_show = Bry_find_.Find_bwd(src, show, bgn , 0); if (prv_show == Bry_find_.Not_found) prv_show = 0;
|
||||
int prv_stop = Bry_find_.Find_bwd(src, stop, bgn , 0); prv_stop = (prv_stop == Bry_find_.Not_found) ? 0 : prv_stop + 1;
|
||||
int prv = prv_show > prv_stop ? prv_show : prv_stop;
|
||||
int nxt = Bry_find_.Find_fwd(src, stop, bgn , end); if (nxt == Bry_find_.Not_found) nxt = end;
|
||||
if (nxt - prv > 255) nxt = prv + diff_max;
|
||||
return Bry_.Mid(src, prv, nxt);
|
||||
}
|
||||
private static final byte[] Bry__eos = Bry_.new_a7("<<EOS>>");
|
||||
}
|
44
400_xowa/src/gplx/core/brys/Bry_diff_tst.java
Normal file
44
400_xowa/src/gplx/core/brys/Bry_diff_tst.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.*;
|
||||
import org.junit.*;
|
||||
public class Bry_diff_tst {
|
||||
@Before public void init() {} private final Bry_diff_fxt fxt = new Bry_diff_fxt();
|
||||
@Test public void Diff_1st() {
|
||||
fxt.Test__diff_1st("a|b|c" , "a|b|c" , null , null);
|
||||
fxt.Test__diff_1st("a|b|c" , "a|b1|c" , "b" , "b1");
|
||||
fxt.Test__diff_1st("a|b|" , "a|b|c" , "<<EOS>>" , "c");
|
||||
fxt.Test__diff_1st("a|b|c" , "a|b|" , "c" , "<<EOS>>");
|
||||
}
|
||||
@Test public void Diff_1st_show() {
|
||||
fxt.Test__diff_1st("a|b<c>d|e" , "a|b<c>e|e" , "<c>d", "<c>e");
|
||||
}
|
||||
}
|
||||
class Bry_diff_fxt {
|
||||
public void Test__diff_1st(String lhs, String rhs, String expd_lhs, String expd_rhs) {
|
||||
byte[] lhs_src = Bry_.new_u8(lhs);
|
||||
byte[] rhs_src = Bry_.new_u8(rhs);
|
||||
byte[][] actl = Bry_diff_.Diff_1st(lhs_src, 0, lhs_src.length, rhs_src, 0, rhs_src.length, Byte_ascii.Pipe_bry, Byte_ascii.Angle_bgn_bry, 255);
|
||||
if (expd_lhs == null && expd_rhs == null)
|
||||
Tfds.Eq_true(actl == null, "actl not null");
|
||||
else {
|
||||
Tfds.Eq_bry(Bry_.new_u8(expd_lhs), actl[0]);
|
||||
Tfds.Eq_bry(Bry_.new_u8(expd_rhs), actl[1]);
|
||||
}
|
||||
}
|
||||
}
|
47
400_xowa/src/gplx/core/brys/Bry_err_wkr.java
Normal file
47
400_xowa/src/gplx/core/brys/Bry_err_wkr.java
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
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 gplx.core.errs.*;
|
||||
public class Bry_err_wkr {
|
||||
private String sect; private int sect_bgn;
|
||||
public byte[] Src() {return src;} private byte[] src;
|
||||
public String Page() {return page;} private String page;
|
||||
public void Fail_throws_err_(boolean v) {this.fail_throws_err = v;} private boolean fail_throws_err = true;
|
||||
public void Init_by_page(String page, byte[] src) {this.page = page; this.src = src;}
|
||||
public void Init_by_sect(String sect, int sect_bgn) {this.sect = sect; this.sect_bgn = sect_bgn;}
|
||||
public int Fail(String msg, Object... args) {return Fail(msg, sect_bgn, sect_bgn + 255, args);}
|
||||
private int Fail(String msg, int excerpt_bgn, int excerpt_end, Object[] args) {
|
||||
String err_msg = Make_msg(msg, excerpt_bgn, excerpt_end, args);
|
||||
Gfo_usr_dlg_.Instance.Warn_many("", "", err_msg);
|
||||
if (fail_throws_err) throw Err_.new_("Bry_err_wkr", err_msg).Logged_y_();
|
||||
return Bry_find_.Not_found;
|
||||
}
|
||||
private String Make_msg(String msg, int excerpt_bgn, int excerpt_end, Object[] args) {
|
||||
int args_len = args.length;
|
||||
args_len += 6;
|
||||
args = (Object[])Array_.Resize(args, args_len);
|
||||
args[args_len - 6] = "page"; args[args_len - 5] = Quote(page);
|
||||
args[args_len - 4] = "sect"; args[args_len - 3] = Quote(sect);
|
||||
args[args_len - 2] = "text"; args[args_len - 1] = Bry_.Escape_ws(Bry_.Mid_safe(src, excerpt_bgn, excerpt_end));
|
||||
for (int i = 0; i < args_len - 6; i += 2) {
|
||||
args[i + 1] = Quote(Object_.Xto_str_strict_or_null_mark(args[i + 1]));
|
||||
}
|
||||
return Err_msg.To_str(msg, args);
|
||||
}
|
||||
private static String Quote(String v) {return "'" + v + "'";}
|
||||
}
|
@ -19,18 +19,20 @@ 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;
|
||||
public byte[] Src() {return src;} private byte[] src;
|
||||
public int Pos() {return pos;} private int pos;
|
||||
public int Src_end() {return src_end;} private int src_end;
|
||||
public Bry_rdr Dflt_dlm_(byte b) {this.dflt_dlm = b; return this;} private byte dflt_dlm;
|
||||
public Bry_rdr Fail_throws_err_(boolean v) {this.fail_throws_err = v; return this;} private boolean fail_throws_err = true;
|
||||
public Bry_rdr Init_by_page(byte[] ctx, byte[] src, int src_len) {this.ctx = Quote(String_.new_u8(ctx)); this.src = src; this.src_end = src_len; this.pos = 0; return this;}
|
||||
public Bry_rdr Init_by_hook(String wkr, int err_bgn, int pos) {this.wkr = Quote(wkr); this.err_bgn = err_bgn; this.pos = pos; return this;}
|
||||
public Bry_rdr Init_by_sub(Bry_rdr rdr, String wkr, int pos, int src_end) {
|
||||
this.src = rdr.src; this.ctx = rdr.ctx; this.wkr = Quote(wkr); this.err_bgn = pos; this.pos = pos; this.src_end = src_end;
|
||||
public Bry_rdr Fail_throws_err_(boolean v) {err_wkr.Fail_throws_err_(v); return this;}
|
||||
public Bry_rdr Init_by_page(byte[] page, byte[] src, int src_len) {err_wkr.Init_by_page(String_.new_u8(page), src); this.pos = 0; this.src = src; this.src_end = src_len; return this;}
|
||||
public Bry_rdr Init_by_sect(String sect, int sect_bgn, int pos) {err_wkr.Init_by_sect(sect, sect_bgn); this.pos = pos; return this;}
|
||||
public Bry_rdr Init_by_wkr (Bry_err_wkr wkr, String sect, int pos, int src_end) {
|
||||
this.pos = pos; this.src = wkr.Src(); this.src_end = src_end;
|
||||
err_wkr.Init_by_page(wkr.Page(), src);
|
||||
err_wkr.Init_by_sect(sect, pos);
|
||||
return this;
|
||||
}
|
||||
public Bry_err_wkr Err_wkr() {return err_wkr;} private Bry_err_wkr err_wkr = new Bry_err_wkr();
|
||||
public int Move_to(int v) {this.pos = v; return pos;}
|
||||
public int Move_by_one() {return Move_by(1);}
|
||||
public int Move_by(int v) {this.pos += v; return pos;}
|
||||
@ -41,12 +43,12 @@ public class Bry_rdr {
|
||||
public int Find_fwd_rr(byte find) {return Find_fwd(find , Bool_.N, Bool_.N);}
|
||||
public int Find_fwd_rr(byte[] find) {return Find_fwd(find , Bool_.N, Bool_.N);}
|
||||
private int Find_fwd(byte find, boolean ret_lhs, boolean pos_lhs) {
|
||||
int find_pos = Bry_find_.Find_fwd(src, find, pos, src_end); if (find_pos == Bry_find_.Not_found) {Fail("find failed", "find", Byte_ascii.To_str(find)); return Bry_find_.Not_found;}
|
||||
int find_pos = Bry_find_.Find_fwd(src, find, pos, src_end); if (find_pos == Bry_find_.Not_found) {err_wkr.Fail("find failed", "find", Byte_ascii.To_str(find)); return Bry_find_.Not_found;}
|
||||
pos = find_pos + (pos_lhs ? 0 : 1);
|
||||
return ret_lhs ? find_pos : pos;
|
||||
}
|
||||
private int Find_fwd(byte[] find, boolean ret_lhs, boolean pos_lhs) {
|
||||
int find_pos = Bry_find_.Find_fwd(src, find, pos, src_end); if (find_pos == Bry_find_.Not_found) {Fail("find failed", "find", String_.new_u8(find)); return Bry_find_.Not_found;}
|
||||
int find_pos = Bry_find_.Find_fwd(src, find, pos, src_end); if (find_pos == Bry_find_.Not_found) {err_wkr.Fail("find failed", "find", String_.new_u8(find)); return Bry_find_.Not_found;}
|
||||
pos = find_pos + (pos_lhs ? 0 : find.length);
|
||||
return ret_lhs ? find_pos : pos;
|
||||
}
|
||||
@ -60,7 +62,7 @@ public class Bry_rdr {
|
||||
byte rv = src[pos];
|
||||
++pos;
|
||||
if (pos < src_end) {
|
||||
if (src[pos] != to_char) {Fail("read byte to failed", "to", Byte_ascii.To_str(to_char)); return Byte_.Max_value_127;}
|
||||
if (src[pos] != to_char) {err_wkr.Fail("read byte to failed", "to", Byte_ascii.To_str(to_char)); return Byte_.Max_value_127;}
|
||||
++pos;
|
||||
}
|
||||
return rv;
|
||||
@ -84,7 +86,7 @@ public class Bry_rdr {
|
||||
break;
|
||||
case Byte_ascii.Dash:
|
||||
if (negative == -1) { // 2nd negative
|
||||
Fail("invalid int", "mid", String_.new_u8(src, bgn, pos));
|
||||
err_wkr.Fail("invalid int", "mid", String_.new_u8(src, bgn, pos));
|
||||
return Int_.Min_value;
|
||||
}
|
||||
else // 1st negative
|
||||
@ -97,14 +99,14 @@ public class Bry_rdr {
|
||||
match = true;
|
||||
}
|
||||
if (!match) {
|
||||
Fail("invalid int", "mid", String_.new_u8(src, bgn, pos));
|
||||
err_wkr.Fail("invalid int", "mid", String_.new_u8(src, bgn, pos));
|
||||
return Int_.Min_value;
|
||||
}
|
||||
return rv * negative;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (bgn == pos) {Fail("int is empty", String_.Empty, String_.Empty); return Int_.Min_value;}
|
||||
if (bgn == pos) {err_wkr.Fail("int is empty"); return Int_.Min_value;}
|
||||
return rv * negative;
|
||||
}
|
||||
public byte Read_byte_as_a7_int() {
|
||||
@ -135,13 +137,13 @@ public class Bry_rdr {
|
||||
return rv;
|
||||
}
|
||||
public int Chk(byte find) {
|
||||
if (src[pos] != find) {Fail("failed check", "chk", Byte_.To_str(find)); return Bry_find_.Not_found;}
|
||||
if (src[pos] != find) {err_wkr.Fail("failed check", "chk", Byte_.To_str(find)); return Bry_find_.Not_found;}
|
||||
++pos;
|
||||
return pos;
|
||||
}
|
||||
public int Chk(byte[] find) {
|
||||
int find_end = pos + find.length;
|
||||
if (!Bry_.Match(src, pos, find_end, find)) {Fail("failed check", "chk", String_.new_u8(find)); return Bry_find_.Not_found;}
|
||||
if (!Bry_.Match(src, pos, find_end, find)) {err_wkr.Fail("failed check", "chk", String_.new_u8(find)); return Bry_find_.Not_found;}
|
||||
pos = find_end;
|
||||
return pos;
|
||||
}
|
||||
@ -149,7 +151,7 @@ public class Bry_rdr {
|
||||
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;}
|
||||
if (rv == Byte_.Max_value_127) {err_wkr.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) {
|
||||
@ -158,20 +160,4 @@ public class Bry_rdr {
|
||||
pos = trie.Match_pos();
|
||||
return ((gplx.core.primitives.Byte_obj_val)rv_obj).Val();
|
||||
}
|
||||
public int Fail(String msg, String arg_key, Object arg_val) {return Fail(msg, arg_key, arg_val, err_bgn, err_bgn + 255);}
|
||||
public int Fail(String msg, String arg_key, Object arg_val, int excerpt_bgn, int excerpt_end) {
|
||||
arg_val = Quote(Object_.Xto_str_strict_or_null_mark(arg_val));
|
||||
String err_msg = Msg_make(msg, arg_key, arg_val, excerpt_bgn, excerpt_end);
|
||||
Gfo_usr_dlg_.Instance.Warn_many("", "", err_msg);
|
||||
if (fail_throws_err) throw Err_.new_("Bry_rdr", err_msg).Logged_y_();
|
||||
return Bry_find_.Not_found;
|
||||
}
|
||||
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 Err_msg.To_str(msg, "ctx", ctx, "wkr", wkr, "excerpt", Bry_.Escape_ws(Bry_.Mid_safe(src, excerpt_bgn, excerpt_end)));
|
||||
else
|
||||
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 + "'";}
|
||||
}
|
||||
|
@ -24,9 +24,12 @@ public class Int_flag_bldr {
|
||||
this.val_ary = new int[pow_ary.length];
|
||||
return this;
|
||||
}
|
||||
public Int_flag_bldr Set(int idx, int val) {val_ary[idx] = val; return this;}
|
||||
public Int_flag_bldr Set(int idx, byte val) {val_ary[idx] = val; return this;}
|
||||
public Int_flag_bldr Set(int idx, boolean val) {val_ary[idx] = val ? 1 : 0; return this;}
|
||||
public boolean Set_as_bool(int idx, boolean val) {val_ary[idx] = val ? 1 : 0; return val;}
|
||||
public byte Set_as_byte(int idx, byte val) {val_ary[idx] = val; return val;}
|
||||
public int Set_as_int(int idx, int val) {val_ary[idx] = val; return val;}
|
||||
public Int_flag_bldr Set(int idx, boolean val) {Set_as_bool(idx, val); return this;}
|
||||
public Int_flag_bldr Set(int idx, byte val) {Set_as_byte(idx, val); return this;}
|
||||
public Int_flag_bldr Set(int idx, int val) {Set_as_int(idx, val); return this;}
|
||||
public int Get_as_int(int idx) {return val_ary[idx];}
|
||||
public byte Get_as_byte(int idx) {return (byte)val_ary[idx];}
|
||||
public boolean Get_as_bool(int idx) {return val_ary[idx] == 1;}
|
||||
|
@ -59,7 +59,7 @@ class GfoCacheMgr_fxt {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class GfoCacheItm_mock implements RlsAble {
|
||||
class GfoCacheItm_mock implements Rls_able {
|
||||
public void Rls() {}
|
||||
public String S() {return s;} private String s;
|
||||
public GfoCacheItm_mock(String s) {this.s = s;}
|
||||
|
@ -44,7 +44,7 @@ public class Gfo_cache_mgr {
|
||||
hash.Del(itm.Key());
|
||||
itm.Rls();
|
||||
}
|
||||
public void Add_replace(byte[] key, RlsAble val, int size) {
|
||||
public void Add_replace(byte[] key, Rls_able val, int size) {
|
||||
// Del(key);
|
||||
// Add(key, val, size);
|
||||
Object o = hash.Get_by(key);
|
||||
@ -57,7 +57,7 @@ public class Gfo_cache_mgr {
|
||||
itm.Replace(val, size);
|
||||
}
|
||||
}
|
||||
public void Add(byte[] key, RlsAble val, int size) {
|
||||
public void Add(byte[] key, Rls_able val, int size) {
|
||||
// if (cur_size + size > 600000000) ReduceCache();
|
||||
cur_size += size;
|
||||
// ++cur_size;
|
||||
@ -104,12 +104,12 @@ public class Gfo_cache_mgr {
|
||||
}
|
||||
}
|
||||
}
|
||||
class Gfo_cache_data implements gplx.CompareAble, RlsAble {
|
||||
public Gfo_cache_data(byte[] key, RlsAble val, int size) {this.key = key; this.val = val; this.size = size; this.timestamp = Env_.TickCount();}
|
||||
class Gfo_cache_data implements gplx.CompareAble, Rls_able {
|
||||
public Gfo_cache_data(byte[] key, Rls_able val, int size) {this.key = key; this.val = val; this.size = size; this.timestamp = Env_.TickCount();}
|
||||
public byte[] Key() {return key;} private byte[] key;
|
||||
public RlsAble Val() {return val;} private RlsAble val;
|
||||
public Rls_able Val() {return val;} private Rls_able val;
|
||||
public int Size() {return size;} private int size;
|
||||
public void Replace(RlsAble val, int size) {this.val = val; this.size = size;}
|
||||
public void Replace(Rls_able val, int size) {this.val = val; this.size = size;}
|
||||
public long Timestamp() {return timestamp;} public void Timestamp_update() {timestamp = Env_.TickCount();} private long timestamp;
|
||||
public int compareTo(Object obj) {
|
||||
Gfo_cache_data comp = (Gfo_cache_data)obj;
|
||||
|
@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.core.ios; import gplx.*; import gplx.core.*;
|
||||
import gplx.core.ios.*;/*IoStream*/
|
||||
public class Io_buffer_rdr implements RlsAble {
|
||||
public class Io_buffer_rdr implements Rls_able {
|
||||
private Io_stream_rdr rdr;
|
||||
Io_buffer_rdr(Io_stream_rdr rdr, Io_url url, int bfr_len) {
|
||||
this.rdr = rdr; this.url = url;
|
||||
|
@ -45,12 +45,12 @@ public class Gfo_url_parser {
|
||||
rel = true;
|
||||
}
|
||||
if (!rel) { // search for ":"; NOTE: only search if not rel; i.e.: "//"
|
||||
int colon_pos = Bry_find_.Find_fwd(src, Byte_ascii.Colon, pos, src_end); // no colon found; EX: "//a.org/b"; "a.org/b"
|
||||
int colon_pos = Bry_find_.Find_fwd(src, Byte_ascii.Colon, pos, src_end); // no colon found; EX: "//a.org/b"; "a.org/b"
|
||||
if (colon_pos != Bry_find_.Not_found) // colon found; EX: "http://" or "https://"
|
||||
pos = colon_pos + Int_.Const_dlm_len;
|
||||
if (pos < src_end && src[pos] == Byte_ascii.Slash) { // skip slash after colon
|
||||
if (pos < src_end && src[pos] == Byte_ascii.Slash) { // skip slash after colon
|
||||
pos += 1;
|
||||
if (pos < src_end && src[pos] == Byte_ascii.Slash) // skip 2nd slash after colon
|
||||
if (pos < src_end && src[pos] == Byte_ascii.Slash) // skip 2nd slash after colon
|
||||
pos += 1;
|
||||
}
|
||||
}
|
||||
|
@ -17,8 +17,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.core.threads.poolables; import gplx.*; import gplx.core.*; import gplx.core.threads.*;
|
||||
public interface Gfo_poolable_itm {
|
||||
int Pool__idx();
|
||||
void Pool__clear (Object[] args);
|
||||
Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args);
|
||||
void Pool__rls();
|
||||
}
|
||||
|
@ -18,10 +18,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.core.threads.poolables; import gplx.*; import gplx.core.*; import gplx.core.threads.*;
|
||||
public class Gfo_poolable_mgr {
|
||||
private final Object thread_lock = new Object();
|
||||
private final Gfo_poolable_itm prototype; private final Object[] make_args, clear_args;
|
||||
private final Gfo_poolable_itm prototype; private final Object[] make_args;
|
||||
private Gfo_poolable_itm[] pool; private int pool_nxt, pool_len;
|
||||
public Gfo_poolable_mgr(Gfo_poolable_itm prototype, Object[] make_args, Object[] clear_args, int init_pool_len, int pool_max) {// NOTE: random IndexOutOfBounds errors in Get around free_ary[--free_len] with free_len being -1; put member variable initialization within thread_lock to try to avoid; DATE:2014-09-21
|
||||
this.prototype = prototype; this.make_args = make_args; this.clear_args = clear_args;
|
||||
public Gfo_poolable_mgr(Gfo_poolable_itm prototype, Object[] make_args, int init_pool_len, int pool_max) {// NOTE: random IndexOutOfBounds errors in Get around free_ary[--free_len] with free_len being -1; put member variable initialization within thread_lock to try to avoid; DATE:2014-09-21
|
||||
this.prototype = prototype; this.make_args = make_args;
|
||||
this.pool_len = init_pool_len;
|
||||
this.Clear_fast();
|
||||
}
|
||||
@ -51,7 +51,6 @@ public class Gfo_poolable_mgr {
|
||||
pool[pool_idx] = rv;
|
||||
}
|
||||
}
|
||||
rv.Pool__clear(clear_args); // 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
|
||||
return rv;
|
||||
}
|
||||
public void Rls_safe(int idx) {synchronized (thread_lock) {Rls_safe(idx);}}
|
||||
|
@ -17,5 +17,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.core.threads.poolables; import gplx.*; import gplx.core.*; import gplx.core.threads.*;
|
||||
public class Gfo_poolable_mgr_ {
|
||||
public static Gfo_poolable_mgr New(int len, int max, Gfo_poolable_itm prototype) {return new Gfo_poolable_mgr(prototype, Object_.Ary_empty, Object_.Ary_empty, len, max);}
|
||||
public static Gfo_poolable_mgr New(int len, int max, Gfo_poolable_itm prototype) {return new Gfo_poolable_mgr(prototype, Object_.Ary_empty, len, max);}
|
||||
public static Gfo_poolable_mgr New(int len, int max, Gfo_poolable_itm prototype, Object[] make_args) {return new Gfo_poolable_mgr(prototype, make_args, len, max);}
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ public class Gfo_poolable_mgr_tst {
|
||||
}
|
||||
}
|
||||
class Gfo_poolable_mgr_tstr {
|
||||
private final Gfo_poolable_mgr mgr = new Gfo_poolable_mgr(new Sample_poolable_itm(null, -1, Object_.Ary_empty), Object_.Ary("make"), Object_.Ary("clear"), 2, 8);
|
||||
private final Gfo_poolable_mgr mgr = new Gfo_poolable_mgr(new Sample_poolable_itm(null, -1, Object_.Ary_empty), Object_.Ary("make"), 2, 8);
|
||||
public void Clear() {mgr.Clear_fast();}
|
||||
public void Test__get(int expd_idx) {
|
||||
Sample_poolable_itm actl_itm = (Sample_poolable_itm)mgr.Get_fast();
|
||||
@ -78,8 +78,6 @@ class Sample_poolable_itm implements Gfo_poolable_itm {
|
||||
public Sample_poolable_itm(Gfo_poolable_mgr pool_mgr, int pool_idx, Object[] make_args) {this.pool_mgr = pool_mgr; this.pool_idx = pool_idx; this.pool__make_args = make_args;}
|
||||
public int Pool__idx() {return pool_idx;} private final int pool_idx;
|
||||
public Object[] Pool__make_args() {return pool__make_args;} private final Object[] pool__make_args;
|
||||
public Object[] Pool__clear_args() {return pool__clear_args;} private Object[] pool__clear_args;
|
||||
public void Pool__clear (Object[] args) {this.pool__clear_args = args;}
|
||||
public void Pool__rls() {pool_mgr.Rls_safe(pool_idx);}
|
||||
public Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args) {return new Sample_poolable_itm(pool_mgr, idx, args);}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.dbs.cfgs; import gplx.*; import gplx.dbs.*;
|
||||
import gplx.core.primitives.*;
|
||||
public class Db_cfg_tbl implements RlsAble {
|
||||
public class Db_cfg_tbl implements Rls_able {
|
||||
private final String tbl_name; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
|
||||
private final String fld_grp, fld_key, fld_val;
|
||||
private Db_stmt stmt_insert, stmt_update, stmt_select;
|
||||
|
@ -19,7 +19,7 @@ package gplx.fsdb.data; import gplx.*; import gplx.fsdb.*;
|
||||
import gplx.core.primitives.*; import gplx.core.envs.*;
|
||||
import gplx.dbs.*; import gplx.core.ios.*;
|
||||
import gplx.dbs.engines.sqlite.*;
|
||||
public class Fsd_bin_tbl implements RlsAble {
|
||||
public class Fsd_bin_tbl implements Rls_able {
|
||||
private final String tbl_name = "fsdb_bin"; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
|
||||
private final String fld_owner_id, fld_owner_tid, fld_part_id, fld_data_url, fld_data;
|
||||
private Db_conn conn; private Db_stmt stmt_insert, stmt_select; private Bry_bfr tmp_bfr;
|
||||
|
@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.fsdb.data; import gplx.*; import gplx.fsdb.*;
|
||||
import gplx.dbs.*;
|
||||
public class Fsd_dir_tbl implements RlsAble {
|
||||
public class Fsd_dir_tbl implements Rls_able {
|
||||
private final String tbl_name = "fsdb_dir"; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
|
||||
private final String fld_id, fld_owner_id, fld_name;
|
||||
private final Db_conn conn; private Db_stmt stmt_insert, stmt_update, stmt_select_by_name;
|
||||
|
@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.fsdb.data; import gplx.*; import gplx.fsdb.*;
|
||||
import gplx.dbs.*; import gplx.dbs.qrys.*; import gplx.dbs.engines.sqlite.*;
|
||||
public class Fsd_fil_tbl implements RlsAble {
|
||||
public class Fsd_fil_tbl implements Rls_able {
|
||||
private final String tbl_name = "fsdb_fil"; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
|
||||
private final String fld_id, fld_owner_id, fld_name, fld_xtn_id, fld_ext_id, fld_size, fld_modified, fld_hash, fld_bin_db_id;
|
||||
private final String idx_owner;
|
||||
|
@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.fsdb.data; import gplx.*; import gplx.fsdb.*;
|
||||
import gplx.dbs.*; import gplx.fsdb.meta.*; import gplx.xowa.files.*;
|
||||
public class Fsd_thm_tbl implements RlsAble {
|
||||
public class Fsd_thm_tbl implements Rls_able {
|
||||
private final String tbl_name; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
|
||||
private final String fld_id, fld_owner_id, fld_w, fld_h, fld_time, fld_page, fld_bin_db_id, fld_size, fld_modified, fld_hash;
|
||||
private final Db_conn conn; private Db_stmt stmt_insert, stmt_select_by_fil_exact, stmt_select_by_fil_near; private int mnt_id; private boolean schema_thm_page;
|
||||
|
@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.fsdb.meta; import gplx.*; import gplx.fsdb.*;
|
||||
import gplx.dbs.*;
|
||||
public class Fsm_mnt_tbl implements RlsAble {
|
||||
public class Fsm_mnt_tbl implements Rls_able {
|
||||
private final String tbl_name = "fsdb_mnt"; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
|
||||
private final String fld_id, fld_name, fld_url;
|
||||
private final Db_conn conn;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user