mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
v2.7.3.2
This commit is contained in:
parent
8e041d6e06
commit
99f9c3ccea
@ -27,6 +27,10 @@ public class Hash_adp_bry extends gplx.lists.Hash_adp_base implements Hash_adp {
|
||||
@Override protected Object Fetch_base(Object key) {return super.Fetch_base(key_ref.Init((byte[])key));}
|
||||
@Override protected void Del_base(Object key) {super.Del_base(key_ref.Init((byte[])key));}
|
||||
@Override protected boolean Has_base(Object key) {return super.Has_base(key_ref.Init((byte[])key));}
|
||||
public int Get_as_int(byte[] key) {
|
||||
Object o = Get_by_bry(key); if (key == null) throw Err_.new_("core", "unknown key", "key", key);
|
||||
return ((Int_obj_val)o).Val();
|
||||
}
|
||||
public Object Get_by_bry(byte[] src) {return super.Fetch_base(key_ref.Init(src));}
|
||||
public Object Get_by_mid(byte[] src, int bgn, int end) {return super.Fetch_base(key_ref.Init(src, bgn, end));}
|
||||
public Hash_adp_bry Add_bry_byte(byte[] key, byte val) {this.Add_base(key, Byte_obj_val.new_(val)); return this;}
|
||||
|
@ -16,15 +16,19 @@ 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.json; import gplx.*; import gplx.core.*;
|
||||
public class Json_itm_ary extends Json_itm_base implements Json_grp {
|
||||
public Json_itm_ary(int src_bgn, int src_end) {this.Ctor(src_bgn, src_end);}
|
||||
public class Json_ary extends Json_itm_base implements Json_grp {
|
||||
public Json_ary(int src_bgn, int src_end) {this.Ctor(src_bgn, src_end);}
|
||||
@Override public byte Tid() {return Json_itm_.Tid_array;}
|
||||
public void Src_end_(int v) {this.src_end = v;}
|
||||
@Override public Object Data() {return null;}
|
||||
@Override public byte[] Data_bry() {return null;}
|
||||
public int Len() {return subs_len;} private int subs_len = 0, subs_max = 0;
|
||||
public Json_nde Get_at_as_nde(int i) {
|
||||
Json_itm rv = subs[i]; if (rv.Tid() != Json_itm_.Tid_nde) throw Err_.new_("json", "itm is not nde", "type", rv.Tid(), "i", i);
|
||||
return (Json_nde)rv;
|
||||
}
|
||||
public Json_itm Get_at(int i) {return subs[i];}
|
||||
public Json_itm_ary Add_many(Json_itm... ary) {
|
||||
public Json_ary Add_many(Json_itm... ary) {
|
||||
int len = ary.length;
|
||||
for (int i = 0; i < len; i++)
|
||||
Add(ary[i]);
|
||||
@ -67,5 +71,9 @@ public class Json_itm_ary extends Json_itm_base implements Json_grp {
|
||||
return rv;
|
||||
}
|
||||
private Json_itm[] subs = Json_itm_.Ary_empty;
|
||||
public static Json_itm_ary cast_(Json_itm v) {return v == null || v.Tid() != Json_itm_.Tid_array ? null : (Json_itm_ary)v;}
|
||||
public static Json_ary cast_or_null(Json_itm v) {return v == null || v.Tid() != Json_itm_.Tid_array ? null : (Json_ary)v;}
|
||||
public static Json_ary cast(Json_itm v) {
|
||||
if (v == null || v.Tid() != Json_itm_.Tid_array) throw Err_.new_("json", "itm is not array");
|
||||
return (Json_ary)v;
|
||||
}
|
||||
}
|
@ -50,7 +50,7 @@ public class Json_doc {
|
||||
byte[] path = paths[paths_idx];
|
||||
int subs_len = owner.Len();
|
||||
for (int i = 0; i < subs_len; i++) {
|
||||
Json_itm_kv itm = Json_itm_kv.cast_(owner.Get_at(i)); if (itm == null) continue; // ignore simple props, arrays, ndes
|
||||
Json_kv itm = Json_kv.cast_(owner.Get_at(i)); if (itm == null) continue; // ignore simple props, arrays, ndes
|
||||
if (!itm.Key_eq(path)) continue;
|
||||
if (paths_idx == paths_last) return itm.Val();
|
||||
Json_nde sub_nde = Json_nde.cast_(itm.Val()); if (sub_nde == null) return null; // match, but has not a nde; exit
|
||||
|
@ -17,21 +17,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.core.json; import gplx.*; import gplx.core.*;
|
||||
public class Json_doc_bldr {
|
||||
public Json_nde Nde() {return factory.Nde(-1);}
|
||||
public Json_nde Nde(Json_grp owner) {
|
||||
Json_nde rv = factory.Nde(-1);
|
||||
public Json_nde Nde(Json_doc jdoc) {return factory.Nde(jdoc, -1);}
|
||||
public Json_nde Nde(Json_doc jdoc, Json_grp owner) {
|
||||
Json_nde rv = factory.Nde(jdoc, -1);
|
||||
owner.Add(rv);
|
||||
return rv;
|
||||
}
|
||||
public Json_itm Str(byte[] v) {return Str(String_.new_u8(v));}
|
||||
public Json_itm Str(String v) {return Json_itm_tmp.new_str_(v);}
|
||||
public Json_itm Int(int v) {return Json_itm_tmp.new_int_(v);}
|
||||
public Json_itm_kv Kv_int(Json_grp owner, String key, int val) {Json_itm_kv rv = factory.Kv(Json_itm_tmp.new_str_(key), Json_itm_tmp.new_int_(val)); owner.Add(rv); return rv;}
|
||||
public Json_itm_kv Kv_str(Json_grp owner, String key, String val) {Json_itm_kv rv = factory.Kv(Json_itm_tmp.new_str_(key), Json_itm_tmp.new_str_(val)); owner.Add(rv); return rv;}
|
||||
public Json_itm_ary Kv_ary(Json_grp owner, String key, Json_itm... subs) {
|
||||
public Json_kv Kv_int(Json_grp owner, String key, int val) {Json_kv rv = factory.Kv(Json_itm_tmp.new_str_(key), Json_itm_tmp.new_int_(val)); owner.Add(rv); return rv;}
|
||||
public Json_kv Kv_str(Json_grp owner, String key, String val) {Json_kv rv = factory.Kv(Json_itm_tmp.new_str_(key), Json_itm_tmp.new_str_(val)); owner.Add(rv); return rv;}
|
||||
public Json_ary Kv_ary(Json_grp owner, String key, Json_itm... subs) {
|
||||
Json_itm key_itm = Json_itm_tmp.new_str_(key);
|
||||
Json_itm_ary val_ary = factory.Ary(-1, -1);
|
||||
Json_itm_kv kv = factory.Kv(key_itm, val_ary);
|
||||
Json_ary val_ary = factory.Ary(-1, -1);
|
||||
Json_kv kv = factory.Kv(key_itm, val_ary);
|
||||
owner.Add(kv);
|
||||
int len = subs.length;
|
||||
for (int i = 0; i < len; i++)
|
||||
|
@ -23,7 +23,7 @@ public class Json_factory {
|
||||
public Json_itm_int Int(Json_doc doc, int bgn, int end) {return new Json_itm_int(doc, bgn, end);}
|
||||
public Json_itm Decimal(Json_doc doc, int bgn, int end) {return new Json_itm_decimal(doc, bgn, end);}
|
||||
public Json_itm Str(Json_doc doc, int bgn, int end, boolean exact) {return new Json_itm_str(doc, bgn, end, exact);}
|
||||
public Json_itm_kv Kv(Json_itm key, Json_itm val) {return new Json_itm_kv(key, val);}
|
||||
public Json_itm_ary Ary(int bgn, int end) {return new Json_itm_ary(bgn, end);}
|
||||
public Json_nde Nde(int bgn) {return new Json_nde(bgn);}
|
||||
public Json_kv Kv(Json_itm key, Json_itm val) {return new Json_kv(key, val);}
|
||||
public Json_ary Ary(int bgn, int end) {return new Json_ary(bgn, end);}
|
||||
public Json_nde Nde(Json_doc doc, int bgn) {return new Json_nde(doc, bgn);}
|
||||
}
|
||||
|
@ -16,12 +16,14 @@ 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.json; import gplx.*; import gplx.core.*;
|
||||
public class Json_itm_kv extends Json_itm_base {
|
||||
public Json_itm_kv(Json_itm key, Json_itm val) {this.key = key; this.val = val;}
|
||||
public class Json_kv extends Json_itm_base {
|
||||
public Json_kv(Json_itm key, Json_itm val) {this.key = key; this.val = val;}
|
||||
@Override public byte Tid() {return Json_itm_.Tid_kv;}
|
||||
public Json_itm Key() {return key;} Json_itm key;
|
||||
public Json_itm Val() {return val;} Json_itm val;
|
||||
public byte[] Key_as_bry() {return key.Data_bry();}
|
||||
public String Key_as_str() {return (String)key.Data();}
|
||||
public byte[] Val_as_bry() {return val.Data_bry();}
|
||||
public boolean Key_eq(byte[] comp) {return ((Json_itm_str)key).Data_eq(comp);}
|
||||
@Override public Object Data() {return null;}
|
||||
@Override public byte[] Data_bry() {return null;}
|
||||
@ -30,6 +32,6 @@ public class Json_itm_kv extends Json_itm_base {
|
||||
bfr.Add_byte(Byte_ascii.Colon);
|
||||
val.Print_as_json(bfr, depth);
|
||||
}
|
||||
public static final Json_itm_kv[] Ary_empty = new Json_itm_kv[0];
|
||||
public static Json_itm_kv cast_(Json_itm v) {return v == null || v.Tid() != Json_itm_.Tid_kv ? null : (Json_itm_kv)v;}
|
||||
public static final Json_kv[] Ary_empty = new Json_kv[0];
|
||||
public static Json_kv cast_(Json_itm v) {return v == null || v.Tid() != Json_itm_.Tid_kv ? null : (Json_kv)v;}
|
||||
}
|
@ -20,7 +20,7 @@ public class Json_kv_ary_srl {
|
||||
public static KeyVal Kv_by_itm(Json_itm itm) {
|
||||
switch (itm.Tid()) {
|
||||
case Json_itm_.Tid_kv:
|
||||
Json_itm_kv kv = (Json_itm_kv)itm;
|
||||
Json_kv kv = (Json_kv)itm;
|
||||
return KeyVal_.new_(kv.Key_as_str(), Val_by_itm(kv.Val()));
|
||||
default:
|
||||
throw Err_.new_unhandled(itm.Tid());
|
||||
@ -33,13 +33,13 @@ public class Json_kv_ary_srl {
|
||||
case Json_itm_.Tid_null:
|
||||
case Json_itm_.Tid_string:
|
||||
case Json_itm_.Tid_decimal: return itm.Data();
|
||||
case Json_itm_.Tid_array: return Val_by_itm_ary((Json_itm_ary)itm);
|
||||
case Json_itm_.Tid_array: return Val_by_itm_ary((Json_ary)itm);
|
||||
case Json_itm_.Tid_nde: return Val_by_itm_nde((Json_nde)itm);
|
||||
case Json_itm_.Tid_kv: // kv should never be val; EX: "a":"b":c; not possible
|
||||
default: throw Err_.new_unhandled(itm.Tid());
|
||||
}
|
||||
}
|
||||
private static KeyVal[] Val_by_itm_ary(Json_itm_ary itm) {
|
||||
private static KeyVal[] Val_by_itm_ary(Json_ary itm) {
|
||||
int subs_len = itm.Len();
|
||||
KeyVal[] rv = new KeyVal[subs_len];
|
||||
for (int i = 0; i < subs_len; i++) {
|
||||
|
@ -16,18 +16,24 @@ 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.json; import gplx.*; import gplx.core.*;
|
||||
public class Json_nde extends Json_itm_base implements Json_grp {
|
||||
public class Json_nde extends Json_itm_base implements Json_grp {
|
||||
private Json_itm[] subs = Json_itm_.Ary_empty; private int subs_len = 0, subs_max = 0;
|
||||
public Json_nde(int src_bgn) {this.Ctor(src_bgn, -1);}
|
||||
public Json_nde(Json_doc jdoc, int src_bgn) {this.jdoc = jdoc; this.Ctor(src_bgn, -1);}
|
||||
@Override public byte Tid() {return Json_itm_.Tid_nde;}
|
||||
public Json_doc Doc() {return jdoc;} private final Json_doc jdoc;
|
||||
public void Src_end_(int v) {this.src_end = v;}
|
||||
@Override public Object Data() {return null;}
|
||||
@Override public byte[] Data_bry() {return null;}
|
||||
public int Len() {return subs_len;}
|
||||
public Json_kv Get_at_as_kv(int i) {
|
||||
Json_itm rv_itm = Get_at(i);
|
||||
Json_kv rv = Json_kv.cast_(rv_itm); if (rv == null) throw Err_.new_("json", "sub is not kv", "i", i, "src", Bry_.Mid(jdoc.Src(), this.Src_bgn(), src_end));
|
||||
return rv;
|
||||
}
|
||||
public Json_itm Get_at(int i) {return subs[i];}
|
||||
public Json_nde Get(String key) {return Get(Bry_.new_u8(key));}
|
||||
public Json_nde Get(byte[] key) {
|
||||
Json_itm_kv kv = Json_itm_kv.cast_(this.Get_itm(key)); if (kv == null) throw Err_.new_("json", "kv not found", "key", key);
|
||||
Json_kv kv = Json_kv.cast_(this.Get_itm(key)); if (kv == null) throw Err_.new_("json", "kv not found", "key", key);
|
||||
Json_nde rv = Json_nde.cast_(kv.Val()); if (rv == null) throw Err_.new_("json", "nde not found", "key", key);
|
||||
return rv;
|
||||
}
|
||||
@ -35,7 +41,7 @@ public class Json_nde extends Json_itm_base implements Json_grp {
|
||||
for (int i = 0; i < subs_len; i++) {
|
||||
Json_itm itm = subs[i];
|
||||
if (itm.Tid() == Json_itm_.Tid_kv) {
|
||||
Json_itm_kv itm_as_kv = (Json_itm_kv)itm;
|
||||
Json_kv itm_as_kv = (Json_kv)itm;
|
||||
if (Bry_.Eq(key, itm_as_kv.Key().Data_bry()))
|
||||
return itm;
|
||||
}
|
||||
@ -52,7 +58,7 @@ public class Json_nde extends Json_itm_base implements Json_grp {
|
||||
Json_itm kv_obj = Get_itm(key);
|
||||
if (kv_obj == null) return or; // key not found;
|
||||
if (kv_obj.Tid() != Json_itm_.Tid_kv) return or; // key is not a key_val
|
||||
Json_itm_kv kv = (Json_itm_kv)kv_obj;
|
||||
Json_kv kv = (Json_kv)kv_obj;
|
||||
Json_itm val = kv.Val();
|
||||
if (val == null) return or;
|
||||
return val.Data_bry();
|
||||
|
@ -33,9 +33,9 @@ public class Json_parser {
|
||||
doc.Ctor(src, root);
|
||||
return doc;
|
||||
}
|
||||
Json_nde Make_nde(Json_doc doc) {
|
||||
private Json_nde Make_nde(Json_doc doc) {
|
||||
++pos; // brack_bgn
|
||||
Json_nde nde = new Json_nde(pos);
|
||||
Json_nde nde = new Json_nde(doc, pos);
|
||||
while (pos < src_len) {
|
||||
Skip_ws();
|
||||
if (src[pos] == Byte_ascii.Curly_end) {++pos; return nde;}
|
||||
@ -55,7 +55,7 @@ public class Json_parser {
|
||||
Chk(Byte_ascii.Colon);
|
||||
Skip_ws();
|
||||
Json_itm val = Make_val(doc);
|
||||
return new Json_itm_kv(key, val);
|
||||
return new Json_kv(key, val);
|
||||
}
|
||||
Json_itm Make_val(Json_doc doc) {
|
||||
while (pos < src_len) {
|
||||
@ -131,8 +131,8 @@ public class Json_parser {
|
||||
? factory.Decimal(doc, num_bgn, pos)
|
||||
: factory.Int(doc, num_bgn, pos);
|
||||
}
|
||||
Json_itm_ary Make_ary(Json_doc doc) {
|
||||
Json_itm_ary rv = factory.Ary(pos++, pos); // brack_bgn
|
||||
Json_ary Make_ary(Json_doc doc) {
|
||||
Json_ary rv = factory.Ary(pos++, pos); // brack_bgn
|
||||
while (pos < src_len) {
|
||||
Skip_ws();
|
||||
if (src[pos] == Byte_ascii.Brack_end) {++pos; return rv;}
|
||||
|
@ -52,23 +52,23 @@ class Json_parser_fxt {
|
||||
} Json_parser parser; Json_factory factory; Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
|
||||
Json_itm itm_int_(int v) {return Json_itm_tmp.new_int_(v);}
|
||||
Json_itm itm_str_(String v) {return Json_itm_tmp.new_str_(v);}
|
||||
public Json_itm_ary itm_ary_() {return factory.Ary(-1, -1);}
|
||||
public Json_nde itm_nde_() {return factory.Nde(-1);}
|
||||
public Json_itm_kv itm_kv_null_(String k) {return factory.Kv(itm_str_(k), factory.Null());}
|
||||
public Json_itm_kv itm_kv_(String k, String v) {return factory.Kv(itm_str_(k), itm_str_(v));}
|
||||
public Json_itm_kv itm_kv_(String k, int v) {return factory.Kv(itm_str_(k), itm_int_(v));}
|
||||
public Json_itm_kv itm_kv_(String k, boolean v) {return factory.Kv(itm_str_(k), v ? factory.Bool_y() : factory.Bool_n());}
|
||||
public Json_itm_kv itm_kv_dec_(String k, String v) {return factory.Kv(itm_str_(k), new Json_itm_tmp(Json_itm_.Tid_decimal, v));}
|
||||
public Json_itm_kv itm_kv_(String k, Json_nde v) {return factory.Kv(itm_str_(k), v);}
|
||||
public Json_itm_kv itm_kv_ary_int_(String k, int... v) {
|
||||
Json_itm_ary ary = factory.Ary(-1, -1);
|
||||
public Json_ary itm_ary_() {return factory.Ary(-1, -1);}
|
||||
public Json_nde itm_nde_() {return factory.Nde(null, -1);}
|
||||
public Json_kv itm_kv_null_(String k) {return factory.Kv(itm_str_(k), factory.Null());}
|
||||
public Json_kv itm_kv_(String k, String v) {return factory.Kv(itm_str_(k), itm_str_(v));}
|
||||
public Json_kv itm_kv_(String k, int v) {return factory.Kv(itm_str_(k), itm_int_(v));}
|
||||
public Json_kv itm_kv_(String k, boolean v) {return factory.Kv(itm_str_(k), v ? factory.Bool_y() : factory.Bool_n());}
|
||||
public Json_kv itm_kv_dec_(String k, String v) {return factory.Kv(itm_str_(k), new Json_itm_tmp(Json_itm_.Tid_decimal, v));}
|
||||
public Json_kv itm_kv_(String k, Json_nde v) {return factory.Kv(itm_str_(k), v);}
|
||||
public Json_kv itm_kv_ary_int_(String k, int... v) {
|
||||
Json_ary ary = factory.Ary(-1, -1);
|
||||
int len = v.length;
|
||||
for (int i = 0; i < len; i++)
|
||||
ary.Add(itm_int_(v[i]));
|
||||
return factory.Kv(itm_str_(k), ary);
|
||||
}
|
||||
public Json_itm_kv itm_kv_ary_str_(String k, String... v) {
|
||||
Json_itm_ary ary = factory.Ary(-1, -1);
|
||||
public Json_kv itm_kv_ary_str_(String k, String... v) {
|
||||
Json_ary ary = factory.Ary(-1, -1);
|
||||
int len = v.length;
|
||||
for (int i = 0; i < len; i++)
|
||||
ary.Add(itm_str_(v[i]));
|
||||
@ -85,7 +85,7 @@ class Json_parser_fxt {
|
||||
public void Test_parse_val0(String raw_str, Object expd) {
|
||||
byte[] raw = Json_parser_tst.Replace_apos(Bry_.new_u8(raw_str));
|
||||
Json_doc doc = parser.Parse(raw);
|
||||
Json_itm_kv kv = Json_itm_kv.cast_(doc.Root().Get_at(0)); // assume root has kv as first sub; EX: {"a":"b"}
|
||||
Json_kv kv = Json_kv.cast_(doc.Root().Get_at(0)); // assume root has kv as first sub; EX: {"a":"b"}
|
||||
Object actl = kv.Val().Data(); // NOTE: Data_bry is escaped val; EX: a\"b has DataBry of a"b
|
||||
Tfds.Eq(expd, actl);
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ public class Xoa_app_ {
|
||||
boot_mgr.Run(args);
|
||||
}
|
||||
public static final String Name = "xowa";
|
||||
public static final String Version = "2.7.3.1";
|
||||
public static final String Version = "2.7.3.2";
|
||||
public static String Build_date = "2012-12-30 00:00:00";
|
||||
public static String Op_sys;
|
||||
public static String User_agent = "";
|
||||
|
@ -33,7 +33,7 @@ abstract class Json_itm_wkr__base implements Json_itm_wkr {
|
||||
Json_itm itm = root.Get_at(i);
|
||||
switch (itm.Tid()) {
|
||||
case Json_itm_.Tid_kv:
|
||||
Json_itm_kv kv = (Json_itm_kv)itm;
|
||||
Json_kv kv = (Json_kv)itm;
|
||||
if (kv.Key().Data_eq(Name_metadata)) continue; // ignore @metadata node
|
||||
byte[] kv_key = kv.Key().Data_bry();
|
||||
byte[] kv_val = kv.Val().Data_bry();
|
||||
|
54
400_xowa/src/gplx/xowa/bldrs/syncs/Xob_sync_itm.java
Normal file
54
400_xowa/src/gplx/xowa/bldrs/syncs/Xob_sync_itm.java
Normal file
@ -0,0 +1,54 @@
|
||||
/*
|
||||
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.xowa.bldrs.syncs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
|
||||
import gplx.ios.*;
|
||||
class Xob_sync_grp {
|
||||
private final Ordered_hash itms = Ordered_hash_.new_();
|
||||
public Xob_sync_grp Ctor_itm(DateAdp upload_time, DateAdp related_time) {
|
||||
this.upload_time = upload_time; this.related_time = related_time;
|
||||
return this;
|
||||
}
|
||||
public DateAdp Upload_time() {return upload_time;} private DateAdp upload_time;
|
||||
public DateAdp Related_time() {return related_time;} private DateAdp related_time;
|
||||
public int Itms__len() {return itms.Count();}
|
||||
public void Itms__add(Xob_sync_pkg file) {itms.Add(file.Path(), file);}
|
||||
public Xob_sync_pkg Itms__get_at(int i) {return (Xob_sync_pkg)itms.Get_at(i);}
|
||||
}
|
||||
class Xob_sync_pkg extends Xob_sync_fil { private final Ordered_hash itms = Ordered_hash_.new_();
|
||||
public Xob_sync_pkg Ctor_itm(String url, byte zip_tid) {
|
||||
this.url = url; this.zip_tid = zip_tid;
|
||||
return this;
|
||||
}
|
||||
public String Url() {return url;} private String url;
|
||||
public byte Zip_tid() {return zip_tid;} private byte zip_tid;
|
||||
public int Itms__len() {return itms.Count();}
|
||||
public void Itms__add(Xob_sync_fil file) {itms.Add(file.Path(), file);}
|
||||
public Xob_sync_fil Itms__get_at(int i) {return (Xob_sync_fil)itms.Get_at(i);}
|
||||
}
|
||||
class Xob_sync_fil {
|
||||
public Xob_sync_fil Ctor_file(String path, String name, int ext, long len, DateAdp modified, String hash) {
|
||||
this.path = path; this.name = name; this.ext = ext; this.len = len; this.modified = modified; this.hash = hash;
|
||||
return this;
|
||||
}
|
||||
public String Path() {return path;} private String path;
|
||||
public String Name() {return name;} private String name;
|
||||
public int Ext() {return ext;} private int ext;
|
||||
public long Len() {return len;} private long len;
|
||||
public DateAdp Modified() {return modified;} private DateAdp modified;
|
||||
public String Hash() {return hash;} private String hash;
|
||||
}
|
@ -118,10 +118,7 @@ public class Xoh_page_wtr_wkr implements Bry_fmtr_arg {
|
||||
return;
|
||||
}
|
||||
Xol_vnt_mgr vnt_mgr = wiki.Lang().Vnt_mgr();
|
||||
if (vnt_mgr.Enabled()) { // VNT
|
||||
// vnt_mgr.Convert_ttl(
|
||||
}
|
||||
if (ns_id == Xow_ns_.Id_file) // if [[File]], add boilerplate header
|
||||
if (ns_id == Xow_ns_.Id_file) // if [[File]], add boilerplate header
|
||||
app.Ns_file_page_mgr().Bld_html(wiki, ctx, page, bfr, page.Ttl(), wiki.Cfg_file_page(), page.File_queue());
|
||||
gplx.xowa.html.tidy.Xoh_tidy_mgr tidy_mgr = app.Html_mgr().Tidy_mgr();
|
||||
boolean tidy_enabled = tidy_mgr.Enabled();
|
||||
@ -146,6 +143,8 @@ public class Xoh_page_wtr_wkr implements Bry_fmtr_arg {
|
||||
else
|
||||
wiki.Html_mgr().Ctg_mgr().Bld(bfr, page, ctgs_len);
|
||||
}
|
||||
if (vnt_mgr.Enabled()) // VNT
|
||||
bfr.Add(vnt_mgr.Convert_text(wiki, bfr.Xto_bry_and_clear()));
|
||||
}
|
||||
private void Write_body_pre(Bry_bfr bfr, Xoae_app app, Xowe_wiki wiki, byte[] data_raw, Bry_bfr tmp_bfr) {
|
||||
Xoh_html_wtr_escaper.Escape(app.Parser_amp_mgr(), tmp_bfr, data_raw, 0, data_raw.length, false, false);
|
||||
|
@ -45,10 +45,10 @@ public class Dbui_cmd_mgr {
|
||||
Dbui_val_hash rv = new Dbui_val_hash();
|
||||
int len = grp.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Json_itm_kv kv = (Json_itm_kv)grp.Get_at(i);
|
||||
Json_kv kv = (Json_kv)grp.Get_at(i);
|
||||
Json_nde nde = (Json_nde)kv.Val();
|
||||
Json_itm_kv key = (Json_itm_kv)nde.Get_itm(Arg_key);
|
||||
Json_itm_kv val = (Json_itm_kv)nde.Get_itm(Arg_val);
|
||||
Json_kv key = (Json_kv)nde.Get_itm(Arg_key);
|
||||
Json_kv val = (Json_kv)nde.Get_itm(Arg_val);
|
||||
Dbui_val_itm fld = new Dbui_val_itm(val.Val().Data_bry(), Bry_.Empty);
|
||||
rv.Add(key.Val().Data_bry(), fld);
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ public class Xow_portal_mgr implements GfoInvkAble {
|
||||
Bry_fmtr_arg vnt_menu = null;
|
||||
// Xol_vnt_mgr vnt_mgr = wiki.Lang().Vnt_mgr(); // VNT; DATE:2015-03-03
|
||||
// if (vnt_mgr.Enabled()) {
|
||||
// Xolg_vnt_grp_fmtr vnt_menu_fmtr = vnt_mgr.Vnt_mnu_fmtr();
|
||||
// Vnt_mnu_grp_fmtr vnt_menu_fmtr = vnt_mgr.Vnt_mnu_fmtr();
|
||||
// vnt_menu_fmtr.Init(vnt_mgr.Vnt_grp(), ttl.Full_db(), vnt_mgr.Cur_vnt());
|
||||
// vnt_menu = wiki.Lang().Vnt_mgr().Enabled() ? vnt_menu_fmtr : null;
|
||||
// }
|
||||
|
@ -16,10 +16,10 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs.vnts; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
public class Xolg_vnt_grp {
|
||||
public class Vnt_mnu_grp {
|
||||
private final List_adp list = List_adp_.new_();
|
||||
public byte[] Text() {return text;} public void Text_(byte[] v) {text = v;} private byte[] text;
|
||||
public int Len() {return list.Count();}
|
||||
public Xolg_vnt_itm Get_at(int i) {return (Xolg_vnt_itm)list.Get_at(i);}
|
||||
public void Add(Xolg_vnt_itm itm) {list.Add(itm);}
|
||||
public Vnt_mnu_itm Get_at(int i) {return (Vnt_mnu_itm)list.Get_at(i);}
|
||||
public void Add(Vnt_mnu_itm itm) {list.Add(itm);}
|
||||
public byte[] Text() {return text;} public void Text_(byte[] v) {text = v;} private byte[] text;
|
||||
}
|
@ -16,10 +16,10 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs.vnts; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
public class Xolg_vnt_grp_fmtr implements Bry_fmtr_arg {
|
||||
private Xolg_vnt_grp grp;
|
||||
private Xolg_vnt_itm_fmtr itm_fmtr = new Xolg_vnt_itm_fmtr();
|
||||
public void Init(Xolg_vnt_grp grp, byte[] page_href, byte[] page_vnt) {
|
||||
public class Vnt_mnu_grp_fmtr implements Bry_fmtr_arg {
|
||||
private Vnt_mnu_grp grp;
|
||||
private final Xolg_vnt_itm_fmtr itm_fmtr = new Xolg_vnt_itm_fmtr();
|
||||
public void Init(Vnt_mnu_grp grp, byte[] page_href, byte[] page_vnt) {
|
||||
this.grp = grp;
|
||||
itm_fmtr.Init(grp, page_href, page_vnt);
|
||||
}
|
||||
@ -27,7 +27,8 @@ public class Xolg_vnt_grp_fmtr implements Bry_fmtr_arg {
|
||||
fmtr.Bld_bfr_many(bfr, grp.Text(), itm_fmtr);
|
||||
}
|
||||
private static final Bry_fmtr fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( " <div id='p-variants' role='navigation' class='vectorMenu' aria-labelledby='p-variants-label'>"
|
||||
( ""
|
||||
, " <div id='p-variants' role='navigation' class='vectorMenu' aria-labelledby='p-variants-label'>"
|
||||
, " <h3 id='p-variants-label'><span>~{grp_text}</span><a href='#'></a></h3>"
|
||||
, " <div class='menu'>"
|
||||
, " <ul>~{itms}"
|
||||
@ -38,12 +39,12 @@ public class Xolg_vnt_grp_fmtr implements Bry_fmtr_arg {
|
||||
);
|
||||
}
|
||||
class Xolg_vnt_itm_fmtr implements Bry_fmtr_arg {
|
||||
private Xolg_vnt_grp grp; private byte[] page_href, page_vnt;
|
||||
public void Init(Xolg_vnt_grp grp, byte[] page_href, byte[] page_vnt) {this.grp = grp; this.page_href = page_href; this.page_vnt = page_vnt;}
|
||||
private Vnt_mnu_grp grp; private byte[] page_href, page_vnt;
|
||||
public void Init(Vnt_mnu_grp grp, byte[] page_href, byte[] page_vnt) {this.grp = grp; this.page_href = page_href; this.page_vnt = page_vnt;}
|
||||
public void XferAry(Bry_bfr bfr, int idx) {
|
||||
int len = grp.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xolg_vnt_itm itm = grp.Get_at(i);
|
||||
Vnt_mnu_itm itm = grp.Get_at(i);
|
||||
boolean itm_is_selected = Bry_.Eq(itm.Key(), page_vnt);
|
||||
byte[] itm_cls_selected = itm_is_selected ? Itm_cls_selected_y : Bry_.Empty;
|
||||
fmtr.Bld_bfr_many(bfr, i, itm_cls_selected, itm.Key(), itm.Text(), page_href);
|
@ -17,11 +17,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs.vnts; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import org.junit.*;
|
||||
public class Xolg_vnt_grp_fmtr_tst {
|
||||
@Before public void init() {fxt.Clear();} private final Xolg_vnt_grp_fmtr_fxt fxt = new Xolg_vnt_grp_fmtr_fxt();
|
||||
public class Vnt_mnu_grp_fmtr_tst {
|
||||
@Before public void init() {fxt.Clear();} private final Vnt_mnu_grp_fmtr_fxt fxt = new Vnt_mnu_grp_fmtr_fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Test_to_str("Earth", "zh-hk", String_.Concat_lines_nl_skip_last
|
||||
( " <div id='p-variants' role='navigation' class='vectorMenu' aria-labelledby='p-variants-label'>"
|
||||
( ""
|
||||
, " <div id='p-variants' role='navigation' class='vectorMenu' aria-labelledby='p-variants-label'>"
|
||||
, " <h3 id='p-variants-label'><span>Choose lang</span><a href='#'></a></h3>"
|
||||
, " <div class='menu'>"
|
||||
, " <ul>"
|
||||
@ -38,13 +39,13 @@ public class Xolg_vnt_grp_fmtr_tst {
|
||||
));
|
||||
}
|
||||
}
|
||||
class Xolg_vnt_grp_fmtr_fxt {
|
||||
private Xolg_vnt_grp vnt_grp;
|
||||
class Vnt_mnu_grp_fmtr_fxt {
|
||||
private Vnt_mnu_grp vnt_grp;
|
||||
public void Clear() {
|
||||
this.Init_grp("Choose lang", "zh-hans", "Simplified", "zh-hant", "Traditional", "zh-cn", "China", "zh-hk", "Hong Kong", "zh-mo", "Macau", "zh-sg", "Singapore", "zh-tw", "Taiwan");
|
||||
}
|
||||
public void Init_grp(String text, String... langs) {
|
||||
vnt_grp = new Xolg_vnt_grp();
|
||||
vnt_grp = new Vnt_mnu_grp();
|
||||
vnt_grp.Text_(Bry_.new_u8(text));
|
||||
int len = langs.length;
|
||||
String lang_code = "";
|
||||
@ -53,13 +54,13 @@ class Xolg_vnt_grp_fmtr_fxt {
|
||||
if (i % 2 == 0)
|
||||
lang_code = lang;
|
||||
else {
|
||||
Xolg_vnt_itm itm = new Xolg_vnt_itm(Bry_.new_u8(lang_code), Bry_.new_u8(lang));
|
||||
Vnt_mnu_itm itm = new Vnt_mnu_itm(Bry_.new_u8(lang_code), Bry_.new_u8(lang));
|
||||
vnt_grp.Add(itm);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Test_to_str(String page_href, String selected_vnt, String expd) {
|
||||
Xolg_vnt_grp_fmtr vnt_grp_fmtr = new Xolg_vnt_grp_fmtr();
|
||||
Vnt_mnu_grp_fmtr vnt_grp_fmtr = new Vnt_mnu_grp_fmtr();
|
||||
Bry_bfr bfr = Bry_bfr.new_();
|
||||
vnt_grp_fmtr.Init(vnt_grp, Bry_.new_u8(page_href), Bry_.new_u8(selected_vnt));
|
||||
vnt_grp_fmtr.XferAry(bfr, 0);
|
@ -16,8 +16,8 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs.vnts; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
public class Xolg_vnt_itm {
|
||||
public Xolg_vnt_itm(byte[] key, byte[] text) {this.key = key; this.text = text;}
|
||||
public class Vnt_mnu_itm {
|
||||
public Vnt_mnu_itm(byte[] key, byte[] text) {this.key = key; this.text = text;}
|
||||
public byte[] Key() {return key;} private final byte[] key;
|
||||
public byte[] Text() {return text;} private final byte[] text;
|
||||
}
|
@ -18,27 +18,43 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.langs.vnts; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import gplx.xowa.wikis.data.tbls.*;
|
||||
public class Xol_vnt_mgr implements GfoInvkAble {
|
||||
private Ordered_hash vnts = Ordered_hash_.new_bry_();
|
||||
private int converter_ary_len; private Ordered_hash tmp_page_list = Ordered_hash_.new_bry_();
|
||||
private final Ordered_hash vnts = Ordered_hash_.new_bry_(); private int converter_ary_len, cur_converter_ary_idx = -1;
|
||||
private final Ordered_hash tmp_page_list = Ordered_hash_.new_bry_();
|
||||
public Xol_vnt_mgr(Xol_lang lang) {this.lang = lang;}
|
||||
public Xol_lang Lang() {return lang;} private final Xol_lang lang;
|
||||
public Xol_vnt_converter[] Converter_ary() {return converter_ary;} private Xol_vnt_converter[] converter_ary;
|
||||
public Xolg_vnt_grp Vnt_grp() {return vnt_grp;} private Xolg_vnt_grp vnt_grp = new Xolg_vnt_grp();
|
||||
public Xolg_vnt_grp_fmtr Vnt_mnu_fmtr() {return vnt_mnu_fmtr;} private Xolg_vnt_grp_fmtr vnt_mnu_fmtr = new Xolg_vnt_grp_fmtr();
|
||||
public Xol_lang Lang() {return lang;} private Xol_lang lang;
|
||||
public byte[] Cur_vnt() {return cur_vnt;} public Xol_vnt_mgr Cur_vnt_(byte[] v) {cur_vnt = v; return this;} private byte[] cur_vnt = Bry_.Empty;
|
||||
public Vnt_mnu_grp Vnt_grp() {return vnt_grp;} private final Vnt_mnu_grp vnt_grp = new Vnt_mnu_grp();
|
||||
public Vnt_mnu_grp_fmtr Vnt_mnu_fmtr() {return vnt_mnu_fmtr;} private final Vnt_mnu_grp_fmtr vnt_mnu_fmtr = new Vnt_mnu_grp_fmtr();
|
||||
public boolean Enabled() {return enabled;} public void Enabled_(boolean v) {this.enabled = v;} private boolean enabled = false;
|
||||
public byte[] Cur_vnt() {return cur_vnt;} private byte[] cur_vnt = Bry_.Empty;
|
||||
private void Vnt_grp_(byte[][] ary) {
|
||||
int len = ary.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
byte[] vnt = ary[i];
|
||||
byte[] msg = lang.Msg_mgr().Itm_by_key_or_new(Bry_.Add(Msg_variantname, vnt)).Val();
|
||||
// byte[] msg = vnt;
|
||||
vnt_grp.Add(new Vnt_mnu_itm(vnt, msg));
|
||||
}
|
||||
}
|
||||
private static final byte[] Msg_variantname = Bry_.new_a7("variantname-");
|
||||
public String Html_style() {return html_style;} private String html_style = "";
|
||||
public Xol_vnt_mgr Cur_vnt_(byte[] v) {
|
||||
int new_converter_ary_idx = -1;
|
||||
for (int i = 0; i < converter_ary_len; i++) {
|
||||
Xol_vnt_converter itm = converter_ary[i];
|
||||
if (Bry_.Eq(v, itm.Owner().Key())) {
|
||||
new_converter_ary_idx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (new_converter_ary_idx == -1) throw Err_.new_("lang.vnt", "uknown vnt", "key", v);
|
||||
this.cur_vnt = v;
|
||||
this.cur_converter_ary_idx = new_converter_ary_idx;
|
||||
return this;
|
||||
}
|
||||
public void Init_by_wiki(Xowe_wiki wiki) {
|
||||
if (!enabled) return;
|
||||
Xop_vnt_lxr_.set_(wiki);
|
||||
// VNT
|
||||
// vnt_grp.Add(new Xolg_vnt_itm(Bry_.new_a7("zh-hans"), Bry_.new_a7("Simplified")));
|
||||
// vnt_grp.Add(new Xolg_vnt_itm(Bry_.new_a7("zh-hant"), Bry_.new_a7("Traditional")));
|
||||
// vnt_grp.Add(new Xolg_vnt_itm(Bry_.new_a7("zh-cn"), Bry_.new_a7("China")));
|
||||
// vnt_grp.Add(new Xolg_vnt_itm(Bry_.new_a7("zh-hk"), Bry_.new_a7("Hong Kong")));
|
||||
// vnt_grp.Add(new Xolg_vnt_itm(Bry_.new_a7("zh-mo"), Bry_.new_a7("Macau")));
|
||||
// vnt_grp.Add(new Xolg_vnt_itm(Bry_.new_a7("zh-sg"), Bry_.new_a7("Singapore")));
|
||||
// vnt_grp.Add(new Xolg_vnt_itm(Bry_.new_a7("zh-tw"), Bry_.new_a7("Taiwan")));
|
||||
}
|
||||
public Xol_vnt_itm Get_or_new(byte[] key) {
|
||||
Xol_vnt_itm rv = (Xol_vnt_itm)vnts.Get_by(key);
|
||||
@ -49,6 +65,13 @@ public class Xol_vnt_mgr implements GfoInvkAble {
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public byte[] Convert_text(Xowe_wiki wiki, byte[] src) {return Convert_text(wiki, src, 0, src.length);}
|
||||
public byte[] Convert_text(Xowe_wiki wiki, byte[] src, int bgn, int end) {
|
||||
Bry_bfr tmp_bfr = wiki.Utl__bfr_mkr().Get_m001();
|
||||
Xol_vnt_converter converter = converter_ary[cur_converter_ary_idx];
|
||||
converter.Convert_text(tmp_bfr, src, bgn, end);
|
||||
return tmp_bfr.To_bry_and_rls();
|
||||
}
|
||||
public void Convert_ttl_init() {
|
||||
int vnts_len = vnts.Count();
|
||||
converter_ary_len = vnts_len;
|
||||
@ -67,39 +90,42 @@ public class Xol_vnt_mgr implements GfoInvkAble {
|
||||
return rv;
|
||||
}
|
||||
public Xowd_page_itm Convert_ttl(Xowe_wiki wiki, Bry_bfr tmp_bfr, Xow_ns ns, byte[] ttl_bry) { // REF.MW:LanguageConverter.php|findVariantLink
|
||||
int converted = Convert_ttl_convert(wiki, tmp_bfr, ns, ttl_bry); // convert ttl for each vnt
|
||||
if (converted == 0) return Xowd_page_itm.Null; // ttl_bry has no conversions; exit;
|
||||
int converted = Convert_ttl__convert_each_vnt(wiki, tmp_bfr, ns, ttl_bry); // convert ttl for each vnt
|
||||
if (converted == 0) return Xowd_page_itm.Null; // ttl_bry has no conversions; exit;
|
||||
wiki.Db_mgr().Load_mgr().Load_by_ttls(Cancelable_.Never, tmp_page_list, true, 0, converted);
|
||||
for (int i = 0; i < converted; i++) {
|
||||
Xowd_page_itm page = (Xowd_page_itm)tmp_page_list.Get_at(i);
|
||||
if (page.Exists()) return page; // return 1st found page
|
||||
if (page.Exists()) return page; // return 1st found page
|
||||
}
|
||||
return Xowd_page_itm.Null;
|
||||
}
|
||||
private int Convert_ttl_convert(Xowe_wiki wiki, Bry_bfr tmp_bfr, Xow_ns ns, byte[] ttl_bry) {
|
||||
tmp_page_list.Clear();
|
||||
int rv = 0;
|
||||
for (int i = 0; i < converter_ary_len; i++) { // convert ttl for each variant
|
||||
Xol_vnt_converter converter = converter_ary[i];
|
||||
tmp_bfr.Clear();
|
||||
if (!converter.Convert_text(tmp_bfr, ttl_bry)) continue; // ttl is not converted for variant; ignore
|
||||
Xoa_ttl ttl = Xoa_ttl.parse_(wiki, ns.Id(), tmp_bfr.Xto_bry_and_clear()); // NOTE: must convert to ttl in order to upper 1st letter; EX:{{jez-eng|sense}} -> Jez-eng; PAGE:sr.w:ДНК DATE:2014-07-06
|
||||
if (ttl == null) continue;
|
||||
Xowd_page_itm page = new Xowd_page_itm();
|
||||
page.Ttl_(ns, ttl.Page_db());
|
||||
byte[] converted_ttl = page.Ttl_full_db();
|
||||
if (tmp_page_list.Has(converted_ttl)) continue;
|
||||
tmp_page_list.Add(converted_ttl, page);
|
||||
++rv;
|
||||
private int Convert_ttl__convert_each_vnt(Xowe_wiki wiki, Bry_bfr tmp_bfr, Xow_ns ns, byte[] ttl_bry) {
|
||||
synchronized (tmp_page_list) {
|
||||
tmp_page_list.Clear();
|
||||
int rv = 0;
|
||||
for (int i = 0; i < converter_ary_len; i++) { // convert ttl for each variant
|
||||
Xol_vnt_converter converter = converter_ary[i];
|
||||
tmp_bfr.Clear();
|
||||
if (!converter.Convert_text(tmp_bfr, ttl_bry)) continue; // ttl is not converted for variant; ignore
|
||||
Xoa_ttl ttl = Xoa_ttl.parse_(wiki, ns.Id(), tmp_bfr.Xto_bry_and_clear()); // NOTE: must convert to ttl in order to upper 1st letter; EX:{{jez-eng|sense}} -> Jez-eng; PAGE:sr.w:ДНК DATE:2014-07-06
|
||||
if (ttl == null) continue;
|
||||
Xowd_page_itm page = new Xowd_page_itm();
|
||||
page.Ttl_(ns, ttl.Page_db());
|
||||
byte[] converted_ttl = page.Ttl_full_db();
|
||||
if (tmp_page_list.Has(converted_ttl)) continue;
|
||||
tmp_page_list.Add(converted_ttl, page);
|
||||
++rv;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_get)) return Get_or_new(m.ReadBry("v"));
|
||||
else if (ctx.Match(k, Invk_init_end)) Convert_ttl_init();
|
||||
else if (ctx.Match(k, Invk_cur_vnt_)) cur_vnt = m.ReadBry("v");
|
||||
else if (ctx.Match(k, Invk_vnt_grp_)) Vnt_grp_(m.ReadBryAry("v", Byte_ascii.Pipe));
|
||||
else if (ctx.Match(k, Invk_cur_vnt_)) Cur_vnt_(m.ReadBry("v"));
|
||||
else if (ctx.Match(k, Invk_html_style_)) html_style = m.ReadStr("v");
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
} private static final String Invk_get = "get", Invk_init_end = "init_end", Invk_cur_vnt_ = "cur_vnt_", Invk_html_style_ = "html_style_";
|
||||
} private static final String Invk_get = "get", Invk_init_end = "init_end", Invk_cur_vnt_ = "cur_vnt_", Invk_html_style_ = "html_style_", Invk_vnt_grp_ = "vnt_grp_";
|
||||
}
|
||||
|
@ -100,8 +100,8 @@ class Xosrv_xowa_exec_parser {
|
||||
private Json_parser json_parser = new Json_parser();
|
||||
public Object[] Parse_xowa_exec(byte[] msg_text) { // parses JSON with format '{"args":["arg0","arg1","arg2"]}'
|
||||
Json_doc doc = json_parser.Parse(msg_text);
|
||||
Json_itm_kv args_kv = (Json_itm_kv)doc.Root().Get_at(0); // get "args" kv
|
||||
Json_itm_ary args_ary = (Json_itm_ary)args_kv.Val(); // get []
|
||||
Json_kv args_kv = (Json_kv)doc.Root().Get_at(0); // get "args" kv
|
||||
Json_ary args_ary = (Json_ary)args_kv.Val(); // get []
|
||||
int len = args_ary.Len();
|
||||
Object[] rv = new Object[len];
|
||||
for (int i = 0; i < len; i++) { // extract args
|
||||
@ -115,7 +115,7 @@ class Xosrv_xowa_exec_parser {
|
||||
case Json_itm_.Tid_string:
|
||||
return String_.new_u8(itm.Data_bry());
|
||||
case Json_itm_.Tid_array:
|
||||
Json_itm_ary ary = (Json_itm_ary)itm;
|
||||
Json_ary ary = (Json_ary)itm;
|
||||
int len = ary.Len();
|
||||
String[] rv = new String[len];
|
||||
for (int i = 0; i < len; i++)
|
||||
|
@ -41,7 +41,7 @@ public class Xow_wmf_api_wkr__ns implements Xow_wmf_api_wkr {
|
||||
int ns_len = ns_grp.Len();
|
||||
for (int i = 0; i < ns_len; ++i) {
|
||||
try {
|
||||
Json_itm_kv kv = (Json_itm_kv)ns_grp.Get_at(i);
|
||||
Json_kv kv = (Json_kv)ns_grp.Get_at(i);
|
||||
Json_nde nde = (Json_nde)kv.Val();
|
||||
int ns_id = Bry_.Xto_int_or(Get_val_or_null(nde, Bry_id), Int_.MinValue);
|
||||
byte ns_case = Xow_ns_case_.parse_(String_.new_u8(Get_val_or_null(nde, Bry_case)));
|
||||
@ -68,7 +68,7 @@ public class Xow_wmf_api_wkr__ns implements Xow_wmf_api_wkr {
|
||||
}
|
||||
private byte[] Get_val_or_null(Json_nde nde, byte[] key) {
|
||||
Json_itm sub = nde.Get_itm(key);
|
||||
Json_itm_kv sub_as_kv = (Json_itm_kv)sub;
|
||||
Json_kv sub_as_kv = (Json_kv)sub;
|
||||
return sub_as_kv == null ? null : sub_as_kv.Val().Data_bry(); // sub_as_kv == null when key is not present; note that "canonical" does not exist for Main ns
|
||||
}
|
||||
private static final byte[] Bry_query = Bry_.new_a7("query"), Bry_namespaces = Bry_.new_a7("namespaces")
|
||||
|
@ -0,0 +1,45 @@
|
||||
/*
|
||||
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.xowa.wmfs.data; import gplx.*; import gplx.xowa.*; import gplx.xowa.wmfs.*;
|
||||
import gplx.dbs.*;
|
||||
class Xowmf_defaultoption_tbl implements RlsAble {
|
||||
private static final String tbl_name = "wmf_defaultoption"; private final Db_meta_fld_list flds = new Db_meta_fld_list();
|
||||
private final String fld_site_id, fld_key, fld_val;
|
||||
private final Db_conn conn;
|
||||
private Db_stmt stmt_insert;
|
||||
public Xowmf_defaultoption_tbl(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
this.fld_site_id = flds.Add_int("site_id");
|
||||
this.fld_key = flds.Add_str("key", 255);
|
||||
this.fld_val = flds.Add_str("val", 255);
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public void Create_tbl() {conn.Ddl_create_tbl(Db_meta_tbl.new_(tbl_name, flds, Db_meta_idx.new_unique_by_name(tbl_name, "main", fld_site_id, fld_key)));}
|
||||
public void Delete_all() {conn.Stmt_delete(tbl_name, Db_meta_fld.Ary_empty).Exec_delete();}
|
||||
public void Rls() {
|
||||
stmt_insert = Db_stmt_.Rls(stmt_insert);
|
||||
}
|
||||
public void Insert(int site_id, byte[] key, byte[] val) {
|
||||
if (stmt_insert == null) stmt_insert = conn.Stmt_insert(tbl_name, flds);
|
||||
stmt_insert.Clear()
|
||||
.Val_int(fld_site_id , site_id)
|
||||
.Val_bry_as_str(fld_key , key)
|
||||
.Val_bry_as_str(fld_val , val)
|
||||
.Exec_insert();
|
||||
}
|
||||
}
|
308
400_xowa/src/gplx/xowa/wmfs/data/Xowmf_json_parser.java
Normal file
308
400_xowa/src/gplx/xowa/wmfs/data/Xowmf_json_parser.java
Normal file
@ -0,0 +1,308 @@
|
||||
/*
|
||||
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.xowa.wmfs.data; import gplx.*; import gplx.xowa.*; import gplx.xowa.wmfs.*;
|
||||
import gplx.core.json.*;
|
||||
class Xowmf_json_parser {
|
||||
private byte[] src;
|
||||
public void Parse_root(Json_nde root, Xowmf_wiki_data wiki_data) {
|
||||
this.src = root.Doc().Src();
|
||||
int len = root.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Json_kv sub = root.Get_at_as_kv(i);
|
||||
byte[] sub_key = sub.Key_as_bry();
|
||||
switch (nde_hash.Get_as_int(sub_key)) {
|
||||
case Tid_general : Parse_kv(Json_nde.cast_(sub.Val()), wiki_data.General_list()); break;
|
||||
case Tid_namespaces : Parse_namespaces(Json_nde.cast_(sub.Val()), wiki_data.Namespaces_list()); break;
|
||||
case Tid_statistics : Parse_kv(Json_nde.cast_(sub.Val()), wiki_data.Statistics_list()); break;
|
||||
case Tid_interwikimap : Parse_interwikimap(Json_ary.cast(sub.Val()), wiki_data.Interwikimap_list()); break;
|
||||
case Tid_namespacealiases : Parse_namespacealiases(Json_ary.cast(sub.Val()), wiki_data.Namespacealiases_list()); break;
|
||||
case Tid_specialpagealiases : Parse_specialpagealiases(Json_ary.cast(sub.Val()), wiki_data.Specialpagealiases_list()); break;
|
||||
case Tid_libraries : Parse_libraries(Json_ary.cast(sub.Val()), wiki_data.Libraries_list()); break;
|
||||
case Tid_extensions : Parse_extensions(Json_ary.cast(sub.Val()), wiki_data.Extensions_list()); break;
|
||||
case Tid_skins : Parse_skins(Json_ary.cast(sub.Val()), wiki_data.Skins_list()); break;
|
||||
case Tid_magicwords : Parse_magicwords(Json_ary.cast(sub.Val()), wiki_data.Magicwords_list()); break;
|
||||
case Tid_functionhooks : Parse_val(Json_ary.cast(sub.Val()), wiki_data.Functionhooks_list()); break;
|
||||
case Tid_showhooks : Parse_showhooks(Json_ary.cast(sub.Val()), wiki_data.Showhooks_list()); break;
|
||||
case Tid_extensiontags : Parse_val(Json_ary.cast(sub.Val()), wiki_data.Extensiontags_list()); break;
|
||||
case Tid_protocols : Parse_val(Json_ary.cast(sub.Val()), wiki_data.Protocols_list()); break;
|
||||
case Tid_defaultoptions : Parse_kv(Json_nde.cast_(sub.Val()), wiki_data.Defaultoptions_list()); break;
|
||||
case Tid_languages : Parse_languages(Json_ary.cast(sub.Val()), wiki_data.Languages_list()); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// private void Parse_general(Json_nde nde, Ordered_hash list) {}
|
||||
private void Parse_namespaces(Json_nde nde, Ordered_hash list) {}
|
||||
// private void Parse_statistics(Json_nde nde, Ordered_hash list) {}
|
||||
private void Parse_interwikimap(Json_ary ary, Ordered_hash list) {}
|
||||
private void Parse_namespacealiases(Json_ary ary, Ordered_hash list) {
|
||||
int len = ary.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Json_nde sub = ary.Get_at_as_nde(i);
|
||||
Fail_if_wrong_count(sub, sub.Len(), 2, "namespacealias");
|
||||
byte[] id_bry = sub.Get_bry(Atr_namespacealias_id);
|
||||
int id = Bry_.Xto_int_or(id_bry, Int_.MaxValue); if (id == Int_.MaxValue) throw Err_.new_("wmf.data", "invalid id for namespacealias", "id", id_bry, "src", Extract(sub));
|
||||
list.Add(id, new Xowmf_namespacealias_itm(id, sub.Get_bry(Atr_namespacealias_alias)));
|
||||
}
|
||||
}
|
||||
private void Parse_specialpagealiases(Json_ary ary, Ordered_hash list) {
|
||||
int len = ary.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Json_nde sub = ary.Get_at_as_nde(i);
|
||||
Fail_if_wrong_count(sub, sub.Len(), 2, "specialpagealias");
|
||||
byte[] key = sub.Get_bry(Atr_specialpagealias_realname);
|
||||
Json_ary aliases_ary = Json_ary.cast(sub.Get(Atr_specialpagealias_aliases));
|
||||
list.Add(key, new Xowmf_specialpagealias_itm(key, aliases_ary.Xto_bry_ary()));
|
||||
}
|
||||
}
|
||||
private void Parse_libraries(Json_ary ary, Ordered_hash list) {
|
||||
int len = ary.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Json_nde sub = ary.Get_at_as_nde(i);
|
||||
Fail_if_wrong_count(sub, sub.Len(), 2, "library");
|
||||
byte[] key = sub.Get_bry(Atr_libraries_name);
|
||||
list.Add(key, new Xowmf_library_itm(key, sub.Get_bry(Atr_libraries_version)));
|
||||
}
|
||||
}
|
||||
private void Parse_extensions(Json_ary ary, Ordered_hash list) {}
|
||||
private void Parse_skins(Json_ary ary, Ordered_hash list) {
|
||||
int len = ary.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Json_nde sub = ary.Get_at_as_nde(i);
|
||||
Fail_if_wrong_count(sub, sub.Len(), 3, "skin");
|
||||
byte[] key = sub.Get_bry(Atr_skins_code);
|
||||
list.Add(key, new Xowmf_skin_itm(key, sub.Get_bry(Atr_skins_dflt), sub.Get_bry(Atr_skins_name)));
|
||||
}
|
||||
}
|
||||
private void Parse_magicwords(Json_ary ary, Ordered_hash list) {}
|
||||
// private void Parse_functionhooks(Json_ary ary, Ordered_hash list) {}
|
||||
private void Parse_showhooks(Json_ary ary, Ordered_hash list) {}
|
||||
// private void Parse_extensiontags(Json_ary ary, Ordered_hash list) {}
|
||||
private void Parse_languages(Json_ary ary, Ordered_hash list) {
|
||||
int len = ary.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Json_nde sub = ary.Get_at_as_nde(i);
|
||||
Fail_if_wrong_count(sub, sub.Len(), 2, "language");
|
||||
byte[] key = sub.Get_bry(Atr_languages_code);
|
||||
list.Add(key, new Xowmf_language_itm(key, sub.Get_bry(Atr_languages_name)));
|
||||
}
|
||||
}
|
||||
private void Parse_val(Json_ary ary, Ordered_hash list) {
|
||||
int len = ary.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
byte[] val = ary.Get_at(i).Data_bry();
|
||||
list.Add(val, new Xowmf_val_itm(val));
|
||||
}
|
||||
}
|
||||
private void Parse_kv(Json_nde nde, Ordered_hash list) {
|
||||
int len = nde.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Json_kv sub = nde.Get_at_as_kv(i);
|
||||
byte[] key = sub.Key_as_bry();
|
||||
list.Add(key, new Xowmf_kv_itm(key, sub.Val_as_bry()));
|
||||
}
|
||||
}
|
||||
private byte[] Extract(Json_itm itm) {return Bry_.Mid(src, itm.Src_bgn(), itm.Src_end());}
|
||||
private void Fail_if_wrong_count(Json_itm itm, int expd, int actl, String type) {
|
||||
if (expd != actl) throw Err_.new_("wmf.data", "node does not have expected attribute count", "type", type, "expd", expd, "actl", actl, "src", Extract(itm));
|
||||
}
|
||||
private static final int
|
||||
Tid_general = 0
|
||||
, Tid_namespaces = 1
|
||||
, Tid_statistics = 2
|
||||
, Tid_interwikimap = 3
|
||||
, Tid_namespacealiases = 4
|
||||
, Tid_specialpagealiases = 5
|
||||
, Tid_libraries = 6
|
||||
, Tid_extensions = 7
|
||||
, Tid_skins = 8
|
||||
, Tid_magicwords = 9
|
||||
, Tid_functionhooks = 10
|
||||
, Tid_showhooks = 11
|
||||
, Tid_extensiontags = 12
|
||||
, Tid_protocols = 13
|
||||
, Tid_defaultoptions = 14
|
||||
, Tid_languages = 15
|
||||
;
|
||||
private static final byte[]
|
||||
Nde_general = Bry_.new_a7("general")
|
||||
, Nde_namespaces = Bry_.new_a7("namespaces")
|
||||
, Nde_statistics = Bry_.new_a7("statistics")
|
||||
, Nde_interwikimap = Bry_.new_a7("interwikimap")
|
||||
, Nde_namespacealiases = Bry_.new_a7("namespacealiases")
|
||||
, Nde_specialpagealiases = Bry_.new_a7("specialpagealiases")
|
||||
, Nde_libraries = Bry_.new_a7("libraries")
|
||||
, Nde_extensions = Bry_.new_a7("extensions")
|
||||
, Nde_skins = Bry_.new_a7("skins")
|
||||
, Nde_magicwords = Bry_.new_a7("magicwords")
|
||||
, Nde_functionhooks = Bry_.new_a7("functionhooks")
|
||||
, Nde_showhooks = Bry_.new_a7("showhooks")
|
||||
, Nde_extensiontags = Bry_.new_a7("extensiontags")
|
||||
, Nde_protocols = Bry_.new_a7("protocols")
|
||||
, Nde_defaultoptions = Bry_.new_a7("defaultoptions")
|
||||
, Nde_languages = Bry_.new_a7("languages")
|
||||
, Atr_namespacealias_id = Bry_.new_a7("id"), Atr_namespacealias_alias = Bry_.new_a7("*")
|
||||
, Atr_specialpagealias_realname = Bry_.new_a7("realname"), Atr_specialpagealias_aliases = Bry_.new_a7("aliases")
|
||||
, Atr_libraries_name = Bry_.new_a7("name"), Atr_libraries_version = Bry_.new_a7("version")
|
||||
, Atr_skins_code = Bry_.new_a7("code"), Atr_skins_dflt = Bry_.new_a7("de"+"fault"), Atr_skins_name = Bry_.new_a7("*")
|
||||
, Atr_languages_code = Bry_.new_a7("code"), Atr_languages_name = Bry_.new_a7("*")
|
||||
;
|
||||
private static final Hash_adp_bry nde_hash = Hash_adp_bry.cs_()
|
||||
.Add_bry_int(Nde_general , Tid_general)
|
||||
.Add_bry_int(Nde_namespaces , Tid_namespaces)
|
||||
.Add_bry_int(Nde_statistics , Tid_statistics)
|
||||
.Add_bry_int(Nde_interwikimap , Tid_interwikimap)
|
||||
.Add_bry_int(Nde_namespacealiases , Tid_namespacealiases)
|
||||
.Add_bry_int(Nde_specialpagealiases , Tid_specialpagealiases)
|
||||
.Add_bry_int(Nde_libraries , Tid_libraries)
|
||||
.Add_bry_int(Nde_extensions , Tid_extensions)
|
||||
.Add_bry_int(Nde_skins , Tid_skins)
|
||||
.Add_bry_int(Nde_magicwords , Tid_magicwords)
|
||||
.Add_bry_int(Nde_functionhooks , Tid_functionhooks)
|
||||
.Add_bry_int(Nde_showhooks , Tid_showhooks)
|
||||
.Add_bry_int(Nde_extensiontags , Tid_extensiontags)
|
||||
.Add_bry_int(Nde_protocols , Tid_protocols)
|
||||
.Add_bry_int(Nde_defaultoptions , Tid_defaultoptions)
|
||||
.Add_bry_int(Nde_languages , Tid_languages)
|
||||
;
|
||||
}
|
||||
/*
|
||||
"general": {
|
||||
"mainpage": "Main Page",
|
||||
"super": "https://en.wikipedia.org/wiki/Main_Page",
|
||||
"sitename": "Wikipedia",
|
||||
"logo": "//en.wikipedia.org/static/images/project-logos/enwiki.png",
|
||||
"generator": "MediaWiki 1.26wmf6",
|
||||
"phpversion": "5.6.99-hhvm",
|
||||
"phpsapi": "srv",
|
||||
"hhvmversion": "3.6.1",
|
||||
"dbtype": "mysql",
|
||||
"dbversion": "10.0.16-MariaDB-log",
|
||||
"imagewhitelistenabled": "",
|
||||
"langconversion": "",
|
||||
"titleconversion": "",
|
||||
"linkprefixcharset": "",
|
||||
"linkprefix": "",
|
||||
"linktrail": "/^([a-z]+)(.*)$/sD",
|
||||
"legaltitlechars": " %!\"$&'()*,\\-.\\/0-9:;=?@A-Z\\\\^_`a-z~\\x80-\\xFF+",
|
||||
"invalidusernamechars": "@:",
|
||||
"git-hash": "84635a11fc9b739d84d9d108565d53d4ff4342b9",
|
||||
"git-branch": "wmf/1.26wmf6",
|
||||
"case": "first-letter",
|
||||
"lang": "en",
|
||||
"fallback": [],
|
||||
"fallback8bitEncoding": "windows-1252",
|
||||
"writeapi": "",
|
||||
"timezone": "UTC",
|
||||
"timeoffset": 0,
|
||||
"articlepath": "/wiki/$1",
|
||||
"scriptpath": "/w",
|
||||
"script": "/w/index.php",
|
||||
"variantarticlepath": false,
|
||||
"server": "//en.wikipedia.org",
|
||||
"servername": "en.wikipedia.org",
|
||||
"wikiid": "enwiki",
|
||||
"time": "2015-05-25T10:52:53Z",
|
||||
"misermode": "",
|
||||
"maxuploadsize": 1048576000,
|
||||
"thumblimits": [
|
||||
120,
|
||||
150,
|
||||
180,
|
||||
200,
|
||||
220,
|
||||
250,
|
||||
300
|
||||
],
|
||||
"imagelimits": [
|
||||
{
|
||||
"width": 320,
|
||||
"height": 240
|
||||
},
|
||||
{
|
||||
"width": 640,
|
||||
"height": 480
|
||||
},
|
||||
{
|
||||
"width": 800,
|
||||
"height": 600
|
||||
},
|
||||
{
|
||||
"width": 1024,
|
||||
"height": 768
|
||||
},
|
||||
{
|
||||
"width": 1280,
|
||||
"height": 1024
|
||||
}
|
||||
],
|
||||
"favicon": "//en.wikipedia.org/static/favicon/wikipedia.ico"
|
||||
},
|
||||
|
||||
"namespaces": {
|
||||
"-2": {
|
||||
"id": -2,
|
||||
"case": "first-letter",
|
||||
"canonical": "Media",
|
||||
"*": "Media"
|
||||
},
|
||||
interwikimap
|
||||
{
|
||||
"prefix": "zh-classical",
|
||||
"local": "",
|
||||
"language": "\u6587\u8a00",
|
||||
"url": "https://zh-classical.wikipedia.org/wiki/$1",
|
||||
"protorel": ""
|
||||
},
|
||||
|
||||
extension
|
||||
{
|
||||
"type": "other",
|
||||
"name": "CirrusSearch",
|
||||
"descriptionmsg": "cirrussearch-desc",
|
||||
"author": "Nik Everett, Chad Horohoe",
|
||||
"url": "https://www.mediawiki.org/wiki/Extension:CirrusSearch",
|
||||
"version": "0.2",
|
||||
"vcs-system": "git",
|
||||
"vcs-version": "841147fa90ceafc64fb1573d6a6c010b04df2f64",
|
||||
"vcs-url": "https://git.wikimedia.org/tree/mediawiki%2Fextensions%2FCirrusSearch.git/841147fa90ceafc64fb1573d6a6c010b04df2f64",
|
||||
"vcs-date": "2015-05-13T16:18:35Z",
|
||||
"license-name": "GPL-2.0+",
|
||||
"license": "/wiki/Special:Version/License/CirrusSearch",
|
||||
"credits": "/wiki/Special:Version/Credits/CirrusSearch"
|
||||
},
|
||||
|
||||
magicword
|
||||
{
|
||||
"name": "revisionday",
|
||||
"aliases": [
|
||||
"REVISIONDAY"
|
||||
],
|
||||
"case-sensitive": ""
|
||||
},
|
||||
|
||||
showhook
|
||||
{
|
||||
"name": "APIGetAllowedParams",
|
||||
"subscribers": [
|
||||
"FlaggedRevsApiHooks::addApiRevisionParams",
|
||||
"ConfirmEditHooks::APIGetAllowedParams",
|
||||
"CentralAuthHooks::onAPIGetAllowedParams",
|
||||
"ApiParseExtender::onAPIGetAllowedParams"
|
||||
]
|
||||
},
|
||||
*/
|
23
400_xowa/src/gplx/xowa/wmfs/data/Xowmf_kv_itm.java
Normal file
23
400_xowa/src/gplx/xowa/wmfs/data/Xowmf_kv_itm.java
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
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.xowa.wmfs.data; import gplx.*; import gplx.xowa.*; import gplx.xowa.wmfs.*;
|
||||
class Xowmf_kv_itm {
|
||||
public Xowmf_kv_itm(byte[] key, byte[] val) {this.key = key; this.val = val;}
|
||||
public byte[] Key() {return key;} private final byte[] key;
|
||||
public byte[] Val() {return val;} private final byte[] val;
|
||||
}
|
23
400_xowa/src/gplx/xowa/wmfs/data/Xowmf_language_itm.java
Normal file
23
400_xowa/src/gplx/xowa/wmfs/data/Xowmf_language_itm.java
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
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.xowa.wmfs.data; import gplx.*; import gplx.xowa.*; import gplx.xowa.wmfs.*;
|
||||
class Xowmf_language_itm {
|
||||
public Xowmf_language_itm(byte[] code, byte[] name) {this.code = code; this.name = name;}
|
||||
public byte[] Code() {return code;} private final byte[] code;
|
||||
public byte[] Name() {return name;} private final byte[] name;
|
||||
}
|
45
400_xowa/src/gplx/xowa/wmfs/data/Xowmf_language_tbl.java
Normal file
45
400_xowa/src/gplx/xowa/wmfs/data/Xowmf_language_tbl.java
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
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.xowa.wmfs.data; import gplx.*; import gplx.xowa.*; import gplx.xowa.wmfs.*;
|
||||
import gplx.dbs.*;
|
||||
class Xowmf_language_tbl implements RlsAble {
|
||||
private static final String tbl_name = "wmf_language"; private final Db_meta_fld_list flds = new Db_meta_fld_list();
|
||||
private final String fld_site_id, fld_code, fld_name;
|
||||
private final Db_conn conn;
|
||||
private Db_stmt stmt_insert;
|
||||
public Xowmf_language_tbl(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
this.fld_site_id = flds.Add_int("site_id");
|
||||
this.fld_code = flds.Add_str("code", 255);
|
||||
this.fld_name = flds.Add_str("name", 255);
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public void Create_tbl() {conn.Ddl_create_tbl(Db_meta_tbl.new_(tbl_name, flds, Db_meta_idx.new_unique_by_name(tbl_name, "main", fld_site_id, fld_code)));}
|
||||
public void Delete_all() {conn.Stmt_delete(tbl_name, Db_meta_fld.Ary_empty).Exec_delete();}
|
||||
public void Rls() {
|
||||
stmt_insert = Db_stmt_.Rls(stmt_insert);
|
||||
}
|
||||
public void Insert(int site_id, byte[] code, byte[] name) {
|
||||
if (stmt_insert == null) stmt_insert = conn.Stmt_insert(tbl_name, flds);
|
||||
stmt_insert.Clear()
|
||||
.Val_int(fld_site_id , site_id)
|
||||
.Val_bry_as_str(fld_code , code)
|
||||
.Val_bry_as_str(fld_name , name)
|
||||
.Exec_insert();
|
||||
}
|
||||
}
|
23
400_xowa/src/gplx/xowa/wmfs/data/Xowmf_library_itm.java
Normal file
23
400_xowa/src/gplx/xowa/wmfs/data/Xowmf_library_itm.java
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
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.xowa.wmfs.data; import gplx.*; import gplx.xowa.*; import gplx.xowa.wmfs.*;
|
||||
class Xowmf_library_itm {
|
||||
public Xowmf_library_itm(byte[] name, byte[] version) {this.name = name; this.version = version;}
|
||||
public byte[] Name() {return name;} private final byte[] name;
|
||||
public byte[] Version() {return version;} private final byte[] version;
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
/*
|
||||
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.xowa.wmfs.data; import gplx.*; import gplx.xowa.*; import gplx.xowa.wmfs.*;
|
||||
class Xowmf_namespacealias_itm {
|
||||
public Xowmf_namespacealias_itm(int id, byte[] alias) {this.id = id; this.alias = alias;}
|
||||
public int Id() {return id;} private final int id;
|
||||
public byte[] Alias() {return alias;} private final byte[] alias;
|
||||
}
|
43
400_xowa/src/gplx/xowa/wmfs/data/Xowmf_protocol_tbl.java
Normal file
43
400_xowa/src/gplx/xowa/wmfs/data/Xowmf_protocol_tbl.java
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
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.xowa.wmfs.data; import gplx.*; import gplx.xowa.*; import gplx.xowa.wmfs.*;
|
||||
import gplx.dbs.*;
|
||||
class Xowmf_protocol_tbl implements RlsAble {
|
||||
private static final String tbl_name = "wmf_protocol"; private final Db_meta_fld_list flds = new Db_meta_fld_list();
|
||||
private final String fld_site_id, fld_val;
|
||||
private final Db_conn conn;
|
||||
private Db_stmt stmt_insert;
|
||||
public Xowmf_protocol_tbl(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
this.fld_site_id = flds.Add_int("site_id");
|
||||
this.fld_val = flds.Add_str("val", 255);
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public void Create_tbl() {conn.Ddl_create_tbl(Db_meta_tbl.new_(tbl_name, flds));}
|
||||
public void Delete_all() {conn.Stmt_delete(tbl_name, Db_meta_fld.Ary_empty).Exec_delete();}
|
||||
public void Rls() {
|
||||
stmt_insert = Db_stmt_.Rls(stmt_insert);
|
||||
}
|
||||
public void Insert(int site_id, byte[] val) {
|
||||
if (stmt_insert == null) stmt_insert = conn.Stmt_insert(tbl_name, flds);
|
||||
stmt_insert.Clear()
|
||||
.Val_int(fld_site_id , site_id)
|
||||
.Val_bry_as_str(fld_val , val)
|
||||
.Exec_insert();
|
||||
}
|
||||
}
|
26
400_xowa/src/gplx/xowa/wmfs/data/Xowmf_skin_itm.java
Normal file
26
400_xowa/src/gplx/xowa/wmfs/data/Xowmf_skin_itm.java
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
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.xowa.wmfs.data; import gplx.*; import gplx.xowa.*; import gplx.xowa.wmfs.*;
|
||||
class Xowmf_skin_itm {
|
||||
public Xowmf_skin_itm(byte[] code, byte[] dflt, byte[] name) {
|
||||
this.code = code; this.dflt = dflt; this.name = name;
|
||||
}
|
||||
public byte[] Code() {return code;} private final byte[] code;
|
||||
public byte[] Dflt() {return dflt;} private final byte[] dflt;
|
||||
public byte[] Name() {return name;} private final byte[] name;
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
/*
|
||||
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.xowa.wmfs.data; import gplx.*; import gplx.xowa.*; import gplx.xowa.wmfs.*;
|
||||
class Xowmf_specialpagealias_itm {
|
||||
public Xowmf_specialpagealias_itm(byte[] realname, byte[][] aliases) {this.realname = realname; this.aliases = aliases;}
|
||||
public byte[] Realname() {return realname;} private final byte[] realname;
|
||||
public byte[][] Aliases() {return aliases;} private final byte[][] aliases;
|
||||
}
|
@ -17,12 +17,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wmfs.data; import gplx.*; import gplx.xowa.*; import gplx.xowa.wmfs.*;
|
||||
import gplx.dbs.*;
|
||||
class Xowmf_specialpagealiases_tbl implements RlsAble {
|
||||
class Xowmf_specialpagealias_tbl implements RlsAble {
|
||||
private static final String tbl_name = "wmf_specialpagealiases"; private final Db_meta_fld_list flds = new Db_meta_fld_list();
|
||||
private final String fld_site_id, fld_realname, fld_aliases;
|
||||
private final Db_conn conn;
|
||||
private Db_stmt stmt_insert;
|
||||
public Xowmf_specialpagealiases_tbl(Db_conn conn) {
|
||||
public Xowmf_specialpagealias_tbl(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
this.fld_site_id = flds.Add_int("site_id");
|
||||
this.fld_realname = flds.Add_str("realname", 255);
|
22
400_xowa/src/gplx/xowa/wmfs/data/Xowmf_val_itm.java
Normal file
22
400_xowa/src/gplx/xowa/wmfs/data/Xowmf_val_itm.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.xowa.wmfs.data; import gplx.*; import gplx.xowa.*; import gplx.xowa.wmfs.*;
|
||||
class Xowmf_val_itm {
|
||||
public Xowmf_val_itm(byte[] val) {this.val = val;}
|
||||
public byte[] Val() {return val;} private byte[] val;
|
||||
}
|
36
400_xowa/src/gplx/xowa/wmfs/data/Xowmf_wiki_data.java
Normal file
36
400_xowa/src/gplx/xowa/wmfs/data/Xowmf_wiki_data.java
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
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.xowa.wmfs.data; import gplx.*; import gplx.xowa.*; import gplx.xowa.wmfs.*;
|
||||
class Xowmf_wiki_data {
|
||||
public Ordered_hash General_list() {return general_list;} private final Ordered_hash general_list = Ordered_hash_.new_bry_();
|
||||
public Ordered_hash Namespaces_list() {return namespaces_list;} private final Ordered_hash namespaces_list = Ordered_hash_.new_bry_();
|
||||
public Ordered_hash Statistics_list() {return statistics_list;} private final Ordered_hash statistics_list = Ordered_hash_.new_bry_();
|
||||
public Ordered_hash Interwikimap_list() {return interwikimap_list;} private final Ordered_hash interwikimap_list = Ordered_hash_.new_bry_();
|
||||
public Ordered_hash Namespacealiases_list() {return namespacealiases_list;} private final Ordered_hash namespacealiases_list = Ordered_hash_.new_bry_();
|
||||
public Ordered_hash Specialpagealiases_list() {return specialpagealiases_list;} private final Ordered_hash specialpagealiases_list = Ordered_hash_.new_bry_();
|
||||
public Ordered_hash Libraries_list() {return libraries_list;} private final Ordered_hash libraries_list = Ordered_hash_.new_bry_();
|
||||
public Ordered_hash Extensions_list() {return extensions_list;} private final Ordered_hash extensions_list = Ordered_hash_.new_bry_();
|
||||
public Ordered_hash Skins_list() {return skins_list;} private final Ordered_hash skins_list = Ordered_hash_.new_bry_();
|
||||
public Ordered_hash Magicwords_list() {return magicwords_list;} private final Ordered_hash magicwords_list = Ordered_hash_.new_bry_();
|
||||
public Ordered_hash Functionhooks_list() {return functionhooks_list;} private final Ordered_hash functionhooks_list = Ordered_hash_.new_bry_();
|
||||
public Ordered_hash Showhooks_list() {return showhooks_list;} private final Ordered_hash showhooks_list = Ordered_hash_.new_bry_();
|
||||
public Ordered_hash Extensiontags_list() {return extensiontags_list;} private final Ordered_hash extensiontags_list = Ordered_hash_.new_bry_();
|
||||
public Ordered_hash Protocols_list() {return protocols_list;} private final Ordered_hash protocols_list = Ordered_hash_.new_bry_();
|
||||
public Ordered_hash Defaultoptions_list() {return defaultoptions_list;} private final Ordered_hash defaultoptions_list = Ordered_hash_.new_bry_();
|
||||
public Ordered_hash Languages_list() {return languages_list;} private final Ordered_hash languages_list = Ordered_hash_.new_bry_();
|
||||
}
|
@ -49,7 +49,7 @@ public class Scrib_lib_ustring__lib_tst {
|
||||
Exec_match("aaa" , "(a)" , 1, "a;a;a"); // should return all matches
|
||||
Exec_match("a b" , "%S" , 1, "a"); // %S was returning every match instead of 1st; PAGE:en.w:Bertrand_Russell; DATE:2014-04-02
|
||||
Exec_match(1 , "a" , 1, String_.Null_mark); // Module can pass raw ints; PAGE:en.w:Budget_of_the_European_Union; DATE:2015-01-22
|
||||
Exec_match("" , "a?" , 1, ""); // no results with ? should return "" not nil; PAGE:en.d:民; DATE:2015-01-30
|
||||
Exec_match("" , "a?" , 1, ""); // no results with ? should return "" not nil; PAGE:en.d:民; DATE:2015-01-30
|
||||
}
|
||||
@Test public void Match_args_out_of_order() {
|
||||
fxt.Test_scrib_proc_empty(lib, Scrib_lib_ustring.Invk_match, KeyVal_.Ary(KeyVal_.int_(2, "[a]")));
|
||||
@ -116,6 +116,11 @@ public class Scrib_lib_ustring__lib_tst {
|
||||
, " 1=2"
|
||||
));
|
||||
}
|
||||
@Test public void Gsub_frontier_pattern() { // PURPOSE: handle frontier pattern; EX:"%f[%a]"; NOTE:test will fail if run in 1.6 environment; DATE:2015-07-20
|
||||
// fxt.Init_cbk(Scrib_core.Key_mw_interface, fxt.Core().Lib_ustring(), Scrib_lib_ustring.Invk_gsub);
|
||||
// //Exec_gsub_regx("THE QUICK brOWN FOx JUMPS", "%f[%a]%u+%f[%A]", 1, "", "THE;1;QUICK;2;JUMPS;3;");
|
||||
// Exec_gsub_regx("thE QUICK brOWN FOx JUMPS", "%f[%a]%u+%f[%A]", 1, "", "THE;1;QUICK;2;JUMPS;3;");
|
||||
}
|
||||
// @Test public void Match_viwiktionary() {
|
||||
// fxt.Init_cbk(Scrib_core.Key_mw_interface, fxt.Core().Lib_ustring(), Scrib_lib_ustring.Invk_match);
|
||||
// Exec_match("tr" , "()(r)", 1, ";"); // should return all matches
|
||||
|
@ -71,7 +71,7 @@ public class Scrib_regx_converter {
|
||||
switch (nxt) {
|
||||
case Byte_ascii.Ltr_b: // EX: "%b()"
|
||||
i += 2;
|
||||
if (i >= len) throw Err_.new_wo_type("malformed pattern (missing arguments to \'%b\')");
|
||||
if (i >= len) throw Err_.new_wo_type("malformed pattern (missing arguments to '%b')");
|
||||
byte char_0 = src[i - 1];
|
||||
byte char_1 = src[i];
|
||||
if (char_0 == char_1) { // same char: easier regex; REF.MW: $bfr .= "{$d1}[^$d1]*$d1";
|
||||
@ -94,6 +94,22 @@ public class Scrib_regx_converter {
|
||||
}
|
||||
}
|
||||
break;
|
||||
// case Byte_ascii.Ltr_f: { // EX: "%f[%a]"
|
||||
// ++i;
|
||||
// if (i + 1 >= len || src[i] != Byte_ascii.Brack_bgn) throw Err_.new_("scribunto", "missing '[' after %f in pattern at pattern character $ii");
|
||||
// Bry_bfr tmp_bfr = Xoa_app_.Utl__bfr_mkr().Get_b128();
|
||||
// i = bracketedCharSetToRegex(tmp_bfr, src, i, len);
|
||||
// byte[] bracketed_regx = tmp_bfr.To_bry_and_rls();
|
||||
// int j = 1;
|
||||
// bfr.Add_str_a7("(?<!").Add(bracketed_regx).Add_str_a7(")(?=$").Add(bracketed_regx).Add_str_a7(")");
|
||||
//// if ( preg_match( "/$re2/us", "\0" ) ) {
|
||||
//// $re .= "(?<!^)(?<!$re2)(?=$re2|$)";
|
||||
//// } else {
|
||||
//// $re .= "(?<!$re2)(?=$re2)";
|
||||
//// }
|
||||
//
|
||||
// break;
|
||||
// }
|
||||
case Byte_ascii.Num_0: case Byte_ascii.Num_1: case Byte_ascii.Num_2: case Byte_ascii.Num_3: case Byte_ascii.Num_4:
|
||||
case Byte_ascii.Num_5: case Byte_ascii.Num_6: case Byte_ascii.Num_7: case Byte_ascii.Num_8: case Byte_ascii.Num_9:
|
||||
grps_len = nxt - Byte_ascii.Num_0;
|
||||
@ -109,52 +125,7 @@ public class Scrib_regx_converter {
|
||||
}
|
||||
break;
|
||||
case Byte_ascii.Brack_bgn:
|
||||
bfr.Add_byte(Byte_ascii.Brack_bgn);
|
||||
++i;
|
||||
if (i < len && src[i] == Byte_ascii.Pow) { // ^
|
||||
bfr.Add_byte(Byte_ascii.Pow);
|
||||
++i;
|
||||
}
|
||||
boolean stop = false;
|
||||
for (; i < len; i++) {
|
||||
byte tmp_b = src[i];
|
||||
switch (tmp_b) {
|
||||
case Byte_ascii.Brack_end:
|
||||
stop = true;
|
||||
break;
|
||||
case Byte_ascii.Percent:
|
||||
++i;
|
||||
if (i >= len)
|
||||
stop = true;
|
||||
else {
|
||||
Object brack_obj = brack_hash.Get_by_mid(src, i, i + 1);
|
||||
if (brack_obj != null)
|
||||
bfr.Add((byte[])brack_obj);
|
||||
else
|
||||
Regx_quote(bfr, src[i]);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
boolean normal = true;
|
||||
if (i + 2 < len) {
|
||||
byte dash_1 = src[i + 1];
|
||||
byte dash_2 = src[i + 2];
|
||||
if (dash_1 == Byte_ascii.Dash && dash_2 != Byte_ascii.Brack_end) {
|
||||
Regx_quote(bfr, tmp_b);
|
||||
bfr.Add_byte(Byte_ascii.Dash);
|
||||
Regx_quote(bfr, dash_2);
|
||||
i += 2;
|
||||
normal = false;
|
||||
}
|
||||
}
|
||||
if (normal)
|
||||
Regx_quote(bfr, src[i]);
|
||||
break;
|
||||
}
|
||||
if (stop) break;
|
||||
}
|
||||
if (i >= len) throw Err_.new_wo_type("Missing close-bracket for character set beginning at pattern character $nxt_pos");
|
||||
bfr.Add_byte(Byte_ascii.Brack_end);
|
||||
i = bracketedCharSetToRegex(bfr, src, i, len);
|
||||
q_flag = true;
|
||||
break;
|
||||
case Byte_ascii.Brack_end: throw Err_.new_wo_type("Unmatched close-bracket at pattern character " + Int_.Xto_str(i));
|
||||
@ -188,6 +159,55 @@ public class Scrib_regx_converter {
|
||||
regx = bfr.Xto_str_and_clear();
|
||||
return regx;
|
||||
} private Bry_bfr bfr = Bry_bfr.new_();
|
||||
private int bracketedCharSetToRegex(Bry_bfr bfr, byte[] src, int i, int len) {
|
||||
bfr.Add_byte(Byte_ascii.Brack_bgn);
|
||||
++i;
|
||||
if (i < len && src[i] == Byte_ascii.Pow) { // ^
|
||||
bfr.Add_byte(Byte_ascii.Pow);
|
||||
++i;
|
||||
}
|
||||
boolean stop = false;
|
||||
for (; i < len; i++) {
|
||||
byte tmp_b = src[i];
|
||||
switch (tmp_b) {
|
||||
case Byte_ascii.Brack_end:
|
||||
stop = true;
|
||||
break;
|
||||
case Byte_ascii.Percent:
|
||||
++i;
|
||||
if (i >= len)
|
||||
stop = true;
|
||||
else {
|
||||
Object brack_obj = brack_hash.Get_by_mid(src, i, i + 1);
|
||||
if (brack_obj != null)
|
||||
bfr.Add((byte[])brack_obj);
|
||||
else
|
||||
Regx_quote(bfr, src[i]);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
boolean normal = true;
|
||||
if (i + 2 < len) {
|
||||
byte dash_1 = src[i + 1];
|
||||
byte dash_2 = src[i + 2];
|
||||
if (dash_1 == Byte_ascii.Dash && dash_2 != Byte_ascii.Brack_end) {
|
||||
Regx_quote(bfr, tmp_b);
|
||||
bfr.Add_byte(Byte_ascii.Dash);
|
||||
Regx_quote(bfr, dash_2);
|
||||
i += 2;
|
||||
normal = false;
|
||||
}
|
||||
}
|
||||
if (normal)
|
||||
Regx_quote(bfr, src[i]);
|
||||
break;
|
||||
}
|
||||
if (stop) break;
|
||||
}
|
||||
if (i >= len) throw Err_.new_wo_type("Missing close-bracket for character set beginning at pattern character $nxt_pos");
|
||||
bfr.Add_byte(Byte_ascii.Brack_end);
|
||||
return i;
|
||||
}
|
||||
boolean grps_open_Has(List_adp list, int v) {
|
||||
int len = list.Count();
|
||||
for (int i = 0; i < len; i++) {
|
||||
|
@ -40,7 +40,7 @@ public class Wdata_wiki_mgr implements GfoEvObj, GfoInvkAble {
|
||||
public Json_parser Jdoc_parser() {return jdoc_parser;} private Json_parser jdoc_parser = new Json_parser();
|
||||
public void Init_by_app() {}
|
||||
public Wdata_doc_parser Wdoc_parser(Json_doc jdoc) {
|
||||
Json_itm_kv itm_0 = Json_itm_kv.cast_(jdoc.Root().Get_at(0)); // get 1st node
|
||||
Json_kv itm_0 = Json_kv.cast_(jdoc.Root().Get_at(0)); // get 1st node
|
||||
return Bry_.Eq(itm_0.Key().Data_bry(), Wdata_doc_parser_v2.Bry_type)
|
||||
|| Bry_.Eq(itm_0.Key().Data_bry(), Wdata_doc_parser_v2.Bry_id)
|
||||
? wdoc_parser_v2 : wdoc_parser_v1; // if "type", must be v2
|
||||
|
@ -102,7 +102,7 @@ abstract class Wdata_tbl_base {
|
||||
public static void Exec_insert_kvs(Db_stmt stmt, int page_id, Ordered_hash hash) {
|
||||
int len = hash.Count();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Json_itm_kv kv = (Json_itm_kv)hash.Get_at(i);
|
||||
Json_kv kv = (Json_kv)hash.Get_at(i);
|
||||
stmt.Clear()
|
||||
.Val_int(page_id)
|
||||
.Val_bry_as_str(kv.Key().Data_bry())
|
||||
@ -145,7 +145,7 @@ class Wdata_alias_tbl extends Wdata_tbl_base {
|
||||
int len = hash.Count();
|
||||
Db_stmt insert_stmt = this.Insert_stmt();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Json_itm_kv kv = (Json_itm_kv)hash.Get_at(i);
|
||||
Json_kv kv = (Json_kv)hash.Get_at(i);
|
||||
byte[] key = kv.Key().Data_bry();
|
||||
Json_grp val_grp = (Json_grp)kv.Val();
|
||||
int val_grp_len = val_grp.Len();
|
||||
@ -155,7 +155,7 @@ class Wdata_alias_tbl extends Wdata_tbl_base {
|
||||
if (val_itm.Tid() == Json_itm_.Tid_string)
|
||||
val = val_itm.Data_bry();
|
||||
else if (val_itm.Tid() == Json_itm_.Tid_kv) { // EX: q80 and de aliases
|
||||
val = ((Json_itm_kv)val_itm).Val().Data_bry();
|
||||
val = ((Json_kv)val_itm).Val().Data_bry();
|
||||
}
|
||||
insert_stmt.Clear()
|
||||
.Val_int(page_id)
|
||||
@ -201,7 +201,7 @@ class Wdata_link_tbl extends Wdata_tbl_base {
|
||||
int len = hash.Count();
|
||||
Db_stmt insert_stmt = this.Insert_stmt();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Json_itm_kv kv = (Json_itm_kv)hash.Get_at(i);
|
||||
Json_kv kv = (Json_kv)hash.Get_at(i);
|
||||
byte[] key = kv.Key().Data_bry();
|
||||
Json_itm kv_val = kv.Val();
|
||||
byte[] val = Bry_.Empty;
|
||||
@ -209,7 +209,7 @@ class Wdata_link_tbl extends Wdata_tbl_base {
|
||||
val = kv_val.Data_bry();
|
||||
else {
|
||||
Json_nde val_nde = (Json_nde)kv.Val();
|
||||
Json_itm_kv val_name_kv = (Json_itm_kv)val_nde.Get_at(0); // ASSUME: 1st item is always "name" kv; EX: "name":"Earth"
|
||||
Json_kv val_name_kv = (Json_kv)val_nde.Get_at(0); // ASSUME: 1st item is always "name" kv; EX: "name":"Earth"
|
||||
val = val_name_kv.Val().Data_bry();
|
||||
}
|
||||
insert_stmt.Clear()
|
||||
|
@ -19,8 +19,8 @@ package gplx.xowa.xtns.wdatas.parsers; import gplx.*; import gplx.xowa.*; import
|
||||
import gplx.core.primitives.*;
|
||||
import gplx.core.json.*; import gplx.xowa.xtns.wdatas.core.*;
|
||||
class Wdata_claims_parser_v2 {
|
||||
public void Make_claim_itms(byte[] qid, List_adp claim_itms_list, byte[] src, Json_itm_kv claim_grp) {
|
||||
Json_itm_ary claim_itms_ary = Json_itm_ary.cast_(claim_grp.Val());
|
||||
public void Make_claim_itms(byte[] qid, List_adp claim_itms_list, byte[] src, Json_kv claim_grp) {
|
||||
Json_ary claim_itms_ary = Json_ary.cast_or_null(claim_grp.Val());
|
||||
int claim_itms_len = claim_itms_ary.Len();
|
||||
int pid = Parse_pid(claim_grp.Key().Data_bry());
|
||||
for (int i = 0; i < claim_itms_len; ++i) {
|
||||
@ -36,14 +36,14 @@ class Wdata_claims_parser_v2 {
|
||||
byte rank_tid = Wdata_dict_rank.Tid_unknown;
|
||||
Wdata_claim_itm_core claim_itm = null; Wdata_claim_grp_list qualifiers = null; int[] qualifiers_order = null; Wdata_references_grp[] snaks_grp = null;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Json_itm_kv sub = Json_itm_kv.cast_(nde.Get_at(i));
|
||||
Json_kv sub = Json_kv.cast_(nde.Get_at(i));
|
||||
byte tid = Wdata_dict_utl.Get_tid_or_invalid(qid, dict, sub.Key().Data_bry()); if (tid == Wdata_dict_utl.Tid_invalid) continue;
|
||||
switch (tid) {
|
||||
case Wdata_dict_claim.Tid_mainsnak: claim_itm = Parse_mainsnak(qid, Json_nde.cast_(sub.Val()), pid); break;
|
||||
case Wdata_dict_claim.Tid_rank: rank_tid = Wdata_dict_rank.Xto_tid(sub.Val().Data_bry()); break;
|
||||
case Wdata_dict_claim.Tid_references: snaks_grp = Parse_references(qid, Json_itm_ary.cast_(sub.Val())); break;
|
||||
case Wdata_dict_claim.Tid_references: snaks_grp = Parse_references(qid, Json_ary.cast_or_null(sub.Val())); break;
|
||||
case Wdata_dict_claim.Tid_qualifiers: qualifiers = Parse_qualifiers(qid, Json_nde.cast_(sub.Val())); break;
|
||||
case Wdata_dict_claim.Tid_qualifiers_order: qualifiers_order = Parse_pid_order(Json_itm_ary.cast_(sub.Val())); break;
|
||||
case Wdata_dict_claim.Tid_qualifiers_order: qualifiers_order = Parse_pid_order(Json_ary.cast_or_null(sub.Val())); break;
|
||||
case Wdata_dict_claim.Tid_type: break; // ignore: "statement"
|
||||
case Wdata_dict_claim.Tid_id: break; // ignore: "Q2$F909BD1C-D34D-423F-9ED2-3493663321AF"
|
||||
}
|
||||
@ -56,7 +56,7 @@ class Wdata_claims_parser_v2 {
|
||||
}
|
||||
return claim_itm;
|
||||
}
|
||||
public Wdata_references_grp[] Parse_references(byte[] qid, Json_itm_ary owner) {
|
||||
public Wdata_references_grp[] Parse_references(byte[] qid, Json_ary owner) {
|
||||
int len = owner.Len();
|
||||
Wdata_references_grp[] rv = new Wdata_references_grp[len];
|
||||
for (int i = 0; i < len; ++i) {
|
||||
@ -70,12 +70,12 @@ class Wdata_claims_parser_v2 {
|
||||
Hash_adp_bry dict = Wdata_dict_reference.Dict;
|
||||
Wdata_claim_grp_list snaks = null; int[] snaks_order = null;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Json_itm_kv sub = Json_itm_kv.cast_(owner.Get_at(i));
|
||||
Json_kv sub = Json_kv.cast_(owner.Get_at(i));
|
||||
byte tid = Wdata_dict_utl.Get_tid_or_invalid(qid, dict, sub.Key().Data_bry()); if (tid == Wdata_dict_utl.Tid_invalid) continue;
|
||||
switch (tid) {
|
||||
case Wdata_dict_reference.Tid_hash: break; // ignore: "b923b0d68beb300866b87ead39f61e63ec30d8af"
|
||||
case Wdata_dict_reference.Tid_snaks: snaks = Parse_qualifiers(qid, Json_nde.cast_(sub.Val())); break;
|
||||
case Wdata_dict_reference.Tid_snaks_order: snaks_order = Parse_pid_order(Json_itm_ary.cast_(sub.Val())); break;
|
||||
case Wdata_dict_reference.Tid_snaks_order: snaks_order = Parse_pid_order(Json_ary.cast_or_null(sub.Val())); break;
|
||||
}
|
||||
}
|
||||
return new Wdata_references_grp(snaks, snaks_order);
|
||||
@ -85,14 +85,14 @@ class Wdata_claims_parser_v2 {
|
||||
if (qualifiers_nde == null) return rv; // NOTE:sometimes references can have 0 snaks; return back an empty Wdata_claim_grp_list, not null; PAGE:Птичкин,_Евгений_Николаевич; DATE:2015-02-16
|
||||
int len = qualifiers_nde.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Json_itm_kv qualifier_kv = Json_itm_kv.cast_(qualifiers_nde.Get_at(i));
|
||||
Json_kv qualifier_kv = Json_kv.cast_(qualifiers_nde.Get_at(i));
|
||||
int pid = Parse_pid(qualifier_kv.Key().Data_bry());
|
||||
Wdata_claim_grp claims_grp = Parse_props_grp(qid, pid, Json_itm_ary.cast_(qualifier_kv.Val()));
|
||||
Wdata_claim_grp claims_grp = Parse_props_grp(qid, pid, Json_ary.cast_or_null(qualifier_kv.Val()));
|
||||
rv.Add(claims_grp);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public int[] Parse_pid_order(Json_itm_ary ary) {
|
||||
public int[] Parse_pid_order(Json_ary ary) {
|
||||
int len = ary.Len();
|
||||
int[] rv = new int[len];
|
||||
for (int i = 0; i < len; ++i) {
|
||||
@ -101,7 +101,7 @@ class Wdata_claims_parser_v2 {
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
private Wdata_claim_grp Parse_props_grp(byte[] qid, int pid, Json_itm_ary props_ary) {
|
||||
private Wdata_claim_grp Parse_props_grp(byte[] qid, int pid, Json_ary props_ary) {
|
||||
List_adp list = List_adp_.new_();
|
||||
int len = props_ary.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
@ -116,7 +116,7 @@ class Wdata_claims_parser_v2 {
|
||||
Hash_adp_bry dict = Wdata_dict_mainsnak.Dict;
|
||||
byte snak_tid = Byte_.Max_value_127;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Json_itm_kv sub = Json_itm_kv.cast_(nde.Get_at(i));
|
||||
Json_kv sub = Json_kv.cast_(nde.Get_at(i));
|
||||
byte tid = Wdata_dict_utl.Get_tid_or_invalid(qid, dict, sub.Key().Data_bry()); if (tid == Wdata_dict_utl.Tid_invalid) continue;
|
||||
switch (tid) {
|
||||
case Wdata_dict_mainsnak.Tid_snaktype: snak_tid = Wdata_dict_snak_tid.Xto_tid(sub.Val().Data_bry()); break;
|
||||
@ -133,7 +133,7 @@ class Wdata_claims_parser_v2 {
|
||||
Hash_adp_bry dict = Wdata_dict_datavalue.Dict;
|
||||
Json_itm value_itm = null; byte value_tid = Wdata_dict_val_tid.Tid_unknown;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Json_itm_kv sub = Json_itm_kv.cast_(nde.Get_at(i));
|
||||
Json_kv sub = Json_kv.cast_(nde.Get_at(i));
|
||||
byte tid = Wdata_dict_utl.Get_tid_or_invalid(qid, dict, sub.Key().Data_bry()); if (tid == Wdata_dict_utl.Tid_invalid) continue;
|
||||
switch (tid) {
|
||||
case Wdata_dict_datavalue.Tid_type: value_tid = Wdata_dict_val_tid.Xto_tid(sub.Val().Data_bry()); break;
|
||||
@ -157,7 +157,7 @@ class Wdata_claims_parser_v2 {
|
||||
byte entity_tid = Byte_.Max_value_127;
|
||||
byte[] entity_id_bry = null;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Json_itm_kv sub = Json_itm_kv.cast_(nde.Get_at(i));
|
||||
Json_kv sub = Json_kv.cast_(nde.Get_at(i));
|
||||
byte tid = Wdata_dict_utl.Get_tid_or_invalid(qid, dict, sub.Key().Data_bry()); if (tid == Wdata_dict_utl.Tid_invalid) continue;
|
||||
switch (tid) {
|
||||
case Wdata_dict_value_entity.Tid_entity_type: entity_tid = Wdata_dict_value_entity_tid.Xto_tid(sub.Val().Data_bry()); break;
|
||||
@ -172,7 +172,7 @@ class Wdata_claims_parser_v2 {
|
||||
int len = nde.Len();
|
||||
byte[] lang = null, text = null;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Json_itm_kv sub = Json_itm_kv.cast_(nde.Get_at(i));
|
||||
Json_kv sub = Json_kv.cast_(nde.Get_at(i));
|
||||
byte tid = Wdata_dict_utl.Get_tid_or_invalid(qid, dict, sub.Key().Data_bry()); if (tid == Wdata_dict_utl.Tid_invalid) continue;
|
||||
byte[] sub_val_bry = sub.Val().Data_bry();
|
||||
switch (tid) {
|
||||
@ -188,7 +188,7 @@ class Wdata_claims_parser_v2 {
|
||||
int len = nde.Len();
|
||||
byte[] lat = null, lng = null, alt = null, prc = null, glb = null;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Json_itm_kv sub = Json_itm_kv.cast_(nde.Get_at(i));
|
||||
Json_kv sub = Json_kv.cast_(nde.Get_at(i));
|
||||
byte tid = Wdata_dict_utl.Get_tid_or_invalid(qid, dict, sub.Key().Data_bry()); if (tid == Wdata_dict_utl.Tid_invalid) continue;
|
||||
byte[] sub_val_bry = sub.Val().Data_bry();
|
||||
switch (tid) {
|
||||
@ -207,7 +207,7 @@ class Wdata_claims_parser_v2 {
|
||||
int len = nde.Len();
|
||||
byte[] amount = null, unit = null, ubound = null, lbound = null;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Json_itm_kv sub = Json_itm_kv.cast_(nde.Get_at(i));
|
||||
Json_kv sub = Json_kv.cast_(nde.Get_at(i));
|
||||
byte tid = Wdata_dict_utl.Get_tid_or_invalid(qid, dict, sub.Key().Data_bry()); if (tid == Wdata_dict_utl.Tid_invalid) continue;
|
||||
byte[] sub_val_bry = sub.Val().Data_bry();
|
||||
switch (tid) {
|
||||
@ -225,7 +225,7 @@ class Wdata_claims_parser_v2 {
|
||||
int len = nde.Len();
|
||||
byte[] time = null, timezone = null, before = null, after = null, precision = null, calendarmodel = null;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Json_itm_kv sub = Json_itm_kv.cast_(nde.Get_at(i));
|
||||
Json_kv sub = Json_kv.cast_(nde.Get_at(i));
|
||||
byte tid = Wdata_dict_utl.Get_tid_or_invalid(qid, dict, sub.Key().Data_bry()); if (tid == Wdata_dict_utl.Tid_invalid) continue;
|
||||
byte[] sub_val_bry = sub.Val().Data_bry();
|
||||
switch (tid) {
|
||||
|
@ -25,6 +25,6 @@ public interface Wdata_doc_parser {
|
||||
Ordered_hash Parse_claims(byte[] qid, Json_doc doc);
|
||||
Wdata_claim_itm_base Parse_claims_data(byte[] qid, int pid, byte snak_tid, Json_nde nde);
|
||||
Wdata_claim_grp_list Parse_qualifiers(byte[] qid, Json_nde nde);
|
||||
int[] Parse_pid_order(byte[] qid, Json_itm_ary ary);
|
||||
Wdata_references_grp[] Parse_references(byte[] qid, Json_itm_ary owner);
|
||||
int[] Parse_pid_order(byte[] qid, Json_ary ary);
|
||||
Wdata_references_grp[] Parse_references(byte[] qid, Json_ary owner);
|
||||
}
|
||||
|
@ -61,13 +61,13 @@ abstract class Wdata_doc_parser_fxt_base {
|
||||
}
|
||||
public void Test_qualifiers(String raw, Wdata_claim_itm_base... expd_itms) {
|
||||
Json_doc jdoc = Json_doc.new_apos_(raw);
|
||||
Json_nde qualifiers_nde = Json_nde.cast_(Json_itm_kv.cast_(jdoc.Root().Get_at(0)).Val());
|
||||
Json_nde qualifiers_nde = Json_nde.cast_(Json_kv.cast_(jdoc.Root().Get_at(0)).Val());
|
||||
Wdata_claim_grp_list actl = parser.Parse_qualifiers(Q1_bry, qualifiers_nde);
|
||||
Tfds.Eq_ary_str(expd_itms, To_ary(actl));
|
||||
}
|
||||
public void Test_references(String raw, int[] expd_order, Wdata_claim_itm_base... expd_itms) {
|
||||
Json_doc jdoc = Json_doc.new_apos_(raw);
|
||||
Json_itm_ary owner = Json_itm_ary.cast_(Json_itm_kv.cast_(jdoc.Root().Get_at(0)).Val());
|
||||
Json_ary owner = Json_ary.cast_or_null(Json_kv.cast_(jdoc.Root().Get_at(0)).Val());
|
||||
Wdata_references_grp[] actl = parser.Parse_references(Q1_bry, owner);
|
||||
Wdata_references_grp actl_grp = actl[0];
|
||||
Tfds.Eq_ary(expd_order, actl_grp.References_order());
|
||||
@ -75,7 +75,7 @@ abstract class Wdata_doc_parser_fxt_base {
|
||||
}
|
||||
public void Test_pid_order(String raw, int... expd) {
|
||||
Json_doc jdoc = Json_doc.new_apos_(raw);
|
||||
Json_itm_ary nde = Json_itm_ary.cast_(Json_itm_kv.cast_(jdoc.Root().Get_at(0)).Val());
|
||||
Json_ary nde = Json_ary.cast_or_null(Json_kv.cast_(jdoc.Root().Get_at(0)).Val());
|
||||
int[] actl = parser.Parse_pid_order(Q1_bry, nde);
|
||||
Tfds.Eq_ary(expd, actl);
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ public class Wdata_doc_parser_v1 implements Wdata_doc_parser {
|
||||
case Json_itm_.Tid_string: // "entity":"q1"
|
||||
return kv_val.Data_bry();
|
||||
case Json_itm_.Tid_array: // "entity":["item",1]
|
||||
Json_itm_ary kv_val_as_ary = (Json_itm_ary)kv_val;
|
||||
Json_ary kv_val_as_ary = (Json_ary)kv_val;
|
||||
Json_itm entity_id = kv_val_as_ary.Get_at(1);
|
||||
return Bry_.Add(Byte_ascii.Ltr_q, entity_id.Data_bry());
|
||||
default:
|
||||
@ -41,16 +41,16 @@ public class Wdata_doc_parser_v1 implements Wdata_doc_parser {
|
||||
Ordered_hash rv = Ordered_hash_.new_bry_();
|
||||
int list_len = list_nde.Len();
|
||||
for (int i = 0; i < list_len; ++i) {
|
||||
Json_itm_kv wiki_kv = Json_itm_kv.cast_(list_nde.Get_at(i));
|
||||
Json_kv wiki_kv = Json_kv.cast_(list_nde.Get_at(i));
|
||||
byte[] site_bry = wiki_kv.Key().Data_bry();
|
||||
byte[] title_bry = null; byte[][] badges_bry_ary = null;
|
||||
if (wiki_kv.Val().Tid() == Json_itm_.Tid_nde) { // v1.2: "enwiki":{name:"Earth", badges:[]}
|
||||
Json_nde val_nde = Json_nde.cast_(wiki_kv.Val());
|
||||
Json_itm_kv name_kv = Json_itm_kv.cast_(val_nde.Get_at(0));
|
||||
Json_kv name_kv = Json_kv.cast_(val_nde.Get_at(0));
|
||||
title_bry = name_kv.Val().Data_bry();
|
||||
Json_itm_kv badges_kv = Json_itm_kv.cast_(val_nde.Get_at(1));
|
||||
Json_kv badges_kv = Json_kv.cast_(val_nde.Get_at(1));
|
||||
if (badges_kv != null) {// TEST:some tests do not define a badges nde; ignore if null; DATE:2014-09-19
|
||||
Json_itm_ary badges_ary = Json_itm_ary.cast_(badges_kv.Val());
|
||||
Json_ary badges_ary = Json_ary.cast_or_null(badges_kv.Val());
|
||||
badges_bry_ary = badges_ary.Xto_bry_ary();
|
||||
}
|
||||
}
|
||||
@ -70,7 +70,7 @@ public class Wdata_doc_parser_v1 implements Wdata_doc_parser {
|
||||
Ordered_hash rv = Ordered_hash_.new_bry_();
|
||||
int list_len = list_nde.Len();
|
||||
for (int i = 0; i < list_len; ++i) {
|
||||
Json_itm_kv data_kv = Json_itm_kv.cast_(list_nde.Get_at(i));
|
||||
Json_kv data_kv = Json_kv.cast_(list_nde.Get_at(i));
|
||||
byte[] lang_bry = data_kv.Key().Data_bry();
|
||||
Wdata_langtext_itm itm = new Wdata_langtext_itm(lang_bry, data_kv.Val().Data_bry());
|
||||
rv.Add(lang_bry, itm);
|
||||
@ -84,13 +84,13 @@ public class Wdata_doc_parser_v1 implements Wdata_doc_parser {
|
||||
Ordered_hash rv = Ordered_hash_.new_bry_();
|
||||
int list_len = list_nde.Len();
|
||||
for (int i = 0; i < list_len; ++i) {
|
||||
Json_itm_kv data_kv = Json_itm_kv.cast_(list_nde.Get_at(i));
|
||||
Json_kv data_kv = Json_kv.cast_(list_nde.Get_at(i));
|
||||
byte[] lang_bry = data_kv.Key().Data_bry();
|
||||
byte[][] vals_bry_ary = null;
|
||||
Json_itm data_val = data_kv.Val();
|
||||
switch (data_val.Tid()) {
|
||||
case Json_itm_.Tid_array: // EX: 'en':['en_val_1','en_val_2']
|
||||
Json_itm_ary vals_ary = Json_itm_ary.cast_(data_val);
|
||||
Json_ary vals_ary = Json_ary.cast_or_null(data_val);
|
||||
vals_bry_ary = vals_ary.Xto_bry_ary();
|
||||
break;
|
||||
case Json_itm_.Tid_nde: // EX: 'en':{'0:en_val_1','1:en_val_2'}; PAGE:wd.q:621080 DATE:2014-09-21
|
||||
@ -98,7 +98,7 @@ public class Wdata_doc_parser_v1 implements Wdata_doc_parser {
|
||||
int vals_len = vals_nde.Len();
|
||||
vals_bry_ary = new byte[vals_len][];
|
||||
for (int j = 0; j < vals_len; ++j) {
|
||||
Json_itm_kv vals_sub_kv = Json_itm_kv.cast_(vals_nde.Get_at(j));
|
||||
Json_kv vals_sub_kv = Json_kv.cast_(vals_nde.Get_at(j));
|
||||
vals_bry_ary[j] = vals_sub_kv.Val().Data_bry();
|
||||
}
|
||||
break;
|
||||
@ -112,7 +112,7 @@ public class Wdata_doc_parser_v1 implements Wdata_doc_parser {
|
||||
}
|
||||
public Ordered_hash Parse_claims(byte[] qid, Json_doc doc) {
|
||||
try {
|
||||
Json_itm_ary list_nde = Json_itm_ary.cast_(doc.Get_grp(Bry_claims)); if (list_nde == null) return Empty_ordered_hash_generic;
|
||||
Json_ary list_nde = Json_ary.cast_or_null(doc.Get_grp(Bry_claims)); if (list_nde == null) return Empty_ordered_hash_generic;
|
||||
List_adp temp_list = List_adp_.new_();
|
||||
byte[] src = doc.Src();
|
||||
int len = list_nde.Len();
|
||||
@ -151,13 +151,13 @@ public class Wdata_doc_parser_v1 implements Wdata_doc_parser {
|
||||
int len = prop_nde.Len(); // should have 5 (m, q, g, rank, refs), but don't enforce (can rely on keys)
|
||||
Wdata_claim_itm_core rv = null;
|
||||
for (int i = 0; i < len; i++) {
|
||||
Json_itm_kv kv = Json_itm_kv.cast_(prop_nde.Get_at(i));
|
||||
Json_kv kv = Json_kv.cast_(prop_nde.Get_at(i));
|
||||
Json_itm kv_key = kv.Key();
|
||||
Byte_obj_val bv = (Byte_obj_val)Prop_key_hash.Get_by_mid(src, kv_key.Src_bgn(), kv_key.Src_end());
|
||||
if (bv == null) {Warn("invalid prop node: ~{0}", String_.new_u8(src, kv_key.Src_bgn(), kv_key.Src_end())); return null;}
|
||||
switch (bv.Val()) {
|
||||
case Prop_tid_m:
|
||||
rv = New_prop_by_m(src, Json_itm_ary.cast_(kv.Val()));
|
||||
rv = New_prop_by_m(src, Json_ary.cast_or_null(kv.Val()));
|
||||
if (rv == null) return null;
|
||||
break;
|
||||
case Prop_tid_g:
|
||||
@ -175,7 +175,7 @@ public class Wdata_doc_parser_v1 implements Wdata_doc_parser {
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
private Wdata_claim_itm_core New_prop_by_m(byte[] src, Json_itm_ary ary) {
|
||||
private Wdata_claim_itm_core New_prop_by_m(byte[] src, Json_ary ary) {
|
||||
byte snak_tid = Wdata_dict_snak_tid.Xto_tid(ary.Get_at(0).Data_bry());
|
||||
int pid = Json_itm_int.cast_(ary.Get_at(1)).Data_as_int();
|
||||
switch (snak_tid) {
|
||||
@ -187,13 +187,13 @@ public class Wdata_doc_parser_v1 implements Wdata_doc_parser {
|
||||
return Make_itm(pid, snak_tid, val_tid, ary);
|
||||
}
|
||||
|
||||
private Wdata_claim_itm_core Make_itm(int pid, byte snak_tid, byte val_tid, Json_itm_ary ary) {
|
||||
private Wdata_claim_itm_core Make_itm(int pid, byte snak_tid, byte val_tid, Json_ary ary) {
|
||||
switch (val_tid) {
|
||||
case Wdata_dict_val_tid.Tid_string:
|
||||
return new Wdata_claim_itm_str(pid, snak_tid, ary.Get_at(3).Data_bry());
|
||||
case Wdata_dict_val_tid.Tid_entity: {
|
||||
Json_nde sub_nde = Json_nde.cast_(ary.Get_at(3));
|
||||
Json_itm_kv entity_kv = Json_itm_kv.cast_(sub_nde.Get_at(1));
|
||||
Json_kv entity_kv = Json_kv.cast_(sub_nde.Get_at(1));
|
||||
return new Wdata_claim_itm_entity(pid, snak_tid, Wdata_dict_value_entity_tid.Tid_item, entity_kv.Val().Data_bry());
|
||||
}
|
||||
case Wdata_dict_val_tid.Tid_time: {
|
||||
@ -216,7 +216,7 @@ public class Wdata_doc_parser_v1 implements Wdata_doc_parser {
|
||||
}
|
||||
}
|
||||
private static byte[] Get_val(Json_nde sub_nde, int i) {
|
||||
Json_itm_kv kv = Json_itm_kv.cast_(sub_nde.Get_at(i));
|
||||
Json_kv kv = Json_kv.cast_(sub_nde.Get_at(i));
|
||||
return kv.Val().Data_bry();
|
||||
}
|
||||
private void Warn(String fmt, Object... args) {usr_dlg.Warn_many("", "", fmt, args);}
|
||||
@ -233,15 +233,15 @@ public class Wdata_doc_parser_v1 implements Wdata_doc_parser {
|
||||
Ordered_hash rv = Ordered_hash_.new_bry_();
|
||||
int len = nde.Len();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Json_itm_kv kv = Json_itm_kv.cast_(nde.Get_at(i));
|
||||
Json_kv kv = Json_kv.cast_(nde.Get_at(i));
|
||||
byte[] kv_key = kv.Key().Data_bry();
|
||||
rv.Add(kv_key, kv);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public Wdata_claim_grp_list Parse_qualifiers(byte[] qid, Json_nde nde) {throw Err_.new_unimplemented();}
|
||||
public Wdata_references_grp[] Parse_references(byte[] qid, Json_itm_ary owner) {throw Err_.new_unimplemented();}
|
||||
public int[] Parse_pid_order(byte[] qid, Json_itm_ary ary) {throw Err_.new_unimplemented();}
|
||||
public Wdata_references_grp[] Parse_references(byte[] qid, Json_ary owner) {throw Err_.new_unimplemented();}
|
||||
public int[] Parse_pid_order(byte[] qid, Json_ary ary) {throw Err_.new_unimplemented();}
|
||||
public static final String
|
||||
Str_entity = "entity"
|
||||
, Str_id = "id"
|
||||
|
@ -32,17 +32,17 @@ public class Wdata_doc_parser_v2 implements Wdata_doc_parser {
|
||||
int list_len = list_nde.Len();
|
||||
Hash_adp_bry dict = Wdata_dict_sitelink.Dict;
|
||||
for (int i = 0; i < list_len; ++i) {
|
||||
Json_itm_kv data_kv = Json_itm_kv.cast_(list_nde.Get_at(i));
|
||||
Json_kv data_kv = Json_kv.cast_(list_nde.Get_at(i));
|
||||
Json_nde data_nde = Json_nde.cast_(data_kv.Val());
|
||||
int data_nde_len = data_nde.Len();
|
||||
Json_itm_kv site_kv = null, name_kv = null; Json_itm_ary badges_ary = null;
|
||||
Json_kv site_kv = null, name_kv = null; Json_ary badges_ary = null;
|
||||
for (int j = 0; j < data_nde_len; ++j) {
|
||||
Json_itm_kv sub = Json_itm_kv.cast_(data_nde.Get_at(j));
|
||||
Json_kv sub = Json_kv.cast_(data_nde.Get_at(j));
|
||||
byte tid = Wdata_dict_utl.Get_tid_or_invalid(qid, dict, sub.Key().Data_bry()); if (tid == Wdata_dict_utl.Tid_invalid) continue;
|
||||
switch (tid) {
|
||||
case Wdata_dict_sitelink.Tid_site: site_kv = Json_itm_kv.cast_(sub); break;
|
||||
case Wdata_dict_sitelink.Tid_title: name_kv = Json_itm_kv.cast_(sub); break;
|
||||
case Wdata_dict_sitelink.Tid_badges: badges_ary = Json_itm_ary.cast_(Json_itm_kv.cast_(sub).Val()); break;
|
||||
case Wdata_dict_sitelink.Tid_site: site_kv = Json_kv.cast_(sub); break;
|
||||
case Wdata_dict_sitelink.Tid_title: name_kv = Json_kv.cast_(sub); break;
|
||||
case Wdata_dict_sitelink.Tid_badges: badges_ary = Json_ary.cast_or_null(Json_kv.cast_(sub).Val()); break;
|
||||
}
|
||||
}
|
||||
byte[] site_bry = site_kv.Val().Data_bry();
|
||||
@ -60,16 +60,16 @@ public class Wdata_doc_parser_v2 implements Wdata_doc_parser {
|
||||
int list_len = list_nde.Len();
|
||||
Hash_adp_bry dict = Wdata_dict_langtext.Dict;
|
||||
for (int i = 0; i < list_len; ++i) {
|
||||
Json_itm_kv data_kv = Json_itm_kv.cast_(list_nde.Get_at(i));
|
||||
Json_kv data_kv = Json_kv.cast_(list_nde.Get_at(i));
|
||||
Json_nde data_nde = Json_nde.cast_(data_kv.Val());
|
||||
Json_itm_kv text_kv = null;
|
||||
Json_kv text_kv = null;
|
||||
int data_nde_len = data_nde.Len();
|
||||
for (int j = 0; j < data_nde_len; ++j) {
|
||||
Json_itm_kv sub = Json_itm_kv.cast_(data_nde.Get_at(j));
|
||||
Json_kv sub = Json_kv.cast_(data_nde.Get_at(j));
|
||||
byte tid = Wdata_dict_utl.Get_tid_or_invalid(qid, dict, sub.Key().Data_bry()); if (tid == Wdata_dict_utl.Tid_invalid) continue;
|
||||
switch (tid) {
|
||||
case Wdata_dict_langtext.Tid_language: break;
|
||||
case Wdata_dict_langtext.Tid_value: text_kv = Json_itm_kv.cast_(sub); break;
|
||||
case Wdata_dict_langtext.Tid_value: text_kv = Json_kv.cast_(sub); break;
|
||||
}
|
||||
}
|
||||
byte[] lang_bry = data_kv.Key().Data_bry();
|
||||
@ -86,15 +86,15 @@ public class Wdata_doc_parser_v2 implements Wdata_doc_parser {
|
||||
int list_len = list_nde.Len();
|
||||
Hash_adp_bry dict = Wdata_dict_langtext.Dict;
|
||||
for (int i = 0; i < list_len; ++i) {
|
||||
Json_itm_kv data_kv = Json_itm_kv.cast_(list_nde.Get_at(i));
|
||||
Json_itm_ary vals_ary = Json_itm_ary.cast_(data_kv.Val());
|
||||
Json_kv data_kv = Json_kv.cast_(list_nde.Get_at(i));
|
||||
Json_ary vals_ary = Json_ary.cast_or_null(data_kv.Val());
|
||||
int vals_len = vals_ary.Len();
|
||||
byte[][] vals = new byte[vals_len][];
|
||||
for (int j = 0; j < vals_len; ++j) {
|
||||
Json_nde lang_nde = Json_nde.cast_(vals_ary.Get_at(j));
|
||||
int k_len = lang_nde.Len();
|
||||
for (int k = 0; k < k_len; ++k) {
|
||||
Json_itm_kv sub = Json_itm_kv.cast_(lang_nde.Get_at(k));
|
||||
Json_kv sub = Json_kv.cast_(lang_nde.Get_at(k));
|
||||
byte tid = Wdata_dict_utl.Get_tid_or_invalid(qid, dict, sub.Key().Data_bry()); if (tid == Wdata_dict_utl.Tid_invalid) continue;
|
||||
switch (tid) {
|
||||
case Wdata_dict_langtext.Tid_language: break;
|
||||
@ -116,7 +116,7 @@ public class Wdata_doc_parser_v2 implements Wdata_doc_parser {
|
||||
byte[] src = doc.Src();
|
||||
int len = list_nde.Len();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Json_itm_kv claim_nde = Json_itm_kv.cast_(list_nde.Get_at(i));
|
||||
Json_kv claim_nde = Json_kv.cast_(list_nde.Get_at(i));
|
||||
claims_parser.Make_claim_itms(qid, temp_list, src, claim_nde);
|
||||
}
|
||||
return Wdata_doc_parser_v1.Claims_list_to_hash(temp_list);
|
||||
@ -124,8 +124,8 @@ public class Wdata_doc_parser_v2 implements Wdata_doc_parser {
|
||||
}
|
||||
public Wdata_claim_itm_base Parse_claims_data(byte[] qid, int pid, byte snak_tid, Json_nde nde) {return claims_parser.Parse_datavalue(qid, pid, snak_tid, nde);}
|
||||
public Wdata_claim_grp_list Parse_qualifiers(byte[] qid, Json_nde nde) {return claims_parser.Parse_qualifiers(qid, nde);}
|
||||
public Wdata_references_grp[] Parse_references(byte[] qid, Json_itm_ary owner) {return claims_parser.Parse_references(qid, owner);}
|
||||
public int[] Parse_pid_order(byte[] qid, Json_itm_ary ary) {return claims_parser.Parse_pid_order(ary);}
|
||||
public Wdata_references_grp[] Parse_references(byte[] qid, Json_ary owner) {return claims_parser.Parse_references(qid, owner);}
|
||||
public int[] Parse_pid_order(byte[] qid, Json_ary ary) {return claims_parser.Parse_pid_order(ary);}
|
||||
public static final String
|
||||
Str_id = "id"
|
||||
, Str_sitelinks = "sitelinks"
|
||||
|
@ -74,6 +74,7 @@ public class Xob_dump_file {
|
||||
dump_date = new_dump_date;
|
||||
file_name = new_dump_file;
|
||||
file_url = new_file_url;
|
||||
break;
|
||||
}
|
||||
else
|
||||
Xoa_app_.Usr_dlg().Warn_many("", "", "wmf.dump:dump not found; url=~{0}", new_file_url);
|
||||
@ -83,6 +84,7 @@ public class Xob_dump_file {
|
||||
}
|
||||
private boolean Connect_exec(IoEngine_xrg_downloadFil args, String cur_file_url) {
|
||||
boolean rv = args.Src_last_modified_query_(true).Exec_meta(cur_file_url);
|
||||
Xoa_app_.Usr_dlg().Note_many("", "", "wmf.dump:connect log; url=~{0} result=~{1} fil_len=~{2} file_modified=~{3} server_url=~{4} dump_date=~{5}", cur_file_url, rv, args.Src_content_length(), args.Src_last_modified() == null ? "<<NULL>>" : args.Src_last_modified().XtoStr_fmt_yyyy_MM_dd_HH_mm_ss(), server_url, dump_date);
|
||||
if (rv) {
|
||||
file_len = args.Src_content_length();
|
||||
file_modified = args.Src_last_modified();
|
||||
|
@ -34,6 +34,7 @@ public class Xob_dump_file_ {
|
||||
|| String_.Eq(dump_server, Xob_dump_file_.Server_masaryk)
|
||||
)
|
||||
){
|
||||
Xoa_app_.Usr_dlg().Note_many("", "", "wmf.dump:connect log; server_url=~{0} dump_date=~{1}", dump_server, dump_date);
|
||||
Xoi_mirror_parser mirror_parser = new Xoi_mirror_parser();
|
||||
String dump_wiki_url = dump_server + String_.new_a7(rv.Wiki_alias()) + "/";
|
||||
byte[] dump_url_wiki_html = gplx.ios.IoEngine_xrg_downloadFil.new_("", Io_url_.Empty).Exec_as_bry(dump_wiki_url); if (Bry_.Len_eq_0(dump_url_wiki_html)) return;
|
||||
@ -46,13 +47,13 @@ public class Xob_dump_file_ {
|
||||
public static byte[] Bld_dump_dir_url(byte[] server_url, byte[] alias, byte[] date) {
|
||||
return Bry_.Add
|
||||
( server_url // "http://dumps.wikimedia.org/"
|
||||
, Bry_.Replace(alias, Byte_ascii.Dash, Byte_ascii.Underline), Bry_slash // "simplewiki/"
|
||||
, Bry_.Replace(alias, Byte_ascii.Dash, Byte_ascii.Underline), Bry_slash // "simplewiki/"
|
||||
, date, Bry_slash // "latest/"
|
||||
);
|
||||
}
|
||||
public static byte[] Bld_dump_file_name(byte[] alias, byte[] date, byte[] dump_file_type, byte[] ext) {
|
||||
return Bry_.Add
|
||||
( Bry_.Replace(alias, Byte_ascii.Dash, Byte_ascii.Underline), Bry_dash // "simplewiki-"
|
||||
( Bry_.Replace(alias, Byte_ascii.Dash, Byte_ascii.Underline), Bry_dash // "simplewiki-"
|
||||
, date, Bry_dash // "latest-"
|
||||
, dump_file_type // "pages-articles"
|
||||
, ext // ".xml.bz2"
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user