mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
Hdump: Add missing Xoh_hdump_wkr [#584]
This commit is contained in:
22
400_xowa/src/gplx/xowa/htmls/hdumps/Xoh_hdump_wkr.java
Normal file
22
400_xowa/src/gplx/xowa/htmls/hdumps/Xoh_hdump_wkr.java
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
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.htmls.hdumps; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import gplx.langs.htmls.docs.*;
|
||||
import gplx.xowa.htmls.core.wkrs.*;
|
||||
public interface Xoh_hdump_wkr {
|
||||
byte[] Key();
|
||||
int Process(Bry_bfr bfr, Xoh_hdoc_ctx hctx, Xoh_hdoc_wkr hdoc_wkr, Gfh_tag_rdr tag_rdr, byte[] src, Gfh_tag tag);
|
||||
}
|
||||
32
400_xowa/src/gplx/xowa/htmls/hdumps/Xoh_hdump_wkr_utl.java
Normal file
32
400_xowa/src/gplx/xowa/htmls/hdumps/Xoh_hdump_wkr_utl.java
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
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.htmls.hdumps; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import gplx.langs.htmls.docs.*;
|
||||
public class Xoh_hdump_wkr_utl {
|
||||
public static void Write_tag_with_val_at_atr_bgn(Bry_bfr bfr, byte[] src, Gfh_tag tag, Gfh_atr atr, byte[] val) {
|
||||
// utility method to write tag, but put "val" at start of atr
|
||||
// EX: val="VAL_" tag="<img id='1' src='b.png' title='c'/>" -> "<img id='1' src='VAL_.png' title='c'/>"
|
||||
bfr.Add_mid(src, tag.Src_bgn(), atr.Val_bgn()); // add bgn of tag
|
||||
if (val != null)
|
||||
bfr.Add(val); // add "val"
|
||||
bfr.Add(atr.Val()); // add atr.val
|
||||
bfr.Add_mid(src, atr.Val_end(), tag.Src_end()); // add end of tag
|
||||
}
|
||||
public static byte[] Build_hdump_atr(byte[] key) {
|
||||
return Bry_.Add(Bry__data_xowa_hdump, key, Byte_ascii.Apos_bry);
|
||||
}
|
||||
private static final byte[] Bry__data_xowa_hdump = Bry_.new_a7("data-xowa-hdump='");
|
||||
}
|
||||
@@ -14,15 +14,20 @@ 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.parsers.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
import org.junit.*;
|
||||
import org.junit.*; import gplx.core.tests.*;
|
||||
public class Mwh_atr_mgr_tst {
|
||||
private final Mwh_atr_mgr_fxt fxt = new Mwh_atr_mgr_fxt();
|
||||
@Test public void Atr_utl_make() {
|
||||
private final Mwh_atr_mgr_fxt fxt = new Mwh_atr_mgr_fxt();
|
||||
@Test public void Atr_utl_make() {
|
||||
// key="val"
|
||||
fxt.Test_atr_utl_make(Mwh_atr_itm_.Qte_tid__qute, Mwh_atr_itm_.Mask__valid__y, Mwh_atr_itm_.Mask__repeated__n, Mwh_atr_itm_.Mask__key_exists__y, Mwh_atr_itm_.Mask__val_made__n, 42);
|
||||
// key=val key=v<nowiki/>al
|
||||
fxt.Test_atr_utl_make(Mwh_atr_itm_.Qte_tid__none, Mwh_atr_itm_.Mask__valid__y, Mwh_atr_itm_.Mask__repeated__y, Mwh_atr_itm_.Mask__key_exists__y, Mwh_atr_itm_.Mask__val_made__y, 120);
|
||||
}
|
||||
@Test public void Resize() {
|
||||
Mwh_atr_mgr atr_mgr = new Mwh_atr_mgr(1);
|
||||
atr_mgr.Add(0, 1, true, true, true, 2, 3, 4, 5, Bry_.Empty, 0, 0, 0, 0, Bry_.Empty);
|
||||
atr_mgr.Add(1, 0, true, true, true, 0, 0, 0, 0, Bry_.Empty, 0, 0, 0, 0, Bry_.Empty);
|
||||
}
|
||||
}
|
||||
class Mwh_atr_mgr_fxt {
|
||||
public void Test_atr_utl_make(int qte_tid, boolean valid, boolean repeated, boolean key_exists, boolean val_made, int expd) {
|
||||
|
||||
@@ -38,7 +38,7 @@ class Mwh_doc_mgr {
|
||||
if (data_idx == data_max) {
|
||||
int new_data_max = data_max == 0 ? Idx__mult : data_max * 2;
|
||||
int[] new_data_ary = new int[new_data_max];
|
||||
Int_ary_.Copy_to(data_ary, data_max, data_ary);
|
||||
Int_ary_.Copy_to(data_ary, data_max, new_data_ary);
|
||||
this.data_ary = new_data_ary;
|
||||
this.data_max = new_data_max;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user