mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
Scribunto: Add HashLibrary [#589]
This commit is contained in:
@@ -49,33 +49,3 @@ abstract class Json_itm_wkr__base implements Json_itm_wkr {
|
||||
public abstract void Read_kv_sub(byte[] key, byte[] val);
|
||||
private static final byte[] Name_metadata = Bry_.new_a7("@metadata");
|
||||
}
|
||||
class Json_itm_wkr__gfs extends Json_itm_wkr__base {
|
||||
private Xoa_gfs_bldr gfs_bldr = new Xoa_gfs_bldr();
|
||||
private Xol_csv_parser csv_parser = Xol_csv_parser.Instance;
|
||||
private Bry_bfr bfr;
|
||||
public byte[] Xto_bry() {return gfs_bldr.Xto_bry();}
|
||||
@Override public void Exec_bgn() {
|
||||
bfr = gfs_bldr.Bfr();
|
||||
gfs_bldr.Add_proc_init_many("this", "messages", "load_text").Add_paren_bgn().Add_nl();
|
||||
gfs_bldr.Add_quote_xtn_bgn();
|
||||
}
|
||||
@Override public void Exec_end() {
|
||||
gfs_bldr.Add_quote_xtn_end().Add_paren_end().Add_term_nl();
|
||||
}
|
||||
@Override public void Read_kv_sub(byte[] key, byte[] val) {
|
||||
csv_parser.Save(bfr, key); // key
|
||||
bfr.Add_byte_pipe(); // |
|
||||
csv_parser.Save(bfr, val); // val
|
||||
bfr.Add_byte_nl(); // \n
|
||||
}
|
||||
}
|
||||
class Json_itm_wkr__msgs extends Json_itm_wkr__base {
|
||||
private Xol_msg_mgr msg_mgr; private boolean dirty;
|
||||
public void Ctor(boolean dirty, Xol_msg_mgr msg_mgr) {this.dirty = dirty; this.msg_mgr = msg_mgr;}
|
||||
@Override public void Read_kv_sub(byte[] key, byte[] val) {
|
||||
Xol_msg_itm msg_itm = msg_mgr.Itm_by_key_or_new(key);
|
||||
Xol_msg_itm_.update_val_(msg_itm, val);
|
||||
if (dirty) // bldr needs to dirty message to generate lang.gfs; DATE:2014-08-05
|
||||
msg_itm.Dirty_(true);
|
||||
}
|
||||
}
|
||||
|
||||
37
400_xowa/src/gplx/xowa/langs/bldrs/Json_itm_wkr__gfs.java
Normal file
37
400_xowa/src/gplx/xowa/langs/bldrs/Json_itm_wkr__gfs.java
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.langs.bldrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import gplx.xowa.apps.gfs.*; import gplx.xowa.langs.parsers.*;
|
||||
class Json_itm_wkr__gfs extends Json_itm_wkr__base {
|
||||
private Xoa_gfs_bldr gfs_bldr = new Xoa_gfs_bldr();
|
||||
private Xol_csv_parser csv_parser = Xol_csv_parser.Instance;
|
||||
private Bry_bfr bfr;
|
||||
public byte[] Xto_bry() {return gfs_bldr.Xto_bry();}
|
||||
@Override public void Exec_bgn() {
|
||||
bfr = gfs_bldr.Bfr();
|
||||
gfs_bldr.Add_proc_init_many("this", "messages", "load_text").Add_paren_bgn().Add_nl();
|
||||
gfs_bldr.Add_quote_xtn_bgn();
|
||||
}
|
||||
@Override public void Exec_end() {
|
||||
gfs_bldr.Add_quote_xtn_end().Add_paren_end().Add_term_nl();
|
||||
}
|
||||
@Override public void Read_kv_sub(byte[] key, byte[] val) {
|
||||
csv_parser.Save(bfr, key); // key
|
||||
bfr.Add_byte_pipe(); // |
|
||||
csv_parser.Save(bfr, val); // val
|
||||
bfr.Add_byte_nl(); // \n
|
||||
}
|
||||
}
|
||||
27
400_xowa/src/gplx/xowa/langs/bldrs/Json_itm_wkr__msgs.java
Normal file
27
400_xowa/src/gplx/xowa/langs/bldrs/Json_itm_wkr__msgs.java
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.langs.bldrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import gplx.xowa.langs.msgs.*;
|
||||
class Json_itm_wkr__msgs extends Json_itm_wkr__base {
|
||||
private Xol_msg_mgr msg_mgr; private boolean dirty;
|
||||
public void Ctor(boolean dirty, Xol_msg_mgr msg_mgr) {this.dirty = dirty; this.msg_mgr = msg_mgr;}
|
||||
@Override public void Read_kv_sub(byte[] key, byte[] val) {
|
||||
Xol_msg_itm msg_itm = msg_mgr.Itm_by_key_or_new(key);
|
||||
Xol_msg_itm_.update_val_(msg_itm, val);
|
||||
if (dirty) // bldr needs to dirty message to generate lang.gfs; DATE:2014-08-05
|
||||
msg_itm.Dirty_(true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user