1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00

v2.12.1.1

This commit is contained in:
gnosygnu
2015-12-06 23:12:52 -05:00
parent 097e6c7f80
commit 9509363f46
337 changed files with 3473 additions and 1917 deletions

View File

@@ -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"/>

View File

@@ -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;
}
}

View File

@@ -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];
}

View File

@@ -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}
;
}

View File

@@ -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;

View File

@@ -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");

View File

@@ -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;

View File

@@ -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);

View File

@@ -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();
}

View File

@@ -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() {}
}

View File

@@ -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);}}

View File

@@ -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) {

View File

@@ -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) {

View 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;
}
}

View 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));
}
}

View File

@@ -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;

View File

@@ -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_();

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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;}

View File

@@ -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() {

View File

@@ -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);}

View File

@@ -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();

View File

@@ -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);

View File

@@ -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);

View File

@@ -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 = "+";

View File

@@ -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() {

View File

@@ -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();

View File

@@ -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) {

View File

@@ -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();

View File

@@ -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);

View File

@@ -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() {

View File

@@ -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");
}

View File

@@ -15,7 +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 ParseAble_ {
public static final ParseAble Null = null;
package gplx.langs.htmls; import gplx.*; import gplx.langs.*;
public interface Url_encoder_interface {
String Encode_str(String v);
byte[] Encode_bry(String v);
}

View File

@@ -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() {}

View File

@@ -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();

View File

@@ -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);