mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.9.3.1
This commit is contained in:
43
400_xowa/src/gplx/xowa/bldrs/wtrs/Xob_tmp_wtr.java
Normal file
43
400_xowa/src/gplx/xowa/bldrs/wtrs/Xob_tmp_wtr.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.bldrs.wtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
|
||||
import gplx.ios.*;
|
||||
import gplx.xowa.nss.*;
|
||||
public class Xob_tmp_wtr {
|
||||
Xob_tmp_wtr(Xow_ns ns_itm, Io_url_gen url_gen, int fil_max) {
|
||||
this.ns_itm = ns_itm;
|
||||
this.url_gen = url_gen;
|
||||
this.fil_max = fil_max;
|
||||
bfr = Bry_bfr.reset_(fil_max);
|
||||
} int fil_max;
|
||||
public Bry_bfr Bfr() {return bfr;} Bry_bfr bfr;
|
||||
public Io_url_gen Url_gen() {return url_gen;} Io_url_gen url_gen;
|
||||
public void Clear() {bfr.ClearAndReset();}
|
||||
public boolean FlushNeeded(int writeLen) {return bfr.Len() + writeLen > fil_max;} //int bfr_len;
|
||||
public Xow_ns Ns_itm() {return ns_itm;} private Xow_ns ns_itm;
|
||||
public void Flush(Gfo_usr_dlg usr_dlg) {
|
||||
if (bfr.Len() == 0) return; // nothing to flush
|
||||
Io_url url = url_gen.Nxt_url();
|
||||
if (bfr.Len() > fil_max) // NOTE: data can exceed proscribed len; EX: wikt:Category for Italian nouns is 1 MB+
|
||||
usr_dlg.Log_many("xowa.tmp_wtr", "flush", "--fil exceeds len: ~{0} ~{1} ~{2}", bfr.Len(), fil_max, url.Xto_api());
|
||||
Io_mgr.I.AppendFilBfr(url, bfr);
|
||||
}
|
||||
public void Rls() {bfr.Rls();}
|
||||
public static Xob_tmp_wtr new_(Xow_ns ns_itm, Io_url_gen url_gen, int fil_max) {return new Xob_tmp_wtr(ns_itm, url_gen, fil_max);}
|
||||
public static Xob_tmp_wtr new_wo_ns_(Io_url_gen url_gen, int fil_max) {return new Xob_tmp_wtr(null, url_gen, fil_max);}
|
||||
}
|
||||
45
400_xowa/src/gplx/xowa/bldrs/wtrs/Xob_tmp_wtr_mgr.java
Normal file
45
400_xowa/src/gplx/xowa/bldrs/wtrs/Xob_tmp_wtr_mgr.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.bldrs.wtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
|
||||
import gplx.xowa.nss.*;
|
||||
public class Xob_tmp_wtr_mgr {
|
||||
public Xob_tmp_wtr[] Regy() {return regy;} private Xob_tmp_wtr[] regy = new Xob_tmp_wtr[Ns_ordinal_max];
|
||||
public Xob_tmp_wtr_mgr(Xob_tmp_wtr_wkr wkr) {this.wkr = wkr;} private Xob_tmp_wtr_wkr wkr;
|
||||
public Xob_tmp_wtr Get_or_new(Xow_ns ns) {
|
||||
Xob_tmp_wtr rv = regy[ns.Ord()];
|
||||
if (rv == null) {
|
||||
rv = wkr.Tmp_wtr_new(ns);
|
||||
regy[ns.Ord()] = rv;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public void Flush_all(Gfo_usr_dlg usr_dlg) {
|
||||
for (int i = 0; i < Ns_ordinal_max; i++) {
|
||||
Xob_tmp_wtr wtr = regy[i];
|
||||
if (wtr != null) {
|
||||
wtr.Flush(usr_dlg);
|
||||
wtr.Rls();
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Rls_all() {
|
||||
for (int i = 0; i < Ns_ordinal_max; i++)
|
||||
regy[i] = null;
|
||||
}
|
||||
static final int Ns_ordinal_max = Xow_ns_mgr_.Ordinal_max; // ASSUME: no more than 128 ns in a wiki
|
||||
}
|
||||
23
400_xowa/src/gplx/xowa/bldrs/wtrs/Xob_tmp_wtr_wkr.java
Normal file
23
400_xowa/src/gplx/xowa/bldrs/wtrs/Xob_tmp_wtr_wkr.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.bldrs.wtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
|
||||
import gplx.ios.*;
|
||||
import gplx.xowa.nss.*;
|
||||
public interface Xob_tmp_wtr_wkr {
|
||||
Xob_tmp_wtr Tmp_wtr_new(Xow_ns ns);
|
||||
}
|
||||
26
400_xowa/src/gplx/xowa/bldrs/wtrs/Xob_tmp_wtr_wkr__ttl.java
Normal file
26
400_xowa/src/gplx/xowa/bldrs/wtrs/Xob_tmp_wtr_wkr__ttl.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.bldrs.wtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
|
||||
import gplx.ios.*;
|
||||
import gplx.xowa.nss.*;
|
||||
public class Xob_tmp_wtr_wkr__ttl implements Xob_tmp_wtr_wkr {
|
||||
public Xob_tmp_wtr_wkr__ttl(Io_url temp_dir, int dump_fil_len) {this.temp_dir = temp_dir; this.dump_fil_len = dump_fil_len;} Io_url temp_dir; int dump_fil_len;
|
||||
public Xob_tmp_wtr Tmp_wtr_new(Xow_ns ns) {
|
||||
return Xob_tmp_wtr.new_(ns, Io_url_gen_.dir_(temp_dir.GenSubDir_nest(ns.Num_str(), "dump")), dump_fil_len);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user