diff --git a/100_core/src_110_primitive/gplx/Bool_default.java b/100_core/src_110_primitive/gplx/Bool_default.java
deleted file mode 100644
index 16920118a..000000000
--- a/100_core/src_110_primitive/gplx/Bool_default.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
-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 .
-*/
-package gplx;
-public class Bool_default {
- public static final byte Tid_n = 0, Tid_y = 1, Tid_i = 2;
- public static final String Str_n = "never", Str_y = "always", Str_i = "default";
- public static final byte Chr_n = Byte_ascii.Ltr_n, Chr_y = Byte_ascii.Ltr_y, Chr_i = Byte_ascii.Ltr_i;
- public static String Xto_str(byte v) {
- switch (v) {
- case Tid_n: return Str_n;
- case Tid_y: return Str_y;
- case Tid_i: return Str_i;
- default: throw Err_.unhandled(v);
- }
- }
- public static byte Xto_char_byte(byte v) {
- switch (v) {
- case Tid_n: return Chr_n;
- case Tid_y: return Chr_y;
- case Tid_i: return Chr_i;
- default: throw Err_.unhandled(v);
- }
- }
- public static byte Xto_tid(String v) {
- if (String_.Eq(v, Str_n)) return Tid_n;
- else if (String_.Eq(v, Str_y)) return Tid_y;
- else if (String_.Eq(v, Str_i)) return Tid_i;
- else throw Err_.unhandled(v);
- }
-}
diff --git a/140_dbs/src_100_core/gplx/dbs/Db_conn_info.java b/140_dbs/src_100_core/gplx/dbs/Db_conn_info.java
deleted file mode 100644
index c7d90ff1b..000000000
--- a/140_dbs/src_100_core/gplx/dbs/Db_conn_info.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
-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 .
-*/
-package gplx.dbs; import gplx.*;
-public interface Db_conn_info {
- String Key();
- String Server();
- String Database();
- String Str_raw();
- String Str_api();
- Db_conn_info Make_new(String raw, GfoMsg m);
-}
-class Db_conn_info__null extends Db_conn_info__base {
- @Override public String Key() {return Key_const;} public static final String Key_const = "null_db";
- @Override public Db_conn_info Make_new(String raw, GfoMsg m) {return this;}
- public static final Db_conn_info__null _ = new Db_conn_info__null(); Db_conn_info__null() {this.Ctor_of_db_connect("", "", "gplx_key=null_db", "");}
-}
-class Db_conn_info__mysql extends Db_conn_info__base {
- @Override public String Key() {return Key_const;} public static final String Key_const = "mysql";
- public String Uid() {return uid;} private String uid;
- public String Pwd() {return pwd;} private String pwd;
- public static Db_conn_info new_(String server, String database, String uid, String pwd) {
- return Db_conn_info_.parse_(BldRaw(GfoMsg_.new_cast_("Db_conn_info")
- .Add("gplx_key", Key_const)
- .Add("server", server)
- .Add("database", database)
- .Add("uid", uid)
- .Add("pwd", pwd)
- .Add("charset", "utf8")
- ));
- }
- @Override public Db_conn_info Make_new(String raw, GfoMsg m) {
- Db_conn_info__mysql rv = new Db_conn_info__mysql();
- rv.Ctor_of_db_connect(m.ReadStr("server"), m.ReadStr("database"), raw, BldApi(m, KeyVal_.new_("charset", "utf8")));
- rv.uid = m.ReadStr("uid");
- rv.pwd = m.ReadStr("pwd");
- return rv;
- }
- public static final Db_conn_info__mysql _ = new Db_conn_info__mysql(); Db_conn_info__mysql() {}
-}
-class Db_conn_info__postgres extends Db_conn_info__base {
- @Override public String Key() {return Key_const;} public static final String Key_const = "postgresql";
- public String Uid() {return uid;} private String uid;
- public String Pwd() {return pwd;} private String pwd;
- public static Db_conn_info new_(String server, String database, String uid, String pwd) {
- return Db_conn_info_.parse_(BldRaw(GfoMsg_.new_cast_("Db_conn_info")
- .Add("gplx_key", Key_const)
- .Add("server", server)
- .Add("database", database)
- .Add("port", 5432)
- .Add("user id", uid)
- .Add("password", pwd)
- .Add("encoding", "unicode") // needed for 1.1 provider; otherwise, ascii
- ));
- }
- @Override public Db_conn_info Make_new(String raw, GfoMsg m) {
- Db_conn_info__postgres rv = new Db_conn_info__postgres();
- rv.Ctor_of_db_connect(m.ReadStr("server"), m.ReadStr("database"), raw, BldApi(m, KeyVal_.new_("encoding", "unicode")));
- rv.uid = m.ReadStr("user id");
- rv.pwd = m.ReadStr("password");
- return rv;
- }
- public static final Db_conn_info__postgres _ = new Db_conn_info__postgres(); Db_conn_info__postgres() {}
-}
-class Db_conn_info__tdb extends Db_conn_info__base {
- public Io_url Url() {return url;} Io_url url;
- @Override public String Key() {return Key_const;} public static final String Key_const = "tdb";
- public static Db_conn_info new_(Io_url url) {
- return Db_conn_info_.parse_(BldRaw(GfoMsg_.new_cast_("Db_conn_info")
- .Add("gplx_key", Key_const)
- .Add("url", url.Raw())
- ));
- } Db_conn_info__tdb() {}
- @Override public Db_conn_info Make_new(String raw, GfoMsg m) {
- Db_conn_info__tdb rv = new Db_conn_info__tdb();
- String urlStr = m.ReadStr("url");
- Io_url url = Io_url_.new_any_(urlStr);
- rv.Ctor_of_db_connect(urlStr, url.NameOnly(), raw, BldApi(m));
- rv.url = url;
- return rv;
- }
- public static final Db_conn_info__tdb _ = new Db_conn_info__tdb();
-}
diff --git a/140_dbs/src_100_core/gplx/dbs/Db_conn_info_.java b/140_dbs/src_100_core/gplx/dbs/Db_conn_info_.java
deleted file mode 100644
index 8de486efc..000000000
--- a/140_dbs/src_100_core/gplx/dbs/Db_conn_info_.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
-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 .
-*/
-package gplx.dbs; import gplx.*;
-public class Db_conn_info_ {
- public static final Db_conn_info Null = Db_conn_info__null._;
- public static final Db_conn_info Test = Db_conn_info__mysql.new_("127.0.0.1", "unit_tests", "root", "mysql7760");
- public static Db_conn_info parse_(String raw) {return Db_conn_info_pool._.Parse(raw);}
- public static Db_conn_info sqlite_(Io_url url) {return Db_conn_info__sqlite.load_(url);}
- public static Db_conn_info tdb_(Io_url url) {return Db_conn_info__tdb.new_(url);}
- public static final String Key_tdb = TdbEngine.KeyDef;
-}
-class Db_conn_info_pool {
- private OrderedHash regy = OrderedHash_.new_();
- public Db_conn_info_pool() {
- this.Add(Db_conn_info__null._).Add(Db_conn_info__tdb._).Add(Db_conn_info__mysql._).Add(Db_conn_info__postgres._).Add(Db_conn_info__sqlite._);
- }
- public Db_conn_info_pool Add(Db_conn_info itm) {regy.AddReplace(itm.Key(), itm); return this;}
- public Db_conn_info Parse(String raw) {// assume each pair has format of: name=val;
- try {
- GfoMsg m = GfoMsg_.new_parse_("db_conn_info");
- String[] terms = String_.Split(raw, ";");
- String conn_info_key = "";
- for (String term : terms) {
- if (String_.Len(term) == 0) continue;
- String[] kv = String_.Split(term, "=");
- if (String_.Eq(kv[0], "gplx_key"))
- conn_info_key = kv[1]; // NOTE: do not add to GfoMsg; will not be part of ApiStr
- else
- m.Add(kv[0], kv[1]);
- }
- Db_conn_info prototype = (Db_conn_info)regy.Fetch(conn_info_key);
- return prototype.Make_new(raw, m);
- }
- catch(Exception exc) {throw Err_.parse_type_exc_(exc, Db_conn_info.class, raw);}
- }
- public static final Db_conn_info_pool _ = new Db_conn_info_pool();
-}
diff --git a/140_dbs/src_100_core/gplx/dbs/Db_conn_info__base.java b/140_dbs/src_100_core/gplx/dbs/Db_conn_info__base.java
deleted file mode 100644
index 1e518be4e..000000000
--- a/140_dbs/src_100_core/gplx/dbs/Db_conn_info__base.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
-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 .
-*/
-package gplx.dbs; import gplx.*;
-public abstract class Db_conn_info__base implements Db_conn_info {
- public abstract String Key();
- public String Database() {return database;} public Db_conn_info__base Database_(String v) {database = v; return this;} private String database = "";
- public String Server() {return server;} public Db_conn_info__base Server_(String v) {server = v; return this;} private String server = "";
- public String Str_raw() {return raw;} public Db_conn_info XtoStr_raw_(String v) {raw = v; return this;} private String raw = "";
- public String Str_api() {return api;} public Db_conn_info XtoStr_std_(String v) {api = v; return this;} private String api = "";
- public abstract Db_conn_info Make_new(String raw, GfoMsg m);
- protected void Ctor_of_db_connect(String server, String database, String raw, String api) {this.server = server; this.database = database; this.raw = raw; this.api = api;}
-
- protected static String BldApi(GfoMsg m, KeyVal... xtnAry) {
- String_bldr sb = String_bldr_.new_();
- HashAdp hash = HashAdp_.new_();
- for (int i = 0; i < m.Args_count(); i++) {
- KeyVal kv = m.Args_getAt(i);
- sb.Add_fmt("{0}={1};", kv.Key(), kv.Val_to_str_or_empty());
- hash.AddKeyVal(kv.Key());
- }
- for (KeyVal xtn : xtnAry) {
- if (hash.Has(xtn.Key())) continue;
- sb.Add_fmt("{0}={1};", xtn.Key(), xtn.Val_to_str_or_empty());
- }
- return sb.XtoStr();
- }
- protected static String BldRaw(GfoMsg m) {
- String_bldr sb = String_bldr_.new_();
- for (int i = 0; i < m.Args_count(); i++) {
- KeyVal itm = m.Args_getAt(i);
- sb.Add_fmt("{0}={1};", itm.Key(), itm.Val_to_str_or_empty());
- }
- return sb.XtoStr();
- }
-}
diff --git a/140_dbs/src_100_core/gplx/dbs/Db_conn_info__sqlite.java b/140_dbs/src_100_core/gplx/dbs/Db_conn_info__sqlite.java
deleted file mode 100644
index a6684338b..000000000
--- a/140_dbs/src_100_core/gplx/dbs/Db_conn_info__sqlite.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
-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 .
-*/
-package gplx.dbs; import gplx.*;
-public class Db_conn_info__sqlite extends Db_conn_info__base {
- @Override public String Key() {return Key_const;} public static final String Key_const = "sqlite";
- public Io_url Url() {return url;} private Io_url url;
- public static Db_conn_info load_(Io_url url) {
- return Db_conn_info_.parse_(BldRaw(GfoMsg_.new_cast_("Db_conn_info")
- .Add("gplx_key", Key_const)
- .Add("data source", url.Xto_api())
- .Add("version", 3)
- ));
- }
- public static Db_conn_info make_(Io_url url) {
- Io_mgr._.CreateDirIfAbsent(url.OwnerDir());
- return Db_conn_info_.parse_(BldRaw(GfoMsg_.new_cast_("Db_conn_info")
- .Add("gplx_key", Key_const)
- .Add("data source", url.Xto_api())
- .Add("version", 3)
- ));
- }
- @Override public Db_conn_info Make_new(String raw, GfoMsg m) {
- Db_conn_info__sqlite rv = new Db_conn_info__sqlite();
- String url = m.ReadStr("data source");
- rv.url = Io_url_.new_any_(url);
- rv.Ctor_of_db_connect("", url, raw, BldApi(m, KeyVal_.new_("version", "3")));
- return rv;
- }
- public static final Db_conn_info__sqlite _ = new Db_conn_info__sqlite(); Db_conn_info__sqlite() {}
-}
\ No newline at end of file
diff --git a/140_dbs/src_100_core/gplx/dbs/Db_conn_info_tst.java b/140_dbs/src_100_core/gplx/dbs/Db_conn_info_tst.java
deleted file mode 100644
index 965e32910..000000000
--- a/140_dbs/src_100_core/gplx/dbs/Db_conn_info_tst.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
-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 .
-*/
-package gplx.dbs; import gplx.*;
-import org.junit.*;
-public class Db_conn_info_tst {
- @Before public void setup() {
- regy = new Db_conn_info_pool();
- regy.Add(Db_conn_info_mock._);
- } Db_conn_info_pool regy;
- @Test public void Parse() {
- tst_Parse("gplx_key=mock;id=1;", kv_("id", "1")); // one; gplx_key removed
- tst_Parse("gplx_key=mock;id=1;name=me;", kv_("id", "1"), kv_("name", "me")); // many
- tst_Parse("gplx_key=mock;id=1;name=me" , kv_("id", "1"), kv_("name", "me")); // no semi-colon at end
- }
- KeyVal kv_(String key, Object val) {return KeyVal_.new_(key, val);}
- void tst_Parse(String raw, KeyVal... expd) {
- Db_conn_info_mock mock = (Db_conn_info_mock)regy.Parse(raw);
- Tfds.Eq_ary_str(expd, mock.Kvs());
- }
-}
-class Db_conn_info_mock extends Db_conn_info__base {
- public KeyVal[] Kvs() {return kvs;} KeyVal[] kvs;
- @Override public String Key() {return Key_const;} public static final String Key_const = "mock";
- @Override public Db_conn_info Make_new(String raw, GfoMsg m) {
- Db_conn_info_mock rv = new Db_conn_info_mock();
- rv.kvs = new KeyVal[m.Args_count()];
- for (int i = 0; i < m.Args_count(); i++)
- rv.kvs[i] = m.Args_getAt(i);
- return rv;
- }
- public static final Db_conn_info_mock _ = new Db_conn_info_mock(); Db_conn_info_mock() {}
-}
diff --git a/140_dbs/src_100_core/gplx/dbs/Db_provider.java b/140_dbs/src_100_core/gplx/dbs/Db_provider.java
deleted file mode 100644
index 199725f65..000000000
--- a/140_dbs/src_100_core/gplx/dbs/Db_provider.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
-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 .
-*/
-package gplx.dbs; import gplx.*;
-public class Db_provider {
- public Db_provider(Db_engine engine) {
- this.engine = engine;
- this.txn_mgr = new Db_txn_mgr_base(engine);
- }
- public Db_conn_info Conn_info() {return engine.Conn_info();}
- public Db_engine Engine() {return engine;} private final Db_engine engine;
- public Db_txn_mgr Txn_mgr() {return txn_mgr;} private final Db_txn_mgr txn_mgr;
-
- public Db_stmt Prepare(Db_qry qry) {return engine.New_db_stmt(this, qry);}
- public int Exec_qry(Db_qry qry) {txn_mgr.Txn_count_(txn_mgr.Txn_count() + 1); return Int_.cast_(engine.Execute(qry));}
- public DataRdr Exec_qry_as_rdr(Db_qry qry) {return DataRdr_.cast_(engine.Execute(qry));}
- public int Exec_sql(String sql) {return this.Exec_qry(Db_qry_sql.dml_(sql));}
- public DataRdr Exec_sql_as_rdr(String sql) {return this.Exec_qry_as_rdr(Db_qry_sql.rdr_(sql));}
- public void Conn_term() {
- engine.Conn_term();
- Db_provider_pool._.Del(this.Conn_info()); // remove from pool, else rls'd instance will be cached and fail upon next use
- }
-}
diff --git a/140_dbs/src_100_core/gplx/dbs/Db_provider_.java b/140_dbs/src_100_core/gplx/dbs/Db_provider_.java
deleted file mode 100644
index 610c8e285..000000000
--- a/140_dbs/src_100_core/gplx/dbs/Db_provider_.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
-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 .
-*/
-package gplx.dbs; import gplx.*;
-public class Db_provider_ {
- public static final Db_provider Null = new_and_open_(Db_conn_info_.Null);
- public static Db_provider new_and_open_(Db_conn_info conn_info) {
- Db_engine prototype = Db_engine_regy._.Get(conn_info.Key());
- Db_engine engine = prototype.Make_new(conn_info);
- engine.Conn_open(); // auto-open
- return new Db_provider(engine);
- }
- public static int Select_fld0_as_int_or(Db_provider p, String sql, int or) {
- DataRdr rdr = DataRdr_.Null;
- try {
- rdr = p.Exec_qry_as_rdr(Db_qry_sql.rdr_(sql));
- int rv = or;
- if (rdr.MoveNextPeer()) {
- Object rv_obj = rdr.ReadAt(0);
- if (rv_obj != null) // Max(fil_id) will be NULL if tbl is empty
- rv = Int_.cast_or_(rv_obj, or);
- }
- return rv;
- }
- finally {
- rdr.Rls();
- }
- }
-}
diff --git a/140_dbs/src_100_core/gplx/dbs/Db_provider_mkr.java b/140_dbs/src_100_core/gplx/dbs/Db_provider_mkr.java
deleted file mode 100644
index 8ac23c100..000000000
--- a/140_dbs/src_100_core/gplx/dbs/Db_provider_mkr.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
-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 .
-*/
-package gplx.dbs; import gplx.*;
-public interface Db_provider_mkr {
- Db_provider Load_or_make_(Io_url db_url, Bool_obj_ref created_ref);
-}
-class Db_provider_mkr_sqlite implements Db_provider_mkr {
- public Db_provider Load_or_make_(Io_url db_url, Bool_obj_ref created_ref) {return Sqlite_engine_.Provider_load_or_make_(db_url, created_ref);}
- public static final Db_provider_mkr_sqlite _ = new Db_provider_mkr_sqlite(); Db_provider_mkr_sqlite() {}
-}
-class Db_provider_mkr_mem implements Db_provider_mkr {
- private boolean create;
- public Db_provider Load_or_make_(Io_url db_url, Bool_obj_ref create_ref) {create_ref.Val_(create); return null;}
- public static Db_provider_mkr_mem create_(boolean create) {
- Db_provider_mkr_mem rv = new Db_provider_mkr_mem();
- rv.create = create;
- return rv;
- }
-}
diff --git a/140_dbs/src_100_core/gplx/dbs/Db_provider_mkr_.java b/140_dbs/src_100_core/gplx/dbs/Db_provider_mkr_.java
deleted file mode 100644
index 74517dabf..000000000
--- a/140_dbs/src_100_core/gplx/dbs/Db_provider_mkr_.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-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 .
-*/
-package gplx.dbs; import gplx.*;
-public class Db_provider_mkr_ {
- public static final Db_provider_mkr
- Sqlite = Db_provider_mkr_sqlite._
- , Mem_create_y = Db_provider_mkr_mem.create_(Bool_.Y)
- , Mem_create_n = Db_provider_mkr_mem.create_(Bool_.N)
- ;
-}
diff --git a/140_dbs/src_100_core/gplx/dbs/Db_provider_pool.java b/140_dbs/src_100_core/gplx/dbs/Db_provider_pool.java
deleted file mode 100644
index bdc2ed0e8..000000000
--- a/140_dbs/src_100_core/gplx/dbs/Db_provider_pool.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
-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 .
-*/
-package gplx.dbs; import gplx.*;
-public class Db_provider_pool {
- private final OrderedHash hash = OrderedHash_.new_();
- public Db_provider Get_or_new(Db_conn_info connectInfo) {return Get_or_new(connectInfo.Str_raw());}
- public Db_provider Get_or_new(String raw) {
- Db_provider rv = (Db_provider)hash.Fetch(raw);
- if (rv == null) {
- rv = Db_provider_.new_and_open_(Db_conn_info_.parse_(raw));
- hash.Add(raw, rv);
- }
- return rv;
- }
- public void Del(Db_conn_info connectInfo) {hash.Del(connectInfo.Str_raw());}
- public void Clear() {
- int len = hash.Count();
- for (int i = 0; i < len; i++) {
- Db_provider provider = (Db_provider)hash.FetchAt(0);
- provider.Conn_term();
- }
- hash.Clear();
- }
- public static final Db_provider_pool _ = new Db_provider_pool(); Db_provider_pool() {}
-}
diff --git a/140_dbs/src_100_core/gplx/dbs/Db_rdr.java b/140_dbs/src_100_core/gplx/dbs/Db_rdr.java
deleted file mode 100644
index 86591502e..000000000
--- a/140_dbs/src_100_core/gplx/dbs/Db_rdr.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
-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 .
-*/
-package gplx.dbs; import gplx.*;
-public interface Db_rdr {
- boolean Move_next();
- byte[] Read_bry(int i);
- byte[] Read_bry_by_str(int i);
- String Read_str(int i);
- byte Read_byte(int i);
- int Read_int(int i);
- long Read_long(int i);
- float Read_float(int i);
- double Read_double(int i);
- void Close();
-}
diff --git a/140_dbs/src_100_core/gplx/dbs/Db_rdr_.java b/140_dbs/src_100_core/gplx/dbs/Db_rdr_.java
deleted file mode 100644
index c2fb81b5a..000000000
--- a/140_dbs/src_100_core/gplx/dbs/Db_rdr_.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
-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 .
-*/
-package gplx.dbs; import gplx.*;
-public class Db_rdr_ {
- public static final Db_rdr Null = new Db_rdr__null();
-}
-class Db_rdr__null implements Db_rdr {
- public boolean Move_next() {return false;}
- public byte[] Read_bry(int i) {return Bry_.Empty;}
- public byte[] Read_bry_by_str(int i) {return Bry_.Empty;}
- public byte Read_byte(int i) {return Byte_.MaxValue_127;}
- public String Read_str(int i) {return String_.Empty;}
- public int Read_int(int i) {return Int_.MinValue;}
- public long Read_long(int i) {return Long_.MinValue;}
- public float Read_float(int i) {return Float_.NaN;}
- public double Read_double(int i) {return Double_.NaN;}
- public void Close() {}
-}
diff --git a/140_dbs/src_100_core/gplx/dbs/Db_rdr__basic.java b/140_dbs/src_100_core/gplx/dbs/Db_rdr__basic.java
deleted file mode 100644
index cdf9a5d9f..000000000
--- a/140_dbs/src_100_core/gplx/dbs/Db_rdr__basic.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
-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 .
-*/
-package gplx.dbs; import gplx.*;
-import java.sql.ResultSet;
-class Db_rdr__basic implements Db_rdr {
- private final ResultSet rdr;
- public Db_rdr__basic(ResultSet rdr, String sql) {this.rdr = rdr; this.sql = sql;}
- public String Sql() {return sql;} private final String sql;
- public boolean Move_next() {
- try {return rdr.next();}
- catch (Exception e) {throw Err_.new_fmt_("move_next failed; check column casting error in SQL: err={0} sql={1}", Err_.Message_lang(e), sql);}
- }
- public byte[] Read_bry(int i) {try {return rdr.getBytes(i + 1);} catch (Exception e) {throw Err_.new_("read failed: i={0} type={1} err={2}", i, Bry_.Cls_name, Err_.Message_lang(e));}}
- public byte[] Read_bry_by_str(int i) {try {return Bry_.new_utf8_(rdr.getString(i + 1));} catch (Exception e) {throw Err_.new_("read failed: i={0} type={1} err={2}", i, String_.Cls_name, Err_.Message_lang(e));}}
- public String Read_str(int i) {try {return rdr.getString(i + 1);} catch (Exception e) {throw Err_.new_("read failed: i={0} type={1} err={2}", i, String_.Cls_name, Err_.Message_lang(e));}}
- public int Read_int(int i) {try {return rdr.getInt(i + 1);} catch (Exception e) {throw Err_.new_("read failed: i={0} type={1} err={2}", i, Int_.Cls_name, Err_.Message_lang(e));}}
- public long Read_long(int i) {try {return rdr.getLong(i + 1);} catch (Exception e) {throw Err_.new_("read failed: i={0} type={1} err={2}", i, Long_.Cls_name, Err_.Message_lang(e));}}
- public float Read_float(int i) {try {return rdr.getFloat(i + 1);} catch (Exception e) {throw Err_.new_("read failed: i={0} type={1} err={2}", i, Float_.Cls_name, Err_.Message_lang(e));}}
- public double Read_double(int i) {try {return rdr.getDouble(i + 1);} catch (Exception e) {throw Err_.new_("read failed: i={0} type={1} err={2}", i, Double_.Cls_name, Err_.Message_lang(e));}}
- public byte Read_byte(int i) {try {return rdr.getByte(i + 1);} catch (Exception e) {throw Err_.new_("read failed: i={0} type={1} err={2}", i, Byte_.Cls_name, Err_.Message_lang(e));}}
- public void Close() {try {rdr.close();} catch (Exception e) {throw Err_.new_("close failed: err={0}", Err_.Message_lang(e));}}
-}
diff --git a/140_dbs/src_120_sql/gplx/dbs/Sql_cmd_wtr.java b/140_dbs/src_120_sql/gplx/dbs/Sql_cmd_wtr.java
deleted file mode 100644
index d24189365..000000000
--- a/140_dbs/src_120_sql/gplx/dbs/Sql_cmd_wtr.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
-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 .
-*/
-package gplx.dbs; import gplx.*;
-import gplx.criterias.*;
-interface Sql_cmd_wtr {
- String XtoSqlQry(Db_qry qry, boolean prepare);
- String XtoSql_insert(Db_qry_insert qry);
- String XtoSql_delete(Db_qry_delete qry);
- String XtoSql_update(Db_qry_update qry);
- String XtoSql_select(Db_qry_select qry);
- void BldWhere(String_bldr sb, Criteria crt);
- void BldValStr(String_bldr sb, Db_arg prm);
-}
-class Sql_cmd_wtr_ {
- public static final Sql_cmd_wtr Ansi = Sql_cmd_wtr_ansi_.default_();
- public static final Sql_cmd_wtr BackslashSensitive = Sql_cmd_wtr_ansi_.backslash_sensitive_();
-}
diff --git a/140_dbs/src_120_sql/gplx/dbs/Sql_cmd_wtr_ansi.java b/140_dbs/src_120_sql/gplx/dbs/Sql_cmd_wtr_ansi.java
deleted file mode 100644
index cd3728818..000000000
--- a/140_dbs/src_120_sql/gplx/dbs/Sql_cmd_wtr_ansi.java
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
-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 .
-*/
-package gplx.dbs; import gplx.*;
-import gplx.criterias.*; /*Criteria_bool_base*/
-class Sql_cmd_wtr_ansi implements Sql_cmd_wtr {
- boolean prepare = false;
- public String XtoSqlQry(Db_qry cmd, boolean prepare) {
- String key = cmd.KeyOfDb_qry(); this.prepare = prepare;
- if (String_.Eq(key, Db_qry_insert.KeyConst)) return XtoSql_insert((Db_qry_insert)cmd);
- else if (String_.Eq(key, Db_qry_delete.KeyConst)) return XtoSql_delete((Db_qry_delete)cmd);
- else if (String_.Eq(key, Db_qry_update.KeyConst)) return XtoSql_update((Db_qry_update)cmd);
- else if (String_.Eq(key, Db_qry_select.KeyConst)) return XtoSql_select((Db_qry_select)cmd);
- else if (String_.Eq(key, Db_qry_sql.KeyConst)) return ((Db_qry_sql)cmd).XtoSql();
- else throw Err_.unhandled(cmd.KeyOfDb_qry());
- }
- public String XtoSql_delete(Db_qry_delete cmd) {
- String_bldr sb = String_bldr_.new_();
- sb.Add_many("DELETE FROM ", cmd.BaseTable());
- BldWhere(sb, cmd.Where());
- return sb.XtoStr();
- }
- public String XtoSql_insert(Db_qry_insert cmd) {
- String_bldr sb = String_bldr_.new_();
- if (cmd.Select() != null) {
- sb.Add_many("INSERT INTO ", cmd.BaseTable(), " (");
- for (int i = 0; i < cmd.Cols().Count(); i++) {
- Sql_select_fld_base fld = cmd.Cols().FetchAt(i);
- sb.Add(fld.Alias());
- sb.Add(i == cmd.Cols().Count() - 1 ? ") " : ", ");
- }
- sb.Add(XtoSql_select(cmd.Select()));
- return sb.XtoStr();
- }
- int argCount = cmd.Args().Count();
- if (argCount == 0) throw Err_.new_("Db_qry_insert has no columns").Add("baseTable", cmd.BaseTable());
- int last = argCount - 1;
- sb.Add_many("INSERT INTO ", cmd.BaseTable(), " (");
- for (int i = 0; i < argCount; i++) {
- KeyVal pair = cmd.Args().FetchAt(i);
- this.XtoSqlCol(sb, pair.Key_as_obj());
- sb.Add(i == last ? ")" : ", ");
- }
- sb.Add(" VALUES (");
- for (int i = 0; i < argCount; i++) {
- KeyVal pair = cmd.Args().FetchAt(i);
- Db_arg prm = (Db_arg)pair.Val();
- this.BldValStr(sb, prm);
- sb.Add(i == last ? ")" : ", ");
- }
- return sb.XtoStr();
- }
- public String XtoSql_update(Db_qry_update cmd) {
- int argCount = cmd.Args().Count();
- if (argCount == 0) throw Err_.new_("Db_qry_update has no columns").Add("baseTable", cmd.BaseTable());
- String_bldr sb = String_bldr_.new_();
- sb.Add_many("UPDATE ", cmd.BaseTable(), " SET ");
- for (int i = 0; i < argCount; i++) {
- KeyVal pair = cmd.Args().FetchAt(i);
- if (i > 0) sb.Add(", ");
- this.XtoSqlCol(sb, pair.Key_as_obj());
- sb.Add("=");
- this.BldValStr(sb, (Db_arg)pair.Val());
- }
- BldWhere(sb, cmd.Where());
- return sb.XtoStr();
- }
- public String XtoSql_select(Db_qry_select cmd) {
- String_bldr sb = String_bldr_.new_();
- sb.Add("SELECT ");
- if (cmd.Cols().Distinct()) sb.Add("DISTINCT ");
- Sql_select_fld_list flds = cmd.Cols().Flds();
- if (flds.Count() == 0) sb.Add("*");
- for (int i = 0; i < flds.Count(); i++) {
- Sql_select_fld_base fld = (Sql_select_fld_base)flds.FetchAt(i);
- if (i > 0) sb.Add(", ");
- this.XtoSqlCol(sb, fld.XtoSql());
- }
- XtoSql_from(sb, cmd.From());
- BldWhere(sb, cmd.Where());
- XtoSql_group_by(sb, cmd.GroupBy());
- XtoSql_order_by(sb, cmd.OrderBy());
- XtoSql_limit(sb, cmd.Limit());
- return sb.XtoStr();
- }
- void XtoSql_group_by(String_bldr sb, Sql_group_by groupBy) {
- if (groupBy == null) return;
- sb.Add(" GROUP BY ");
- for (int i = 0; i < groupBy.Flds().Count(); i++) {
- String item = (String)groupBy.Flds().FetchAt(i);
- if (i > 0) sb.Add(", ");
- sb.Add(item);
- }
- }
- void XtoSql_order_by(String_bldr sb, Sql_order_by orderBy) {
- if (orderBy == null) return;
- sb.Add(" ORDER BY ");
- for (int i = 0; i < orderBy.Flds().Count(); i++) {
- Sql_order_by_itm item = (Sql_order_by_itm)orderBy.Flds().FetchAt(i);
- if (i > 0) sb.Add(", ");
- sb.Add(item.XtoSql());
- }
- }
- void XtoSql_limit(String_bldr sb, int limit) {
- if (limit == Db_qry_select.Limit_disabled) return;
- sb.Add(" LIMIT ").Add(limit);
- }
- void XtoSql_from(String_bldr sb, Sql_from from) {
- for (Object tblObj : from.Tbls()) {
- Sql_tbl_src tbl = (Sql_tbl_src)tblObj;
- sb.Add_many
- ( " ", String_.Upper(tbl.JoinType().Name()), " ", tbl.TblName(), String_.FormatOrEmptyStrIfNull(" {0}", tbl.Alias())
- );
- String tblAliasForJoin = tbl.Alias() == null ? tbl.TblName() : tbl.Alias();
- for (int i = 0; i < tbl.JoinLinks().Count(); i++) {
- Sql_join_itm joinLink = (Sql_join_itm)tbl.JoinLinks().FetchAt(i);
- String conjunction = i == 0 ? " ON " : " AND ";
- sb.Add_many
- ( conjunction, joinLink.SrcTbl(), ".", joinLink.SrcFld(), "=", tblAliasForJoin, ".", joinLink.TrgFldOrSrcFld()
- );
- }
- }
- }
- public void XtoSqlCol(String_bldr sb, Object obj) {
- if (obj == null) throw Err_.null_("ColName");
- sb.Add_obj(obj); // FIXME: options for bracketing; ex: [name]
- }
- public void BldValStr(String_bldr sb, Db_arg prm) {
- if (prepare) {
- sb.Add("?");
- return;
- }
- Object val = prm.Val();
- if (val == null) {
- sb.Add("NULL");
- return;
- }
- Class> valType = val.getClass();
- if (valType == Boolean.class)
- sb.Add_obj(Bool_.Xto_int(Bool_.cast_(val))); // NOTE!: save boolean to 0 or 1, b/c (a) db may not support bit datatype (sqllite) and (b) avoid i18n issues with "true"/"false"
- else if
- ( valType == Byte.class || valType == Short.class
- || valType == Integer.class || valType == Long.class
- || valType == Float.class || valType == Double.class
- )
- sb.Add(Object_.Xto_str_strict_or_null(val));
- else if (valType == DateAdp.class)
- XtoSqlVal_DateAdp(sb, prm, (DateAdp)val);
- else if (valType == DecimalAdp.class) {
- DecimalAdp valDecimal = (DecimalAdp)val;
- sb.Add(valDecimal.Xto_str());
- }
- // else if (valType == System.Enum.class)
-// sb.Add_any(Enm_.XtoInt(val)); // save enum as 0 or 1, since (a) no db supports enum datatype; (b) names are fungible; (c) int is less space than name
- else {
- String valString = Object_.Xto_str_strict_or_null(val);
- XtoSqlVal_Str(sb, prm, valString);
- }
- }
- @gplx.Virtual public void XtoSqlVal_Str(String_bldr sb, Db_arg prm, String s) {
- sb.Add_many("'", String_.Replace(s, "'", "''"), "'"); // stupid escaping of '
- }
- @gplx.Virtual public void XtoSqlVal_DateAdp(String_bldr sb, Db_arg prm, DateAdp s) {
- sb.Add_many("'", s.XtoStr_gplx_long(), "'"); // stupid escaping of '
- }
- void BldWhere(String_bldr sb, Sql_where where) {
- if (where == null || where.Crt() == Db_crt_.Wildcard) return;
- sb.Add(" WHERE ");
- this.BldWhere(sb, where.Crt());
- }
- public void BldWhere(String_bldr sb, Criteria crt) {
- Criteria_bool_base boolOp = Criteria_bool_base.as_(crt);
- if (boolOp != null) {
- sb.Add("(");
- BldWhere(sb, boolOp.Lhs());
- sb.Add_many(" ", boolOp.OpLiteral(), " ");
- BldWhere(sb, boolOp.Rhs());
- sb.Add(")");
- return;
- }
- if (crt.Crt_tid() == Criteria_.Tid_db_obj_ary) {
- Append_db_obj_ary(sb, (Db_obj_ary_crt)crt);
- }
- else {
- Criteria_wrapper leaf = Criteria_wrapper.as_(crt); if (leaf == null) throw Err_.invalid_op_(crt.XtoStr());
- sb.Add(leaf.Name_of_GfoFldCrt());
- AppendWhereItem(sb, leaf.Crt_of_GfoFldCrt());
- }
- }
- void AppendWhereItem(String_bldr sb, Criteria crt) {
- switch (crt.Crt_tid()) {
- case Criteria_.Tid_eq: AppendEqual(sb, Criteria_eq.as_(crt)); break;
- case Criteria_.Tid_comp: AppendCompare(sb, Criteria_comp.as_(crt)); break;
- case Criteria_.Tid_between: AppendBetween(sb, Criteria_between.as_(crt)); break;
- case Criteria_.Tid_in: AppendIn(sb, Criteria_in.as_(crt)); break;
- case Criteria_.Tid_like: AppendLike(sb, Criteria_like.as_(crt)); break;
- case Criteria_.Tid_iomatch: AppendIoMatch(sb, Criteria_ioMatch.as_(crt)); break;
- default: throw Err_.unhandled(crt);
- }
- }
- void AppendEqual(String_bldr sb, Criteria_eq crt) {
- sb.Add(crt.Negated() ? "!=" : "=");
- this.BldValStr(sb, Wrap(crt.Value()));
- }
- void AppendCompare(String_bldr sb, Criteria_comp crt) {
- sb.Add_many(crt.XtoSymbol());
- this.BldValStr(sb, Wrap(crt.Value()));
- }
- void AppendBetween(String_bldr sb, Criteria_between crt) {
- sb.Add(crt.Negated() ? " NOT BETWEEN " : " BETWEEN ");
- this.BldValStr(sb, Wrap(crt.Lhs()));
- sb.Add(" AND ");
- this.BldValStr(sb, Wrap(crt.Rhs()));
- }
- void AppendLike(String_bldr sb, Criteria_like crt) {
- sb.Add(crt.Negated() ? " NOT LIKE " : " LIKE ");
- this.BldValStr(sb, Wrap(crt.Pattern().Raw()));
- sb.Add_fmt(" ESCAPE '{0}'", crt.Pattern().Escape());
- }
- void AppendIn(String_bldr sb, Criteria_in crt) {
- sb.Add(crt.Negated() ? " NOT IN (" : " IN (");
- int last = crt.Values().length - 1;
- for (int i = 0; i < crt.Values().length; i++) {
- Object val = crt.Values()[i];
- this.BldValStr(sb, Wrap(val));
- sb.Add(i == last ? ")" : ", ");
- }
- }
- void AppendIoMatch(String_bldr sb, Criteria_ioMatch crt) {
- sb.Add(crt.Negated() ? " NOT IOMATCH " : " IOMATCH ");
- this.BldValStr(sb, Wrap(crt.Pattern().Raw()));
- }
- public void Append_db_obj_ary(String_bldr sb, Db_obj_ary_crt crt) {
- Object[][] ary = crt.Vals();
- int ary_len = ary.length;
- Db_fld[] flds = crt.Flds();
- for (int i = 0; i < ary_len; i++) {
- Object[] itm = (Object[])ary[i];
- int itm_len = itm.length;
- if (i != 0) sb.Add(" OR ");
- sb.Add("(");
- for (int j = 0; j < itm_len; j++) {
- if (j != 0) sb.Add(" AND ");
- Db_fld fld = flds[j];
- Object val = itm[j];
- boolean quote = false;
- switch (fld.Type_tid()) {
- case ClassAdp_.Tid_str:
- case ClassAdp_.Tid_char:
- case ClassAdp_.Tid_date:
- quote = true;
- break;
- }
- sb.Add(fld.Name());
- sb.Add("=");
- if (quote) sb.Add("'");
- sb.Add(Object_.Xto_str_strict_or_empty(val));
- if (quote) sb.Add("'");
- }
- sb.Add(")");
- }
- }
- Db_arg Wrap(Object val) {return new Db_arg("unknown", val);}
-}
-class Sql_cmd_wtr_ansi_ {
- public static Sql_cmd_wtr default_() {return new Sql_cmd_wtr_ansi();}
- public static Sql_cmd_wtr backslash_sensitive_() {return Sql_cmd_wtr_ansi_backslashSensitive.new_();}
-}
-class Sql_cmd_wtr_ansi_backslashSensitive extends Sql_cmd_wtr_ansi { @Override public void XtoSqlVal_Str(String_bldr sb, Db_arg prm, String s) {
- if (String_.Has(s, "\\")) s = String_.Replace(s, "\\", "\\\\");
- super.XtoSqlVal_Str(sb, prm, s);
- }
- public static Sql_cmd_wtr_ansi_backslashSensitive new_() {return new Sql_cmd_wtr_ansi_backslashSensitive();} Sql_cmd_wtr_ansi_backslashSensitive() {}
-}
diff --git a/140_dbs/src_120_sql/gplx/dbs/Sql_join_itm.java b/140_dbs/src_120_sql/gplx/dbs/Sql_join_itm.java
deleted file mode 100644
index 13f1403b3..000000000
--- a/140_dbs/src_120_sql/gplx/dbs/Sql_join_itm.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
-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 .
-*/
-package gplx.dbs; import gplx.*;
-public class Sql_join_itm {
- public String SrcTbl() {return srcTbl;} public Sql_join_itm SrcTbl_(String v) {srcTbl = v; return this;} private String srcTbl;
- public String SrcFld() {return srcFld;} public Sql_join_itm SrcFld_(String v) {srcFld = v; return this;} private String srcFld;
- public String TrgFld() {return trgFld;} public Sql_join_itm TrgFld_(String v) {trgFld = v; return this;} private String trgFld;
- public String TrgFldOrSrcFld() {return trgFld == null ? srcFld : trgFld;}
- public static Sql_join_itm new_(String trgFld, String srcTbl, String srcFld) {
- Sql_join_itm rv = new Sql_join_itm();
- rv.trgFld = trgFld; rv.srcTbl = srcTbl; rv.srcFld = srcFld;
- return rv;
- } Sql_join_itm() {}
- public static Sql_join_itm same_(String tbl, String fld) {
- Sql_join_itm rv = new Sql_join_itm();
- rv.trgFld = fld; rv.srcTbl = tbl; rv.srcFld = fld;
- return rv;
- }
-}
-class Sql_from {
- public ListAdp Tbls() {return tbls;} ListAdp tbls = ListAdp_.new_();
- public Sql_tbl_src BaseTable() {return (Sql_tbl_src)tbls.FetchAt(0);}
-
- public static Sql_from new_(Sql_tbl_src baseTable) {
- Sql_from rv = new Sql_from();
- rv.tbls.Add(baseTable);
- return rv;
- } Sql_from() {}
-}
-class Sql_tbl_src {
- public Sql_join_itmType JoinType() {return type;} public Sql_tbl_src JoinType_(Sql_join_itmType v) {this.type = v; return this;} Sql_join_itmType type = Sql_join_itmType.Inner;
- public ListAdp JoinLinks() {return joinLinks;} ListAdp joinLinks = ListAdp_.new_();
- public String TblName() {return tblName;} public Sql_tbl_src TblName_(String s) {tblName = s; return this;} private String tblName;
- public String Alias() {return alias;} public Sql_tbl_src Alias_(String s) {alias = s; return this;} private String alias;
- public void XtoSql(String_bldr sb) {
- sb.Add_many(tblName, alias == null ? "" : " " + alias);
- }
- public static Sql_tbl_src new_() {return new Sql_tbl_src();} Sql_tbl_src() {}
-}
-class Sql_join_itmType {
- public int Val() {return val;} int val;
- public String Name() {return name;} private String name;
- Sql_join_itmType(int v, String name) {this.val = v; this.name = name;}
- public static final Sql_join_itmType
- From = new Sql_join_itmType(0, "FROM")
- , Inner = new Sql_join_itmType(1, "INNER JOIN")
- , Left = new Sql_join_itmType(2, "LEFT JOIN")
- , Right = new Sql_join_itmType(3, "RIGHT JOIN")
- , Outer = new Sql_join_itmType(4, "OUTER JOIN")
- , Cross = new Sql_join_itmType(5, "CROSS JOIN")
- ;
-}
diff --git a/140_dbs/src_120_sql/gplx/dbs/Sql_order_by.java b/140_dbs/src_120_sql/gplx/dbs/Sql_order_by.java
deleted file mode 100644
index fa30513f9..000000000
--- a/140_dbs/src_120_sql/gplx/dbs/Sql_order_by.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
-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 .
-*/
-package gplx.dbs; import gplx.*;
-import gplx.lists.*; /*ComparerAble*/
-class Sql_order_by {
- public ListAdp Flds() {return flds;} ListAdp flds = ListAdp_.new_();
-
- public static Sql_order_by new_(Sql_order_by_itm... ary) {
- Sql_order_by rv = new Sql_order_by();
- for (Sql_order_by_itm itm : ary)
- rv.flds.Add(itm);
- return rv;
- } Sql_order_by() {}
-}
-class Sql_group_by {
- public ListAdp Flds() {return flds;} ListAdp flds = ListAdp_.new_();
-
- public static Sql_group_by new_(String... ary) {
- Sql_group_by rv = new Sql_group_by();
- for (String itm : ary)
- rv.flds.Add(itm);
- return rv;
- } Sql_group_by() {}
-}
-class Sql_order_by_itm {
- public String Name() {return name;} private String name;
- public boolean Ascending() {return ascending;} private boolean ascending;
- public String XtoSql() {
- String ascString = ascending ? "" : " DESC";
- return name + ascString;
- }
- public static Sql_order_by_itm new_(String name, boolean ascending) {
- Sql_order_by_itm rv = new Sql_order_by_itm();
- rv.name = name; rv.ascending = ascending;
- return rv;
- } Sql_order_by_itm() {}
-}
-class Sql_order_by_sorter implements ComparerAble {
- public int compare(Object lhsObj, Object rhsObj) {
- GfoNde lhs = (GfoNde)lhsObj; GfoNde rhs = (GfoNde)rhsObj;
- Sql_order_by_itm item = null; Object lhsData = null, rhsData = null;
- for (int i = 0; i < items.length; i++) {
- item = items[i];
- lhsData = lhs.Read(item.Name()); rhsData = rhs.Read(item.Name());
- int compare = CompareAble_.Compare_obj(lhsData, rhsData);
- if (compare == CompareAble_.Same) continue;
- int ascendingVal = item.Ascending() ? 1 : -1;
- return compare * ascendingVal;
- }
- return CompareAble_.Same;
- }
- Sql_order_by_itm[] items;
- public static ComparerAble new_(Sql_order_by_itm[] items) {
- Sql_order_by_sorter rv = new Sql_order_by_sorter();
- rv.items = items;
- return rv;
- }
-}
\ No newline at end of file
diff --git a/140_dbs/src_120_sql/gplx/dbs/Sql_select.java b/140_dbs/src_120_sql/gplx/dbs/Sql_select.java
deleted file mode 100644
index 52ab564ee..000000000
--- a/140_dbs/src_120_sql/gplx/dbs/Sql_select.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
-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 .
-*/
-package gplx.dbs; import gplx.*;
-class Sql_select {
- public Sql_select_fld_list Flds() {return flds;} Sql_select_fld_list flds = Sql_select_fld_list.new_();
- public boolean Distinct() {return distinct;} public void Distinct_set(boolean v) {distinct = v;} private boolean distinct;
- public void Add(String fldName) {flds.Add(Sql_select_fld_fld.new_(Sql_select_fld_base.Tbl_null, fldName, fldName));}
- public void Add(String fldName, String alias) {flds.Add(Sql_select_fld_fld.new_(Sql_select_fld_base.Tbl_null, fldName, alias));}
- public void Add(Sql_select_fld_base fld) {flds.Add(fld);}
-
- public static final Sql_select All = all_(); static Sql_select all_() {Sql_select rv = new_(); rv.Add(Sql_select_fld_wild._); return rv;}
- public static Sql_select new_() {return new Sql_select();} Sql_select() {}
-}
-class Sql_select_fld_list {
- public int Count() {return hash.Count();}
- public void Add(Sql_select_fld_base fld) {hash.Add(fld.Alias(), fld);}
- public Sql_select_fld_base FetchAt(int i) {return (Sql_select_fld_base)hash.FetchAt(i);}
- public Sql_select_fld_base FetchOrNull(String k) {return (Sql_select_fld_base)hash.Fetch(k);}
- public GfoFldList XtoGfoFldLst(TdbTable tbl) {
- GfoFldList rv = GfoFldList_.new_();
- for (int i = 0; i < this.Count(); i++) {
- Sql_select_fld_base selectFld = this.FetchAt(i);
- GfoFld fld = tbl.Flds().FetchOrNull(selectFld.Fld());
- if (fld == null) throw Err_.new_("fld not found in tbl").Add("fldName", selectFld.Fld()).Add("tblName", tbl.Name()).Add("tblFlds", tbl.Flds().XtoStr());
- if (rv.Has(selectFld.Alias())) throw Err_.new_("alias is not unique").Add("fldName", selectFld.Fld()).Add("flds", rv.XtoStr());
- selectFld.GroupBy_type(fld);
- rv.Add(selectFld.Alias(), selectFld.ValType());
- }
- return rv;
- }
- public String XtoStr() {
- String_bldr sb = String_bldr_.new_();
- for (int i = 0; i < this.Count(); i++) {
- Sql_select_fld_base fld = this.FetchAt(i);
- sb.Add_fmt("{0},{1}|", fld.Fld(), fld.Alias());
- }
- return sb.XtoStr();
- }
- OrderedHash hash = OrderedHash_.new_();
- public static Sql_select_fld_list new_() {return new Sql_select_fld_list();} Sql_select_fld_list() {}
-}
-abstract class Sql_select_fld_base {
- public String Tbl() {return tbl;} public void Tbl_set(String val) {tbl = val;} private String tbl;
- public String Fld() {return fld;} public void Fld_set(String val) {fld = val;} private String fld;
- public String Alias() {return alias;} public void Alias_set(String val) {alias = val;} private String alias;
- public ClassXtn ValType() {return valType;} public void ValType_set(ClassXtn val) {valType = val;} ClassXtn valType = ObjectClassXtn._;
- public abstract Object GroupBy_eval(Object groupByVal, Object curVal, ClassXtn type);
- @gplx.Virtual public void GroupBy_type(GfoFld fld) {this.ValType_set(fld.Type());}
- @gplx.Virtual public boolean Type_fld() {return true;}
- public abstract String XtoSql();
- public static final String Tbl_null = null;
- @gplx.Internal protected void ctor_(String tbl, String fld, String alias) {
- Tbl_set(tbl); Fld_set(fld); Alias_set(alias);
- }
-}
-class Sql_select_fld_wild extends Sql_select_fld_base {
- @Override public Object GroupBy_eval(Object groupByVal, Object curVal, ClassXtn type) {throw Err_.new_("group by eval not allowed on *");}
- @Override public void GroupBy_type(GfoFld fld) {throw Err_.new_("group by type not allowed on *");}
- @Override public String XtoSql() {return "*";}
- public static final Sql_select_fld_wild _ = new Sql_select_fld_wild(); Sql_select_fld_wild() {this.ctor_(Tbl_null, "*", "*");}
-}
-class Sql_select_fld_fld extends Sql_select_fld_base {
- @Override public Object GroupBy_eval(Object groupByVal, Object curVal, ClassXtn type) {return curVal;}
- @Override public void GroupBy_type(GfoFld fld) {this.ValType_set(fld.Type());}
- @Override public String XtoSql() {
- String rv = Fld();
- if (Tbl() != Tbl_null)
- rv = Tbl() + "." + Fld();
- if (!String_.Eq(Alias(), Fld()))
- rv = rv + " AS " + Alias();
- return rv;
- }
- public static Sql_select_fld_fld new_(String tbl, String fld, String alias) {
- Sql_select_fld_fld rv = new Sql_select_fld_fld();
- rv.ctor_(tbl, fld, alias);
- return rv;
- } Sql_select_fld_fld() {}
-}
-abstract class Sql_select_fld_func_base extends Sql_select_fld_base {
- public abstract String XtoSql_functionName();
- @Override public boolean Type_fld() {return false;}
- @Override public String XtoSql() {
- return String_.Format("{0}({1}) AS {2}", XtoSql_functionName(), Fld(), Alias());
- }
-}
-class Sql_select_fld_count extends Sql_select_fld_func_base {
- @Override public String XtoSql_functionName() {return "COUNT";}
- @Override public void GroupBy_type(GfoFld fld) {this.ValType_set(IntClassXtn._);}
- @Override public Object GroupBy_eval(Object groupByVal, Object curVal, ClassXtn type) {
- if (groupByVal == null) return 1;
- return Int_.cast_(groupByVal) + 1;
- }
- public static Sql_select_fld_count new_(String tbl, String fld, String alias) {
- Sql_select_fld_count rv = new Sql_select_fld_count();
- rv.ctor_(tbl, fld, alias);
- return rv;
- } Sql_select_fld_count() {}
-}
-class Sql_select_fld_sum extends Sql_select_fld_func_base {
- @Override public String XtoSql_functionName() {return "SUM";}
- @Override public void GroupBy_type(GfoFld fld) {this.ValType_set(IntClassXtn._);}
- @Override public Object GroupBy_eval(Object groupByVal, Object curVal, ClassXtn type) {
- if (groupByVal == null) return Int_.cast_(curVal);
- return Int_.cast_(groupByVal) + Int_.cast_(curVal);
- }
- public static Sql_select_fld_sum new_(String tbl, String fld, String alias) {
- Sql_select_fld_sum rv = new Sql_select_fld_sum();
- rv.ctor_(tbl, fld, alias);
- return rv;
- } Sql_select_fld_sum() {}
-}
-class Sql_select_fld_minMax extends Sql_select_fld_func_base {
- int compareType = CompareAble_.Less;
- @Override public String XtoSql_functionName() {return compareType == CompareAble_.Less ? "MIN" : "MAX";}
- @Override public Object GroupBy_eval(Object groupByVal, Object curVal, ClassXtn type) {
- if (groupByVal == null) return curVal;
- int compareVal = CompareAble_.Compare_obj(curVal, groupByVal);
- return compareVal * compareType > 0 ? curVal : groupByVal;
- }
- public static Sql_select_fld_minMax min_(String tbl, String fld, String alias) {return new_(CompareAble_.Less, tbl, fld, alias);}
- public static Sql_select_fld_minMax max_(String tbl, String fld, String alias) {return new_(CompareAble_.More, tbl, fld, alias);}
- static Sql_select_fld_minMax new_(int compareType, String tbl, String fld, String alias) {
- Sql_select_fld_minMax rv = new Sql_select_fld_minMax();
- rv.compareType = compareType;
- rv.ctor_(tbl, fld, alias);
- return rv;
- } Sql_select_fld_minMax() {}
-}
diff --git a/140_dbs/src_120_sql/gplx/dbs/Sql_where.java b/140_dbs/src_120_sql/gplx/dbs/Sql_where.java
deleted file mode 100644
index bb58f459b..000000000
--- a/140_dbs/src_120_sql/gplx/dbs/Sql_where.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
-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 .
-*/
-package gplx.dbs; import gplx.*;
-import gplx.criterias.*;
-class Sql_where {
- public Criteria Crt() {return crt;} Criteria crt;
- public static Sql_where merge_or_new_(Sql_where where, Criteria crt) {
- return where == null
- ? Sql_where.new_(crt)
- : Sql_where.new_(Criteria_.And(where.Crt(), crt));
- }
- public static Sql_where new_(Criteria crt) {
- Sql_where rv = new Sql_where();
- rv.crt = crt;
- return rv;
- } Sql_where() {}
-}
diff --git a/140_dbs/tst/gplx/dbs/AnsiValWtr_tst.java b/140_dbs/tst/gplx/dbs/AnsiValWtr_tst.java
deleted file mode 100644
index d787081bf..000000000
--- a/140_dbs/tst/gplx/dbs/AnsiValWtr_tst.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
-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 .
-*/
-package gplx.dbs; import gplx.*;
-import org.junit.*;
-public class AnsiValWtr_tst {
- @Test public void BldValStr() {
- tst_XtoSqlVal(null, "NULL");
- tst_XtoSqlVal(true, "1");
- tst_XtoSqlVal(false, "0");
- tst_XtoSqlVal(1, "1");
- tst_XtoSqlVal(1.1, "1.1");
- tst_XtoSqlVal("a", "'a'");
- tst_XtoSqlVal("a'b", "'a''b'");
- }
- void tst_XtoSqlVal(Object val, String expd) {
- String_bldr sb = String_bldr_.new_();
- Db_arg prm = new Db_arg("not needed", val);
- valWtr.BldValStr(sb, prm);
- Tfds.Eq(expd, sb.XtoStr());
- }
- Sql_cmd_wtr valWtr = Sql_cmd_wtr_ansi_.default_();
-}
diff --git a/140_dbs/tst/gplx/dbs/Db_provider_fxt.java b/140_dbs/tst/gplx/dbs/Db_provider_fxt.java
deleted file mode 100644
index 530062275..000000000
--- a/140_dbs/tst/gplx/dbs/Db_provider_fxt.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
-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 .
-*/
-package gplx.dbs; import gplx.*;
-public class Db_provider_fxt implements RlsAble {
- public Db_provider Provider() {return provider;} public Db_provider_fxt Provider_(Db_provider v) {provider = v; return this;} Db_provider provider;
- public void DmlAffectedAvailable_(boolean v) {dmlAffectedAvailable = v;} private boolean dmlAffectedAvailable = true;
- public void ini_DeleteAll(String tbl) {provider.Exec_qry(Db_qry_.delete_tbl_(tbl));}
- public void tst_ExecDml(int expd, Db_qry qry) {
- int actl = provider.Exec_qry(qry);
- if (dmlAffectedAvailable)
- Tfds.Eq(expd, actl, "Exec_qry failed: sql={0}", qry.XtoSql());
- }
- public void tst_ExecRdrTbl(int expd, String tblName) {tst_ExecRdr(expd, Db_qry_.select_tbl_(tblName));}
- public void tst_ExecRdr(int expd, Db_qry qry) {
- DataRdr rdr = DataRdr_.Null;
- try {
- rdr = provider.Exec_qry_as_rdr(qry);
- tbl = GfoNde_.rdr_(rdr);
- }
- catch (Exception e) {Err_.Noop(e); rdr.Rls();}
- Tfds.Eq(expd, tbl.Subs().Count(), "Exec_qry_as_rdr failed: sql={0}", qry.XtoSql());
- } GfoNde tbl;
- public GfoNde tst_RowAry(int index, Object... expdValAry) {
- GfoNde record = tbl.Subs().FetchAt_asGfoNde(index);
- Object[] actlValAry = new Object[expdValAry.length];
- for (int i = 0; i < actlValAry.length; i++)
- actlValAry[i] = record.ReadAt(i);
- Tfds.Eq_ary(actlValAry, expdValAry);
- return record;
- }
- public void Rls() {provider.Conn_term();}
-
- public static Db_provider Mysql() {return Db_provider_.new_and_open_(Db_conn_info__mysql.new_("127.0.0.1", "unit_tests", "gplx_user", "gplx_password"));}
- public static Db_provider Tdb(String fileName) {return Db_provider_.new_and_open_(Db_conn_info_.tdb_(Tfds.RscDir.GenSubDir_nest("140_dbs", "tdbs").GenSubFil(fileName)));}
- public static Db_provider Postgres() {return Db_provider_.new_and_open_(Db_conn_info__postgres.new_("127.0.0.1", "unit_tests", "gplx_user", "gplx_password"));}
- public static Db_provider Sqlite() {return Db_provider_.new_and_open_(Db_conn_info__sqlite.load_(Tfds.RscDir.GenSubFil_nest("140_dbs", "sqlite", "unit_tests.db")));}
-// public static Db_provider Mssql() {return MssqlConnectUrl.WindowsAuth(".", "unit_tests");
- public static final boolean SkipPostgres = Tfds.SkipDb || true;
-}
\ No newline at end of file
diff --git a/140_dbs/tst/gplx/dbs/Sql_cmd_wtr_ansi_tst.java b/140_dbs/tst/gplx/dbs/Sql_cmd_wtr_ansi_tst.java
deleted file mode 100644
index 2a915cde5..000000000
--- a/140_dbs/tst/gplx/dbs/Sql_cmd_wtr_ansi_tst.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
-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 .
-*/
-package gplx.dbs; import gplx.*;
-import org.junit.*;
-import gplx.criterias.*;
-public class Sql_cmd_wtr_ansi_tst {
- Sql_cmd_wtr whereWtr = Sql_cmd_wtr_ansi_.default_();
- @Test public void Basic() {
- tst_XtoSql_where(Db_crt_.eq_("id", 1), "id=1");
- tst_XtoSql_where(Db_crt_.eqn_("id", 1), "id!=1");
- tst_XtoSql_where(Db_crt_.mt_("id", 1), "id>1");
- tst_XtoSql_where(Db_crt_.mte_("id", 1), "id>=1");
- tst_XtoSql_where(Db_crt_.lt_("id", 1), "id<1");
- tst_XtoSql_where(Db_crt_.lte_("id", 1), "id<=1");
- tst_XtoSql_where(Db_crt_.between_("id", 1, 2), "id BETWEEN 1 AND 2");
- tst_XtoSql_where(Db_crt_.in_("id", 1, 2, 3), "id IN (1, 2, 3)");
- }
- @Test public void AndOr() {
- tst_XtoSql_where(Criteria_.And(Db_crt_.eq_("id", 1), Db_crt_.eq_("name", "me")), "(id=1 AND name='me')");
- tst_XtoSql_where(Criteria_.Or(Db_crt_.eq_("id", 1), Db_crt_.eq_("name", "me")), "(id=1 OR name='me')");
- tst_XtoSql_where(Criteria_.Or(Db_crt_.eq_("id", 1), Criteria_.And(Db_crt_.eq_("name", "me"), Db_crt_.eq_("id", 1))), "(id=1 OR (name='me' AND id=1))");
- }
- void tst_XtoSql_where(Criteria crt, String expd) {
- String_bldr sb = String_bldr_.new_();
- whereWtr.BldWhere(sb, crt);
- Tfds.Eq(expd, sb.XtoStr());
- }
-}
diff --git a/400_xowa/src/gplx/xowa/files/wiki_orig/Xof_wiki_orig_itm.java b/400_xowa/src/gplx/xowa/files/wiki_orig/Xof_wiki_orig_itm.java
deleted file mode 100644
index 9371d1c19..000000000
--- a/400_xowa/src/gplx/xowa/files/wiki_orig/Xof_wiki_orig_itm.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
-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 .
-*/
-package gplx.xowa.files.wiki_orig; import gplx.*; import gplx.xowa.*; import gplx.xowa.files.*;
-public class Xof_wiki_orig_itm {
- public int Id() {return id;} public Xof_wiki_orig_itm Id_(int v) {id = v; return this;} private int id;
- public byte[] Ttl() {return ttl;} public Xof_wiki_orig_itm Ttl_(byte[] v) {ttl = v; return this;} private byte[] ttl;
- public byte Status() {return status;} public Xof_wiki_orig_itm Status_(byte v) {status = v; return this;} private byte status;
- public byte Orig_repo() {return orig_repo;} public Xof_wiki_orig_itm Orig_repo_(byte v) {orig_repo = v; return this;} private byte orig_repo;
- public int Orig_w() {return orig_w;} public Xof_wiki_orig_itm Orig_w_(int v) {orig_w = v; return this;} private int orig_w;
- public int Orig_h() {return orig_h;} public Xof_wiki_orig_itm Orig_h_(int v) {orig_h = v; return this;} private int orig_h;
- public int Orig_ext() {return orig_ext;} public Xof_wiki_orig_itm Orig_ext_(int v) {orig_ext = v; return this;} private int orig_ext;
- public byte[] Orig_redirect() {return orig_redirect;} public Xof_wiki_orig_itm Orig_redirect_(byte[] v) {orig_redirect = v; return this;} private byte[] orig_redirect;
- public static Xof_wiki_orig_itm load_(DataRdr rdr) {
- Xof_wiki_orig_itm rv = new Xof_wiki_orig_itm();
- rv.ttl = rdr.ReadBryByStr(Xof_wiki_orig_tbl.Fld_orig_ttl);
- rv.status = rdr.ReadByte(Xof_wiki_orig_tbl.Fld_status);
- rv.orig_repo = rdr.ReadByte(Xof_wiki_orig_tbl.Fld_orig_repo);
- rv.orig_w = rdr.ReadInt(Xof_wiki_orig_tbl.Fld_orig_w);
- rv.orig_h = rdr.ReadInt(Xof_wiki_orig_tbl.Fld_orig_h);
- rv.orig_ext = rdr.ReadInt(Xof_wiki_orig_tbl.Fld_orig_ext);
- rv.orig_redirect = rdr.ReadBryByStr(Xof_wiki_orig_tbl.Fld_orig_redirect);
- return rv;
- }
- public static final Xof_wiki_orig_itm Null = null;
-}
diff --git a/400_xowa/src/gplx/xowa/hdumps/Db_provider_key.java b/400_xowa/src/gplx/xowa/hdumps/Db_provider_key.java
deleted file mode 100644
index ccbf7d957..000000000
--- a/400_xowa/src/gplx/xowa/hdumps/Db_provider_key.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-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 .
-*/
-package gplx.xowa.hdumps; import gplx.*; import gplx.xowa.*;
-import gplx.dbs.*;
-public class Db_provider_key {
- public Db_provider_key(String key, Db_conn_info conn_info, GfoInvkAbleCmd init_cmd) {this.key = key; this.conn_info = conn_info; this.init_cmd = init_cmd;}
- public String Key() {return key;} private final String key;
- public Db_conn_info Conn_info() {return conn_info;} private Db_conn_info conn_info;
- public GfoInvkAbleCmd Init_cmd() {return init_cmd;} private GfoInvkAbleCmd init_cmd;
-}
diff --git a/400_xowa/src/gplx/xowa/hdumps/Db_provider_mkr.java b/400_xowa/src/gplx/xowa/hdumps/Db_provider_mkr.java
deleted file mode 100644
index 65edba1e9..000000000
--- a/400_xowa/src/gplx/xowa/hdumps/Db_provider_mkr.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
-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 .
-*/
-package gplx.xowa.hdumps; import gplx.*; import gplx.xowa.*;
-import gplx.dbs.*;
-public class Db_provider_mkr {
- private final HashAdp engine_regy = HashAdp_.new_();
- public void Engines_add(Db_engine engine) {engine_regy.AddReplace(engine.Conn_info_tid(), engine);}
- public Db_provider Get(Db_provider_key provider_key) {
- Db_provider rv = Get_or_new(provider_key);
- GfoInvkAbleCmd init_cmd = provider_key.Init_cmd();
- if (init_cmd != GfoInvkAbleCmd.Null)
- GfoInvkAble_.InvkCmd_val(init_cmd.InvkAble(), init_cmd.Cmd(), rv);
- return rv;
- }
- private Db_provider Get_or_new(Db_provider_key key) {
- Db_conn_info conn_info = key.Conn_info();
- Db_engine prototype = (Db_engine)engine_regy.Fetch(conn_info.Key());
- Db_engine engine = prototype.Make_new(conn_info);
- engine.Conn_open(); // auto-open
- return new Db_provider(engine);
- }
-}
-class Mem_db_rdr implements Db_rdr {
- private int idx = -1, len;
- private Mem_db_row[] rows = new Mem_db_row[0];
- private Mem_db_rdr(Mem_db_row[] rows) {
- this.rows = rows;
- this.len = rows.length;
- }
- public boolean Move_next() {return ++idx < len;}
- public byte[] Read_bry(int i) {return (byte[])rows[idx].Get_at(i);}
- public byte[] Read_bry_by_str(int i) {return Bry_.new_utf8_((String)rows[idx].Get_at(i));}
- public String Read_str(int i) {return (String)rows[idx].Get_at(i);}
- public byte Read_byte(int i) {return Byte_.cast_(rows[idx].Get_at(i));}
- public int Read_int(int i) {return Int_.cast_(rows[idx].Get_at(i));}
- public long Read_long(int i) {return Long_.cast_(rows[idx].Get_at(i));}
- public float Read_float(int i) {return Float_.cast_(rows[idx].Get_at(i));}
- public double Read_double(int i) {return Double_.cast_(rows[idx].Get_at(i));}
- public void Close() {rows = null;}
- public static Mem_db_rdr new_by_rows(Mem_db_row[] rows) {return new Mem_db_rdr(rows);}
- public static Mem_db_rdr new_by_obj_ary(Object[][] obj_arys) {
- int obj_arys_len = obj_arys.length;
- Mem_db_row[] rows = new Mem_db_row[obj_arys_len];
- for (int i = 0; i < obj_arys_len; ++i) {
- Object[] obj_ary = obj_arys[i];
- rows[i] = new Mem_db_row(obj_ary);
- }
- return new Mem_db_rdr(rows);
- }
-}
-class Mem_db_row {
- private Object[] vals;
- public Mem_db_row(Object[] vals) {this.vals = vals;}
- public Object Get_at(int i) {return vals[i];}
-}
diff --git a/400_xowa/src/gplx/xowa/hdumps/Xoav_app.java b/400_xowa/src/gplx/xowa/hdumps/Xoav_app.java
deleted file mode 100644
index 4dca55ae7..000000000
--- a/400_xowa/src/gplx/xowa/hdumps/Xoav_app.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
-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 .
-*/
-package gplx.xowa.hdumps; import gplx.*; import gplx.xowa.*;
-import gplx.xowa.apps.fsys.*; import gplx.xowa.parsers.amps.*; import gplx.xowa.langs.cases.*; import gplx.intl.*;
-public class Xoav_app {
- public Xoav_app(Gfo_usr_dlg usr_dlg, Io_url root_dir, String plat_name) {
- this.usr_dlg = usr_dlg;
- this.fsys_mgr = new Xoa_fsys_mgr(root_dir, plat_name);
- this.wiki_mgr = new Xoav_wiki_mgr(this, fsys_mgr.Wiki_dir(), utl_case_mgr);
- this.db_mgr = new Db_provider_mkr();
- this.utl_msg_log = Gfo_msg_log.Test();
- db_mgr.Engines_add(gplx.dbs.Sqlite_engine_.New_engine());
- }
- public Xoa_fsys_mgr Fsys_mgr() {return fsys_mgr;} private Xoa_fsys_mgr fsys_mgr;
- public Xoav_wiki_mgr Wiki_mgr() {return wiki_mgr;} private final Xoav_wiki_mgr wiki_mgr;
- public Db_provider_mkr Db_mgr() {return db_mgr;} private Db_provider_mkr db_mgr;
-
- public Gfo_usr_dlg Usr_dlg() {return usr_dlg;} private Gfo_usr_dlg usr_dlg;
- public Bry_bfr_mkr Utl_bfr_mkr() {return utl_bfr_mkr;} private Bry_bfr_mkr utl_bfr_mkr = new Bry_bfr_mkr();
- public Xop_amp_mgr Utl_amp_mgr() {return utl_amp_mgr;} private Xop_amp_mgr utl_amp_mgr = new Xop_amp_mgr();
- public Xol_case_mgr Utl_case_mgr() {return utl_case_mgr;} private Xol_case_mgr utl_case_mgr = Xol_case_mgr_.Utf8();
- public Url_encoder Utl_encoder_fsys() {return utl_encoder_fsys;} private Url_encoder utl_encoder_fsys = Url_encoder.new_fsys_lnx_();
- public Gfo_msg_log Utl_msg_log() {return utl_msg_log;} private Gfo_msg_log utl_msg_log;
-}
diff --git a/400_xowa/src/gplx/xowa/hdumps/Xoav_wiki_mgr.java b/400_xowa/src/gplx/xowa/hdumps/Xoav_wiki_mgr.java
deleted file mode 100644
index 468a30a0a..000000000
--- a/400_xowa/src/gplx/xowa/hdumps/Xoav_wiki_mgr.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
-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 .
-*/
-package gplx.xowa.hdumps; import gplx.*; import gplx.xowa.*;
-import gplx.xowa.langs.cases.*;
-public class Xoav_wiki_mgr {
- private final Xoav_app app; private final OrderedHash hash = OrderedHash_.new_bry_();
- private Io_url wiki_root_dir;
- public Xoav_wiki_mgr(Xoav_app app, Io_url wiki_root_dir, Xol_case_mgr case_mgr) {this.app = app; this.wiki_root_dir = wiki_root_dir;}
- public Xowv_wiki Get_by_domain(byte[] domain) {
- Xowv_wiki rv = (Xowv_wiki)hash.Fetch(domain);
- return rv.Init_assert();
- }
- public void Load_default() {
- Io_url[] wiki_dirs = Io_mgr._.QueryDir_args(wiki_root_dir).DirOnly_().ExecAsUrlAry();
- for (Io_url wiki_dir : wiki_dirs) {
- String wiki_dir_url = wiki_dir.Raw();
- if (String_.HasAtBgn(wiki_dir_url, "#")) continue;
- Xowv_wiki wiki = new Xowv_wiki(app, wiki_dir.NameOnly(), wiki_dir);
- hash.Add(wiki.Domain_bry(), wiki);
- }
- }
-}
diff --git a/400_xowa/src/gplx/xowa/hdumps/Xogv_tab_base.java b/400_xowa/src/gplx/xowa/hdumps/Xogv_tab_base.java
deleted file mode 100644
index 16b8738d0..000000000
--- a/400_xowa/src/gplx/xowa/hdumps/Xogv_tab_base.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
-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 .
-*/
-package gplx.xowa.hdumps; import gplx.*; import gplx.xowa.*;
-import gplx.xowa.hdumps.core.*; import gplx.xowa.gui.history.*;
-public abstract class Xogv_tab_base {
- private Xog_history_stack history_stack = new Xog_history_stack();
- private Xoav_wiki_mgr wiki_mgr;
- public void Ctor(Xoav_wiki_mgr wiki_mgr) {this.wiki_mgr = wiki_mgr;}
- public Xog_history_itm Cur_itm() {return history_stack.Cur_itm();}
- public Hdump_page Go_to(byte[] page) {return Go_to(history_stack.Cur_itm().Wiki(), page, Bry_.Empty, Bry_.Empty, false, "");}
- public Hdump_page Go_to(byte[] wiki, byte[] page) {return Go_to(wiki, page, Bry_.Empty, Bry_.Empty, false, "");}
- public Hdump_page Go_to(byte[] wiki, byte[] page, byte[] anch, byte[] qarg, boolean redirect_force, String bmk_pos) {
- Xog_history_itm old_itm = this.Cur_itm();
- Xog_history_itm new_itm = new Xog_history_itm(wiki, page, anch, qarg, redirect_force, bmk_pos);
- history_stack.Add(new_itm);
- return Fetch_page_and_show(old_itm, new_itm);
- }
- public Hdump_page Go_bwd() {return Go_by_dir(Bool_.Y);}
- public Hdump_page Go_fwd() {return Go_by_dir(Bool_.N);}
- private Hdump_page Go_by_dir(boolean bwd) {
- Xog_history_itm old_itm = this.Cur_itm();
- Xog_history_itm new_itm = bwd ? history_stack.Go_bwd() : history_stack.Go_fwd();
- return Fetch_page_and_show(old_itm, new_itm);
- }
- private Hdump_page Fetch_page_and_show(Xog_history_itm old_itm, Xog_history_itm new_itm) {
- Hdump_page new_hpg = Fetch_page(new_itm.Wiki(), new_itm.Page());
- Show_page(old_itm, new_itm, new_hpg);
- return new_hpg;
- }
- private Hdump_page Fetch_page(byte[] wiki_domain, byte[] page_ttl) {
- Xowv_wiki wiki = wiki_mgr.Get_by_domain(wiki_domain);
- Hdump_page rv = new Hdump_page();
- wiki.Hdump_mgr().Load(rv, page_ttl);
- return rv;
- }
- protected abstract void Show_page(Xog_history_itm old_itm, Xog_history_itm new_itm, Hdump_page new_hpg);
-}
diff --git a/400_xowa/src/gplx/xowa/hdumps/Xowv_db_mgr.java b/400_xowa/src/gplx/xowa/hdumps/Xowv_db_mgr.java
deleted file mode 100644
index 706591be7..000000000
--- a/400_xowa/src/gplx/xowa/hdumps/Xowv_db_mgr.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
-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 .
-*/
-package gplx.xowa.hdumps; import gplx.*; import gplx.xowa.*;
-import gplx.dbs.*; import gplx.xowa.dbs.*;
-public class Xowv_db_mgr implements GfoInvkAble {
- private Io_url wiki_root_dir;
- public Xowv_db_mgr(String domain_str, Io_url wiki_root_dir) {
- this.tbl_mgr = new Xowd_db_tbl_mgr(); this.wiki_root_dir = wiki_root_dir;
- this.key__core = Xowv_db_mgr.Db_key__core__default(this, domain_str, wiki_root_dir);
- }
- public Xowd_db_tbl_mgr Tbl_mgr() {return tbl_mgr;} private Xowd_db_tbl_mgr tbl_mgr;
- private Xodb_file[] db_files; private Db_provider_key[] db_keys; private int db_keys_len;
- public Db_provider_key Key__core() {return key__core;} private Db_provider_key key__core;
- public Db_provider_key Key_by_idx(int idx) {if (!Int_.Between(idx, 0, db_keys_len)) throw Err_.new_("database does not exist: idx={0}", idx); return db_keys[idx];}
- private void Core_init(Db_provider provider) {
- db_files = tbl_mgr.Tbl__dbs_new().Select_all(provider, wiki_root_dir);
- db_keys = Db_keys_make(db_files);
- db_keys_len = db_keys.length;
- }
- public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
- if (ctx.Match(k, Invk_core_init)) Core_init((Db_provider)m.ReadObj("v"));
- else return GfoInvkAble_.Rv_unhandled;
- return this;
- } private static final String Invk_core_init = "core_init";
- private static Db_provider_key Db_key__core__default(Xowv_db_mgr db_mgr, String domain_str, Io_url wiki_root_dir) {
- Io_url core_db_url = wiki_root_dir.GenSubFil_ary(domain_str, ".000.sqlite3");
- GfoInvkAbleCmd init_cmd = GfoInvkAbleCmd.new_(db_mgr, Invk_core_init);
- return new Db_provider_key(core_db_url.Raw(), Db_conn_info_.sqlite_(core_db_url), init_cmd);
- }
- private static Db_provider_key[] Db_keys_make(Xodb_file[] ary) {
- int len = ary.length;
- Db_provider_key[] rv = new Db_provider_key[len];
- for (int i = 0; i < len; ++i) {
- Xodb_file itm = ary[i];
- Io_url itm_url = itm.Url();
- rv[i] = new Db_provider_key(itm_url.Raw(), Db_conn_info_.sqlite_(itm_url), GfoInvkAbleCmd.Null);
- }
- return rv;
- }
-}
diff --git a/400_xowa/src/gplx/xowa/hdumps/Xowv_db_mgr_tst.java b/400_xowa/src/gplx/xowa/hdumps/Xowv_db_mgr_tst.java
deleted file mode 100644
index c638314bb..000000000
--- a/400_xowa/src/gplx/xowa/hdumps/Xowv_db_mgr_tst.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
-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 .
-*/
-package gplx.xowa.hdumps; import gplx.*; import gplx.xowa.*;
-import org.junit.*; import gplx.xowa.files.*; import gplx.xowa.dbs.*;
-import gplx.xowa.hdumps.core.*; import gplx.xowa.hdumps.dbs.*; import gplx.xowa.hdumps.pages.*; import gplx.xowa.xtns.hieros.*; import gplx.xowa.xtns.gallery.*;
-public class Xowv_db_mgr_tst {
- @Before public void init() {} private Xowv_db_mgr_fxt fxt = new Xowv_db_mgr_fxt();
- @Test public void Basic() {
- fxt.Init_rdr(fxt.Make_row(0, "mem/a", 2),fxt.Make_row(0, "mem/a", 2), fxt.Make_row(0, "mem/a", 2));
-// fxt.Exec_open_core();
-// fxt.Test_dbs(fxt.Make_db(0, "mem/a", 0), fxt.Make_db(1, "mem/2", 2), fxt.Make_db("mem/3, 3"));
- }
-}
-class Xowv_db_mgr_fxt {
-// private Xoav_app app; private Xowv_wiki wiki;
- public void Init_rdr(Mem_db_row... rows) {
-// Mem_db_rdr rdr = Mem_db_rdr.new_by_rows(rows);
-// app = new Xoav_app(null, nul, null);
-// Mem_db_engine engine = new Mem_db_engine();
-// engine.Pending_rdrs_add(rdr);
-// app.Db_mgr().Engines_add(engine);
- }
- public Mem_db_row Make_row(Object... vals) {return new Mem_db_row(vals);}
- public void Exec_open_core() {
-// app.Db_mgr().Get(wiki.Db_mgr().Key__core());
- }
- public void Test_dbs(Xodb_file[] expd) {
-// Tfds.Eq(expd, wiki.Db_mgr().Files());
- }
-}
diff --git a/400_xowa/src/gplx/xowa/hdumps/Xowv_wiki.java b/400_xowa/src/gplx/xowa/hdumps/Xowv_wiki.java
deleted file mode 100644
index bab422cff..000000000
--- a/400_xowa/src/gplx/xowa/hdumps/Xowv_wiki.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
-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 .
-*/
-package gplx.xowa.hdumps; import gplx.*; import gplx.xowa.*;
-import gplx.xowa.wikis.xwikis.*; import gplx.xowa.langs.cases.*; import gplx.xowa.apps.ttls.*; import gplx.xowa.html.hzips.*;
-import gplx.xowa.dbs.tbls.*; import gplx.dbs.*;
-public class Xowv_wiki implements Xoa_ttl_parser {
- private Xoav_app app;
- public Xowv_wiki(Xoav_app app, String domain_str, Io_url wiki_root_dir) {
- this.app = app;
- this.domain_str = domain_str; this.domain_bry = Bry_.new_utf8_(domain_str);
- this.ns_mgr = Xow_ns_mgr_.default_(app.Utl_case_mgr()); // new Xow_ns_mgr(app.Utl_case_mgr()); // FIXME
- this.db_mgr = new Xowv_db_mgr(domain_str, wiki_root_dir);
- this.hdump_mgr = new Xowd_hdump_mgr(app, this);
- this.xwiki_mgr = new Xow_xwiki_mgr();
- this.hzip_mgr = new Xow_hzip_mgr(app.Usr_dlg(), this);
- }
- public byte[] Domain_bry() {return domain_bry;} private final byte[] domain_bry;
- public String Domain_str() {return domain_str;} private final String domain_str;
- public Xow_ns_mgr Ns_mgr() {return ns_mgr;} private final Xow_ns_mgr ns_mgr;
- public Xowv_db_mgr Db_mgr() {return db_mgr;} private final Xowv_db_mgr db_mgr;
- public Xowd_hdump_mgr Hdump_mgr() {return hdump_mgr;} private final Xowd_hdump_mgr hdump_mgr;
- public Xow_hzip_mgr Hzip_mgr() {return hzip_mgr;} private Xow_hzip_mgr hzip_mgr;
- public Xow_xwiki_mgr Xwiki_mgr() {return xwiki_mgr;} private Xow_xwiki_mgr xwiki_mgr;
- private boolean init_done = false;
- public Xowv_wiki Init_assert() {
- if (init_done) return this;
- init_done = true;
- Db_provider core_provider = app.Db_mgr().Get(db_mgr.Key__core());
- Xodb_xowa_ns_tbl ns_tbl = db_mgr.Tbl_mgr().Tbl__ns();
- ns_tbl.Provider_(core_provider);
- ns_tbl.Select_all(ns_mgr);
- return this;
- }
- public Xoa_ttl Ttl_parse(byte[] ttl) {return Xoa_ttl.parse(app.Utl_bfr_mkr(), app.Utl_amp_mgr(), app.Utl_case_mgr(), xwiki_mgr, ns_mgr, app.Utl_msg_log(), ttl, 0, ttl.length);}
- public Xoa_ttl Ttl_parse(int ns_id, byte[] ttl) {
- Xow_ns ns = ns_mgr.Ids_get_or_null(ns_id);
- byte[] raw = Bry_.Add(ns.Name_db_w_colon(), ttl);
- return Xoa_ttl.parse(app.Utl_bfr_mkr(), app.Utl_amp_mgr(), app.Utl_case_mgr(), xwiki_mgr, ns_mgr, app.Utl_msg_log(), raw, 0, raw.length);
- }
-}
diff --git a/400_xowa/src/gplx/xowa/hdumps/core/Hdump_page.java b/400_xowa/src/gplx/xowa/hdumps/core/Hdump_page.java
deleted file mode 100644
index 8d4e03212..000000000
--- a/400_xowa/src/gplx/xowa/hdumps/core/Hdump_page.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
-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 .
-*/
-package gplx.xowa.hdumps.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.hdumps.*;
-import gplx.xowa.pages.*; import gplx.xowa.pages.skins.*;
-public class Hdump_page {
- public int Page_id() {return page_id;} private int page_id;
- public Xoa_url Page_url() {return page_url;} private Xoa_url page_url;
- public Xoa_ttl Page_ttl() {return page_ttl;} private Xoa_ttl page_ttl;
- public int Version_id() {return version_id;} public void Version_id_(int v) {version_id = v;} private int version_id;
- public int Img_count() {return img_count;} public void Img_count_(int v) {img_count = v;} private int img_count;
- public Hdump_module_mgr Module_mgr() {return module_mgr;} private Hdump_module_mgr module_mgr = new Hdump_module_mgr();
- public byte[] Page_body() {return page_body;} public void Page_body_(byte[] v) {this.page_body = v;} private byte[] page_body;
- public byte[] Display_ttl() {return display_ttl;} public void Display_ttl_(byte[] v) {this.display_ttl = v;} private byte[] display_ttl;
- public byte[] Content_sub() {return content_sub;} public void Content_sub_(byte[] v) {this.content_sub = v;} private byte[] content_sub;
- public byte[] Sidebar_div() {return sidebar_div;} public void Sidebar_div_(byte[] v) {this.sidebar_div = v;} private byte[] sidebar_div;
- public int[] Redlink_uids() {return redlink_uids;} public void Redlink_uids_(int[] v) {redlink_uids = v;} private int[] redlink_uids;
- public Hdump_data_img__base[] Img_itms() {return img_itms;} public void Img_itms_(Hdump_data_img__base[] v) {this.img_itms = v;} private Hdump_data_img__base[] img_itms;
- public OrderedHash Gly_itms() {return gly_itms;} private OrderedHash gly_itms = OrderedHash_.new_();
- public Hdump_page Init(int page_id, Xoa_url page_url, Xoa_ttl page_ttl) {
- this.page_id = page_id; this.page_url = page_url; this.page_ttl = page_ttl;
- content_sub = sidebar_div = Bry_.Empty;
- display_ttl = null;
- img_itms = Hdump_data_img__base.Ary_empty;
- module_mgr.Clear();
- gly_itms.Clear();
- return this;
- }
- public void Init(Bry_bfr tmp_bfr, Xoa_page page) {
- page_id = page.Revision_data().Id();
- page_body = page.Hdump_data().Body();
- Xopg_html_data html_data = page.Html_data();
- gplx.xowa.html.modules.Xoh_module_mgr mod_mgr = html_data.Module_mgr();
- module_mgr.Init(mod_mgr.Itm_mathjax().Enabled(), mod_mgr.Itm_popups().Bind_hover_area(), mod_mgr.Itm_gallery().Enabled(), mod_mgr.Itm_hiero().Enabled());
- display_ttl = html_data.Display_ttl();
- content_sub = html_data.Content_sub();
- sidebar_div = Save_sidebars(tmp_bfr, page, html_data);
- }
- private static byte[] Save_sidebars(Bry_bfr tmp_bfr, Xoa_page page, Xopg_html_data html_data) {
- Xopg_xtn_skin_mgr mgr = html_data.Xtn_skin_mgr();
- int len = mgr.Count();
- boolean sidebar_exists = false;
- for (int i = 0; i < len; ++i) {
- Xopg_xtn_skin_itm itm = mgr.Get_at(i);
- if (itm.Tid() == Xopg_xtn_skin_itm_tid.Tid_sidebar) {
- sidebar_exists = true;
- itm.Write(tmp_bfr, page);
- }
- }
- return sidebar_exists ? tmp_bfr.Xto_bry_and_clear() : null;
- }
-}