mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
Refactor: Remove whitespace after final and remove @gplx.Virtual
This commit is contained in:
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.core.stores; import gplx.*; import gplx.core.*;
|
||||
import gplx.core.criterias.*; import gplx.core.gfo_ndes.*;
|
||||
import gplx.dbs.*; import gplx.dbs.qrys.*;
|
||||
@@ -87,7 +87,7 @@ public class DbMaprWtr extends DataWtr_base implements DataWtr {
|
||||
rv.conn = Db_conn_pool.Instance.Get_or_new(url);
|
||||
return rv;
|
||||
} DbMaprWtr() {}
|
||||
public static final String Key_Mgr = "DbMapr.mgr";
|
||||
public static final String Key_Mgr = "DbMapr.mgr";
|
||||
}
|
||||
class DbMaprWtrUtl {
|
||||
public static void PurgeObjTree(SrlObj root, DbMaprMgr mgr, Db_conn conn) {
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.core.stores; import gplx.*; import gplx.core.*;
|
||||
class MockDisc implements SrlObj, Gfo_invk {
|
||||
public int Id() {return id;} public MockDisc Id_(int val) {id = val; return this;} int id; public static final String id_idk = "id";
|
||||
public String Name() {return name;} public MockDisc Name_(String val) {name = val; return this;} private String name; public static final String name_idk = "name";
|
||||
public List_adp Titles() {return titles;} List_adp titles = List_adp_.New(); public static final String titles_idk = "titles";
|
||||
public static final MockDisc Instance = new MockDisc(); MockDisc() {}
|
||||
public int Id() {return id;} public MockDisc Id_(int val) {id = val; return this;} int id; public static final String id_idk = "id";
|
||||
public String Name() {return name;} public MockDisc Name_(String val) {name = val; return this;} private String name; public static final String name_idk = "name";
|
||||
public List_adp Titles() {return titles;} List_adp titles = List_adp_.New(); public static final String titles_idk = "titles";
|
||||
public static final MockDisc Instance = new MockDisc(); MockDisc() {}
|
||||
public SrlObj SrlObj_New(Object o) {return new MockDisc();}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, id_idk)) return Id();
|
||||
@@ -48,17 +48,17 @@ class MockDisc implements SrlObj, Gfo_invk {
|
||||
}
|
||||
}
|
||||
class MockTitle implements SrlObj, Gfo_invk {
|
||||
public int Id() {return id;} public MockTitle Id_(int val) {id = val; return this;} int id; public static final String id_idk = "id";
|
||||
public String Name() {return name;} public MockTitle Name_(String val) {name = val; return this;} private String name; public static final String name_idk = "name";
|
||||
public List_adp Chapters() {return chapters;} List_adp chapters = List_adp_.New(); public static final String chapters_idk = "chapters";
|
||||
public List_adp Audios() {return audios;} List_adp audios = List_adp_.New(); public static final String audios_idk = "audios";
|
||||
public List_adp Subtitles() {return subtitles;} List_adp subtitles = List_adp_.New(); public static final String subtitles_idk = "subtitles";
|
||||
public int Id() {return id;} public MockTitle Id_(int val) {id = val; return this;} int id; public static final String id_idk = "id";
|
||||
public String Name() {return name;} public MockTitle Name_(String val) {name = val; return this;} private String name; public static final String name_idk = "name";
|
||||
public List_adp Chapters() {return chapters;} List_adp chapters = List_adp_.New(); public static final String chapters_idk = "chapters";
|
||||
public List_adp Audios() {return audios;} List_adp audios = List_adp_.New(); public static final String audios_idk = "audios";
|
||||
public List_adp Subtitles() {return subtitles;} List_adp subtitles = List_adp_.New(); public static final String subtitles_idk = "subtitles";
|
||||
public MockTitle Disc_(MockDisc disc) {disc.Titles().Add(this); return this;}
|
||||
public static MockTitle new_() {
|
||||
MockTitle rv = new MockTitle();
|
||||
return rv;
|
||||
}
|
||||
public static final MockTitle Instance = new MockTitle(); MockTitle() {}
|
||||
public static final MockTitle Instance = new MockTitle(); MockTitle() {}
|
||||
public SrlObj SrlObj_New(Object o) {return new MockTitle();}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, id_idk)) return Id();
|
||||
@@ -87,10 +87,10 @@ class MockTitle implements SrlObj, Gfo_invk {
|
||||
}
|
||||
}
|
||||
class MockChapter implements SrlObj, Gfo_invk {
|
||||
public int Id() {return id;} public MockChapter Id_(int val) {id = val; return this;} int id; public static final String id_idk = "id";
|
||||
public String Name() {return name;} public MockChapter Name_(String val) {name = val; return this;} private String name; public static final String name_idk = "name";
|
||||
public int Id() {return id;} public MockChapter Id_(int val) {id = val; return this;} int id; public static final String id_idk = "id";
|
||||
public String Name() {return name;} public MockChapter Name_(String val) {name = val; return this;} private String name; public static final String name_idk = "name";
|
||||
public MockChapter Title_(MockTitle title) {title.Chapters().Add(this); return this;}
|
||||
public static final MockChapter Instance = new MockChapter(); MockChapter() {}
|
||||
public static final MockChapter Instance = new MockChapter(); MockChapter() {}
|
||||
public static MockChapter new_() {
|
||||
MockChapter rv = new MockChapter();
|
||||
return rv;
|
||||
@@ -107,10 +107,10 @@ class MockChapter implements SrlObj, Gfo_invk {
|
||||
}
|
||||
}
|
||||
class MockStream implements SrlObj, Gfo_invk {
|
||||
public int Id() {return id;} public MockStream Id_(int val) {id = val; return this;} int id; public static final String id_idk = "id";
|
||||
public String Name() {return name;} public MockStream Name_(String val) {name = val; return this;} private String name; public static final String name_idk = "name";
|
||||
public int Id() {return id;} public MockStream Id_(int val) {id = val; return this;} int id; public static final String id_idk = "id";
|
||||
public String Name() {return name;} public MockStream Name_(String val) {name = val; return this;} private String name; public static final String name_idk = "name";
|
||||
public MockStream Title_(List_adp list) {list.Add(this); return this;}
|
||||
public static final MockStream Instance = new MockStream(); MockStream() {}
|
||||
public static final MockStream Instance = new MockStream(); MockStream() {}
|
||||
public static MockStream new_() {
|
||||
MockStream rv = new MockStream();
|
||||
return rv;
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs; import gplx.*;
|
||||
import gplx.dbs.sqls.*; import gplx.dbs.sqls.itms.*;
|
||||
public class Db_attach_mgr {
|
||||
private Db_conn main_conn; private Io_url main_conn_url;
|
||||
private final Ordered_hash links_hash = Ordered_hash_.New();
|
||||
private final List_adp attach_list = List_adp_.New();
|
||||
private final Ordered_hash links_hash = Ordered_hash_.New();
|
||||
private final List_adp attach_list = List_adp_.New();
|
||||
public Db_attach_mgr() {}
|
||||
public Db_attach_mgr(Db_conn main_conn, Db_attach_itm... links_ary) {
|
||||
this.Conn_main_(main_conn);
|
||||
@@ -96,7 +96,7 @@ public class Db_attach_mgr {
|
||||
}
|
||||
public Db_stmt Test__make_stmt_and_attach(Db_qry qry, gplx.dbs.sqls.itms.Sql_from_clause from_itm) { // NOTE: tries to do attach via DOM not SQL
|
||||
attach_list.Clear();
|
||||
Sql_qry_wtr sql_wtr = main_conn.Engine().Sql_wtr();
|
||||
SqlQryWtr sql_wtr = main_conn.Engine().Sql_wtr();
|
||||
List_adp from_tbls = from_itm.Tbls;
|
||||
int from_tbls_len = from_tbls.Count();
|
||||
for (int i = 0; i < from_tbls_len; ++i) {
|
||||
@@ -109,7 +109,7 @@ public class Db_attach_mgr {
|
||||
else
|
||||
attach_list.Add(attach_itm);
|
||||
}
|
||||
attached_sql = sql_wtr.To_sql_str(qry, true);
|
||||
attached_sql = sql_wtr.ToSqlStr(qry, true);
|
||||
this.Attach();
|
||||
for (int i = 0; i < from_tbls_len; ++i) { // reverse blanking from above
|
||||
Sql_tbl_itm from_tbl = (Sql_tbl_itm)from_tbls.Get_at(i);
|
||||
|
||||
@@ -16,7 +16,7 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
package gplx.dbs; import gplx.*;
|
||||
import org.junit.*; import gplx.core.tests.*; import gplx.dbs.qrys.*;
|
||||
public class Db_attach_mgr__tst {
|
||||
private final Db_attach_mgr__fxt fxt = new Db_attach_mgr__fxt();
|
||||
private final Db_attach_mgr__fxt fxt = new Db_attach_mgr__fxt();
|
||||
@Test public void Basic() {
|
||||
Db_qry__select_cmd qry = Db_qry_.select_()
|
||||
.Cols_w_tbl_("t1", "fld_1")
|
||||
|
||||
@@ -43,7 +43,7 @@ import gplx.dbs.sys.Db_sys_mgr;
|
||||
import gplx.dbs.wkrs.SqlWkrMgr;
|
||||
|
||||
public class Db_conn {
|
||||
private final List_adp rls_list = List_adp_.New();
|
||||
private final List_adp rls_list = List_adp_.New();
|
||||
public Db_conn(Db_engine engine) {
|
||||
this.engine = engine;
|
||||
this.sys_mgr = new Db_sys_mgr(this);
|
||||
|
||||
@@ -13,7 +13,7 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs; import gplx.*;
|
||||
public class Db_conn_ {
|
||||
public static final Db_conn Noop = new Db_conn(gplx.dbs.engines.noops.Noop_engine.Instance);
|
||||
}
|
||||
package gplx.dbs; import gplx.*;
|
||||
public class Db_conn_ {
|
||||
public static final Db_conn Noop = new Db_conn(gplx.dbs.engines.noops.Noop_engine.Instance);
|
||||
}
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs; import gplx.*;
|
||||
public class Db_conn_bldr {
|
||||
private final Object thread_lock = new Object(); // LOCK:synchronized else random failures in Schema_mgr due to diff conn pointing to same db; DATE:2016-07-12
|
||||
private final Object thread_lock = new Object(); // LOCK:synchronized else random failures in Schema_mgr due to diff conn pointing to same db; DATE:2016-07-12
|
||||
private Db_conn_bldr_wkr wkr;
|
||||
public void Reg_default_sqlite() {wkr = Db_conn_bldr_wkr__sqlite.Instance; wkr.Clear_for_tests();}
|
||||
public void Reg_default_mem() {wkr = Db_conn_bldr_wkr__mem.Instance; wkr.Clear_for_tests();}
|
||||
@@ -48,5 +48,5 @@ public class Db_conn_bldr {
|
||||
if (rv == Db_conn_.Noop) throw Err_.new_wo_type("connection is null; file does not exist: file={0}", "file", url.Raw());
|
||||
return rv;
|
||||
}
|
||||
public static final Db_conn_bldr Instance = new Db_conn_bldr(); Db_conn_bldr() {}
|
||||
public static final Db_conn_bldr Instance = new Db_conn_bldr(); Db_conn_bldr() {}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs; import gplx.*;
|
||||
import gplx.dbs.engines.sqlite.*; import gplx.dbs.qrys.bats.*;
|
||||
public interface Db_conn_bldr_wkr {
|
||||
@@ -23,7 +23,7 @@ public interface Db_conn_bldr_wkr {
|
||||
}
|
||||
class Db_conn_bldr_wkr__sqlite implements Db_conn_bldr_wkr {
|
||||
public void Clear_for_tests() {}
|
||||
// public Db_batch_mgr Batch_mgr() {return batch_mgr;} private final Db_batch_mgr batch_mgr = new Db_batch_mgr();
|
||||
// public Db_batch_mgr Batch_mgr() {return batch_mgr;} private final Db_batch_mgr batch_mgr = new Db_batch_mgr();
|
||||
public boolean Exists(Io_url url) {return Io_mgr.Instance.ExistsFil(url);}
|
||||
public Db_conn Get(Io_url url) {
|
||||
if (!Io_mgr.Instance.ExistsFil(url)) return null;
|
||||
@@ -37,10 +37,10 @@ class Db_conn_bldr_wkr__sqlite implements Db_conn_bldr_wkr {
|
||||
conn.Exec_qry(Sqlite_pragma.New__page_size(4096));
|
||||
return conn;
|
||||
}
|
||||
public static final Db_conn_bldr_wkr__sqlite Instance = new Db_conn_bldr_wkr__sqlite(); Db_conn_bldr_wkr__sqlite() {}
|
||||
public static final Db_conn_bldr_wkr__sqlite Instance = new Db_conn_bldr_wkr__sqlite(); Db_conn_bldr_wkr__sqlite() {}
|
||||
}
|
||||
class Db_conn_bldr_wkr__mem implements Db_conn_bldr_wkr {
|
||||
private final Hash_adp hash = Hash_adp_.New();
|
||||
private final Hash_adp hash = Hash_adp_.New();
|
||||
public void Clear_for_tests() {hash.Clear(); Db_conn_pool.Instance.Rls_all();}
|
||||
public boolean Exists(Io_url url) {
|
||||
String io_url_str = url.Xto_api();
|
||||
@@ -59,5 +59,5 @@ class Db_conn_bldr_wkr__mem implements Db_conn_bldr_wkr {
|
||||
private Db_conn Get_or_new(Io_url url) {
|
||||
return Db_conn_pool.Instance.Get_or_new(gplx.dbs.engines.mems.Mem_conn_info.new_(url.Xto_api()));
|
||||
}
|
||||
public static final Db_conn_bldr_wkr__mem Instance = new Db_conn_bldr_wkr__mem(); Db_conn_bldr_wkr__mem() {}
|
||||
public static final Db_conn_bldr_wkr__mem Instance = new Db_conn_bldr_wkr__mem(); Db_conn_bldr_wkr__mem() {}
|
||||
}
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs; import gplx.*;
|
||||
import gplx.dbs.engines.noops.*; import gplx.dbs.engines.mems.*; import gplx.dbs.engines.sqlite.*; import gplx.dbs.engines.tdbs.*;
|
||||
import gplx.dbs.engines.mysql.*; import gplx.dbs.engines.postgres.*;
|
||||
public class Db_conn_info_ {
|
||||
public static final Db_conn_info Null = Noop_conn_info.Instance;
|
||||
public static final Db_conn_info Test = Mysql_conn_info.new_("127.0.0.1", "unit_tests", "root", "mysql7760");
|
||||
public static final Db_conn_info Null = Noop_conn_info.Instance;
|
||||
public static final Db_conn_info Test = Mysql_conn_info.new_("127.0.0.1", "unit_tests", "root", "mysql7760");
|
||||
public static Db_conn_info parse(String raw) {return Db_conn_info_pool.Instance.Parse(raw);}
|
||||
public static Db_conn_info sqlite_(Io_url url) {return Sqlite_conn_info.load_(url);}
|
||||
public static Db_conn_info tdb_(Io_url url) {return Tdb_conn_info.new_(url);}
|
||||
public static Db_conn_info mem_(String db) {return Mem_conn_info.new_(db);}
|
||||
public static final String Key_tdb = Tdb_conn_info.Tid_const;
|
||||
public static final String Key_tdb = Tdb_conn_info.Tid_const;
|
||||
public static Io_url To_url(Db_conn_info cs) {
|
||||
if (String_.Eq(cs.Key(), Sqlite_conn_info.Key_const)) return ((Sqlite_conn_info)cs).Url();
|
||||
else if (String_.Eq(cs.Key(), Mem_conn_info.Instance.Key())) return Io_url_.mem_fil_("mem/" + ((Mem_conn_info)cs).Database());
|
||||
@@ -31,7 +31,7 @@ public class Db_conn_info_ {
|
||||
}
|
||||
}
|
||||
class Db_conn_info_pool {
|
||||
private final Ordered_hash regy = Ordered_hash_.New();
|
||||
private final Ordered_hash regy = Ordered_hash_.New();
|
||||
public Db_conn_info_pool() {
|
||||
this.Add(Noop_conn_info.Instance).Add(Tdb_conn_info.Instance).Add(Mysql_conn_info.Instance).Add(Postgres_conn_info.Instance).Add(Sqlite_conn_info.Instance);
|
||||
this.Add(Mem_conn_info.Instance);
|
||||
@@ -82,5 +82,5 @@ class Db_conn_info_pool {
|
||||
Db_conn_info prototype = (Db_conn_info)regy.Get_by(cs_tid);
|
||||
return prototype.New_self(raw, hash);
|
||||
}
|
||||
public static final Db_conn_info_pool Instance = new Db_conn_info_pool();
|
||||
public static final Db_conn_info_pool Instance = new Db_conn_info_pool();
|
||||
}
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs; import gplx.*;
|
||||
public abstract class Db_conn_info__base implements Db_conn_info {
|
||||
public Db_conn_info__base(String raw, String db_api, String database) {this.raw = raw; this.db_api = db_api; this.database = database;}
|
||||
public abstract String Key();
|
||||
public String Raw() {return raw;} private final String raw;
|
||||
public String Db_api() {return db_api;} private final String db_api;
|
||||
public String Database() {return database;} protected final String database;
|
||||
public String Raw() {return raw;} private final String raw;
|
||||
public String Db_api() {return db_api;} private final String db_api;
|
||||
public String Database() {return database;} protected final String database;
|
||||
public abstract Db_conn_info New_self(String raw, Keyval_hash hash);
|
||||
|
||||
protected static String Bld_raw(String... ary) {// "a", "b" -> "a=b;"
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs; import gplx.*;
|
||||
import gplx.dbs.engines.*;
|
||||
import gplx.dbs.qrys.bats.*;
|
||||
public class Db_conn_pool { // PURPOSE: cache one connection per connection_string
|
||||
private final Ordered_hash hash = Ordered_hash_.New();
|
||||
public Db_batch_mgr Batch_mgr() {return batch_mgr;} private final Db_batch_mgr batch_mgr = new Db_batch_mgr();
|
||||
private final Ordered_hash hash = Ordered_hash_.New();
|
||||
public Db_batch_mgr Batch_mgr() {return batch_mgr;} private final Db_batch_mgr batch_mgr = new Db_batch_mgr();
|
||||
public void Del(Db_conn_info url) {hash.Del(url.Db_api());}
|
||||
public Db_conn Get_or_new(String s) {return Get_or_new(Db_conn_info_.parse(s));}
|
||||
public Db_conn Get_or_new(Db_conn_info url) {
|
||||
@@ -45,8 +45,8 @@ public class Db_conn_pool { // PURPOSE: cache one connection per connection_stri
|
||||
hash.Clear();
|
||||
}
|
||||
|
||||
private final Hash_adp prime_hash = Hash_adp_.New();
|
||||
public static final Db_conn_pool Instance = new Db_conn_pool(); Db_conn_pool() {this.Init();}
|
||||
private final Hash_adp prime_hash = Hash_adp_.New();
|
||||
public static final Db_conn_pool Instance = new Db_conn_pool(); Db_conn_pool() {this.Init();}
|
||||
public void Primes__add(Db_engine... ary) { // PUBLIC.DRD:
|
||||
for (Db_engine itm : ary)
|
||||
prime_hash.Add(itm.Tid(), itm);
|
||||
|
||||
@@ -13,16 +13,11 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs; import gplx.*;
|
||||
public interface Db_qry {
|
||||
int Tid();
|
||||
boolean Exec_is_rdr();
|
||||
String Base_table();
|
||||
String To_sql__exec(gplx.dbs.sqls.Sql_qry_wtr wtr);
|
||||
}
|
||||
class Db_qry__noop implements Db_qry {
|
||||
public int Tid() {return Db_qry_.Tid_noop;}
|
||||
public boolean Exec_is_rdr() {return false;}
|
||||
public String Base_table() {return "";}
|
||||
public String To_sql__exec(gplx.dbs.sqls.Sql_qry_wtr wtr) {return "";}
|
||||
}
|
||||
package gplx.dbs;
|
||||
import gplx.dbs.sqls.SqlQryWtr;
|
||||
public interface Db_qry {
|
||||
int Tid();
|
||||
boolean Exec_is_rdr();
|
||||
String Base_table();
|
||||
String To_sql__exec(SqlQryWtr wtr);
|
||||
}
|
||||
|
||||
@@ -13,49 +13,54 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs; import gplx.*;
|
||||
import gplx.core.criterias.*; import gplx.dbs.qrys.*; import gplx.dbs.sqls.*; import gplx.dbs.sqls.itms.*;
|
||||
public class Db_qry_ {
|
||||
public static Db_qry__select_cmd select_cols_(String tbl, Criteria crt, String... cols){return select_().From_(tbl).Where_(crt).Cols_(cols);}
|
||||
public static Db_qry__select_cmd select_val_(String tbl, String col, Criteria crt) {return select_().From_(tbl).Where_(crt).Cols_(col);}
|
||||
public static Db_qry__select_cmd select_tbl_(String tbl) {return select_().From_(tbl).Cols_all_();}
|
||||
public static Db_qry__select_cmd select_() {return new Db_qry__select_cmd();}
|
||||
public static Db_qry__select_cmd select_(String tbl, String... cols) {return new Db_qry__select_cmd().From_(tbl).Cols_(cols);}
|
||||
public static Db_qry_delete delete_(String tbl, Criteria crt) {return Db_qry_delete.new_(tbl, crt);}
|
||||
public static Db_qry_delete delete_tbl_(String tbl) {return Db_qry_delete.new_(tbl);}
|
||||
public static Db_qry_insert insert_(String tbl) {return new Db_qry_insert(tbl);}
|
||||
public static Db_qry_insert insert_common_(String tbl, Keyval... pairs) {
|
||||
Db_qry_insert cmd = new Db_qry_insert(tbl);
|
||||
for (Keyval pair : pairs)
|
||||
cmd.Val_obj(pair.Key(), pair.Val());
|
||||
return cmd;
|
||||
}
|
||||
|
||||
public static Sql_join_fld New_join__join(String trg_fld, String src_tbl, String src_fld) {return new Sql_join_fld(trg_fld, src_tbl, src_fld);}
|
||||
public static Sql_join_fld New_join__same(String tbl, String fld) {return new Sql_join_fld(fld, tbl, fld);}
|
||||
|
||||
public static Db_qry_update update_(String tbl, Criteria crt) {
|
||||
Db_qry_update update = new Db_qry_update();
|
||||
update.From_(tbl);
|
||||
update.Where_(crt);
|
||||
return update;
|
||||
}
|
||||
public static Db_qry_update update_common_(String tbl, Criteria crt, Keyval... pairs) {
|
||||
Db_qry_update cmd = new Db_qry_update();
|
||||
cmd.From_(tbl); cmd.Where_(crt);
|
||||
for (Keyval pair : pairs)
|
||||
cmd.Val_obj(pair.Key(), pair.Val());
|
||||
return cmd;
|
||||
}
|
||||
public static gplx.core.gfo_ndes.GfoNde Exec_as_nde(Db_conn conn, Db_qry qry) {return gplx.core.gfo_ndes.GfoNde_.rdr_(conn.Exec_qry_as_old_rdr(qry));}
|
||||
public static Object Exec_as_obj(Db_conn conn, Db_qry__select_cmd qry) {
|
||||
gplx.core.stores.DataRdr rdr = conn.Exec_qry_as_old_rdr(qry);
|
||||
try {
|
||||
return rdr.MoveNextPeer() ? rdr.Read(qry.Cols().Flds.Get_at(0).Fld) : null; // NOTE: need to access from flds for tdb
|
||||
} finally {rdr.Rls();}
|
||||
}
|
||||
|
||||
public static Db_qry as_(Object obj) {return obj instanceof Db_qry ? (Db_qry)obj : null;}
|
||||
public static final Db_qry Noop = new Db_qry__noop();
|
||||
public static final int Tid_insert = 0, Tid_delete = 1, Tid_update = 2, Tid_select = 3, Tid_sql = 4, Tid_select_in_tbl = 5, Tid_flush = 6, Tid_noop = 7, Tid_pragma = 8;
|
||||
}
|
||||
package gplx.dbs;
|
||||
import gplx.Keyval;
|
||||
import gplx.core.criterias.Criteria;
|
||||
import gplx.dbs.qrys.Db_qry__select_cmd;
|
||||
import gplx.dbs.qrys.Db_qry_delete;
|
||||
import gplx.dbs.qrys.Db_qry_insert;
|
||||
import gplx.dbs.qrys.Db_qry_update;
|
||||
import gplx.dbs.sqls.itms.Sql_join_fld;
|
||||
public class Db_qry_ {
|
||||
public static Db_qry__select_cmd select_cols_(String tbl, Criteria crt, String... cols){return select_().From_(tbl).Where_(crt).Cols_(cols);}
|
||||
public static Db_qry__select_cmd select_val_(String tbl, String col, Criteria crt) {return select_().From_(tbl).Where_(crt).Cols_(col);}
|
||||
public static Db_qry__select_cmd select_tbl_(String tbl) {return select_().From_(tbl).Cols_all_();}
|
||||
public static Db_qry__select_cmd select_() {return new Db_qry__select_cmd();}
|
||||
public static Db_qry__select_cmd select_(String tbl, String... cols) {return new Db_qry__select_cmd().From_(tbl).Cols_(cols);}
|
||||
public static Db_qry_delete delete_(String tbl, Criteria crt) {return Db_qry_delete.new_(tbl, crt);}
|
||||
public static Db_qry_delete delete_tbl_(String tbl) {return Db_qry_delete.new_(tbl);}
|
||||
public static Db_qry_insert insert_(String tbl) {return new Db_qry_insert(tbl);}
|
||||
public static Db_qry_insert insert_common_(String tbl, Keyval... pairs) {
|
||||
Db_qry_insert cmd = new Db_qry_insert(tbl);
|
||||
for (Keyval pair : pairs)
|
||||
cmd.Val_obj(pair.Key(), pair.Val());
|
||||
return cmd;
|
||||
}
|
||||
|
||||
public static Sql_join_fld New_join__join(String trg_fld, String src_tbl, String src_fld) {return new Sql_join_fld(trg_fld, src_tbl, src_fld);}
|
||||
public static Sql_join_fld New_join__same(String tbl, String fld) {return new Sql_join_fld(fld, tbl, fld);}
|
||||
|
||||
public static Db_qry_update update_(String tbl, Criteria crt) {
|
||||
Db_qry_update update = new Db_qry_update();
|
||||
update.From_(tbl);
|
||||
update.Where_(crt);
|
||||
return update;
|
||||
}
|
||||
public static Db_qry_update update_common_(String tbl, Criteria crt, Keyval... pairs) {
|
||||
Db_qry_update cmd = new Db_qry_update();
|
||||
cmd.From_(tbl); cmd.Where_(crt);
|
||||
for (Keyval pair : pairs)
|
||||
cmd.Val_obj(pair.Key(), pair.Val());
|
||||
return cmd;
|
||||
}
|
||||
public static gplx.core.gfo_ndes.GfoNde Exec_as_nde(Db_conn conn, Db_qry qry) {return gplx.core.gfo_ndes.GfoNde_.rdr_(conn.Exec_qry_as_old_rdr(qry));}
|
||||
public static Object Exec_as_obj(Db_conn conn, Db_qry__select_cmd qry) {
|
||||
gplx.core.stores.DataRdr rdr = conn.Exec_qry_as_old_rdr(qry);
|
||||
try {
|
||||
return rdr.MoveNextPeer() ? rdr.Read(qry.Cols().Flds.Get_at(0).Fld) : null; // NOTE: need to access from flds for tdb
|
||||
} finally {rdr.Rls();}
|
||||
}
|
||||
|
||||
public static Db_qry as_(Object obj) {return obj instanceof Db_qry ? (Db_qry)obj : null;}
|
||||
public static final int Tid_insert = 0, Tid_delete = 1, Tid_update = 2, Tid_select = 3, Tid_sql = 4, Tid_select_in_tbl = 5, Tid_flush = 6, Tid_noop = 7, Tid_pragma = 8;
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs; import gplx.*;
|
||||
import java.sql.ResultSet;
|
||||
public class Db_rdr__basic implements Db_rdr {
|
||||
@@ -24,21 +24,21 @@ public class Db_rdr__basic implements Db_rdr {
|
||||
try {return rdr.next();}
|
||||
catch (Exception e) {throw Err_.new_exc(e, "db", "move_next failed; check column casting error in SQL", "sql", sql);}
|
||||
}
|
||||
@gplx.Virtual public byte[] Read_bry(String k) {try {return (byte[])rdr.getObject(k);} catch (Exception e) {throw Err_.new_exc(e, "db", "read failed", "key", k, "type", Bry_.Cls_val_name);}}
|
||||
@gplx.Virtual public byte[] Read_bry_by_str(String k) {try {return Bry_.new_u8((String)rdr.getObject(k));} catch (Exception e) {throw Err_.new_exc(e, "db", "read failed", "key", k, "type", String_.Cls_val_name);}}
|
||||
@gplx.Virtual public void Save_bry_in_parts(Io_url url, String tbl, String fld, String crt_key, Object crt_val) {throw Err_.new_unimplemented();}
|
||||
@gplx.Virtual public String Read_str(String k) {try {return (String)rdr.getObject(k);} catch (Exception e) {throw Err_.new_exc(e, "db", "read failed", "key", k, "type", String_.Cls_val_name);}}
|
||||
@gplx.Virtual public DateAdp Read_date_by_str(String k) {return DateAdp_.parse_iso8561(Read_str(k));}
|
||||
@gplx.Virtual public int Read_int(String k) {try {return Int_.Cast(rdr.getObject(k));} catch (Exception e) {throw Err_.new_exc(e, "db", "read failed", "key", k, "type", Int_.Cls_val_name);}}
|
||||
@gplx.Virtual public long Read_long(String k) {try {return Long_.cast(rdr.getObject(k));} catch (Exception e) {throw Err_.new_exc(e, "db", "read failed", "key", k, "type", Long_.Cls_val_name);}}
|
||||
@gplx.Virtual public float Read_float(String k) {try {return Float_.cast(rdr.getObject(k));} catch (Exception e) {throw Err_.new_exc(e, "db", "read failed", "key", k, "type", Float_.Cls_val_name);}}
|
||||
@gplx.Virtual public double Read_double(String k) {try {return Double_.cast(rdr.getObject(k));} catch (Exception e) {throw Err_.new_exc(e, "db", "read failed", "key", k, "type", Double_.Cls_val_name);}}
|
||||
@gplx.Virtual public byte Read_byte(String k) {try {return Byte_.Cast(rdr.getObject(k));} catch (Exception e) {throw Err_.new_exc(e, "db", "read failed", "key", k, "type", Byte_.Cls_val_name);}}
|
||||
@gplx.Virtual public boolean Read_bool_by_byte(String k) {try {return Byte_.Cast(rdr.getObject(k)) == 1;} catch (Exception e) {throw Err_.new_exc(e, "db", "read failed", "key", k, "type", Bool_.Cls_val_name);}}
|
||||
@gplx.Virtual public int Fld_len() {try {return rdr.getMetaData().getColumnCount();} catch (Exception e) {throw Err_.new_exc(e, "db", "field count failed", "sql", sql);}}
|
||||
@gplx.Virtual public Object Read_obj(String k) {try {return rdr.getObject(k);} catch (Exception e) {throw Err_.new_exc(e, "db", "read failed", "key", k, "type", Object_.Cls_val_name);}}
|
||||
@gplx.Virtual public Object Read_at(int i) {try {return rdr.getObject(i + 1);} catch (Exception e) {throw Err_.new_exc(e, "db", "read failed", "idx", i, "type", Object_.Cls_val_name);}}
|
||||
@gplx.Virtual public void Rls() {
|
||||
public byte[] Read_bry(String k) {try {return (byte[])rdr.getObject(k);} catch (Exception e) {throw Err_.new_exc(e, "db", "read failed", "key", k, "type", Bry_.Cls_val_name);}}
|
||||
public byte[] Read_bry_by_str(String k) {try {return Bry_.new_u8((String)rdr.getObject(k));} catch (Exception e) {throw Err_.new_exc(e, "db", "read failed", "key", k, "type", String_.Cls_val_name);}}
|
||||
public void Save_bry_in_parts(Io_url url, String tbl, String fld, String crt_key, Object crt_val) {throw Err_.new_unimplemented();}
|
||||
public String Read_str(String k) {try {return (String)rdr.getObject(k);} catch (Exception e) {throw Err_.new_exc(e, "db", "read failed", "key", k, "type", String_.Cls_val_name);}}
|
||||
public DateAdp Read_date_by_str(String k) {return DateAdp_.parse_iso8561(Read_str(k));}
|
||||
public int Read_int(String k) {try {return Int_.Cast(rdr.getObject(k));} catch (Exception e) {throw Err_.new_exc(e, "db", "read failed", "key", k, "type", Int_.Cls_val_name);}}
|
||||
public long Read_long(String k) {try {return Long_.cast(rdr.getObject(k));} catch (Exception e) {throw Err_.new_exc(e, "db", "read failed", "key", k, "type", Long_.Cls_val_name);}}
|
||||
public float Read_float(String k) {try {return Float_.cast(rdr.getObject(k));} catch (Exception e) {throw Err_.new_exc(e, "db", "read failed", "key", k, "type", Float_.Cls_val_name);}}
|
||||
public double Read_double(String k) {try {return Double_.cast(rdr.getObject(k));} catch (Exception e) {throw Err_.new_exc(e, "db", "read failed", "key", k, "type", Double_.Cls_val_name);}}
|
||||
public byte Read_byte(String k) {try {return Byte_.Cast(rdr.getObject(k));} catch (Exception e) {throw Err_.new_exc(e, "db", "read failed", "key", k, "type", Byte_.Cls_val_name);}}
|
||||
public boolean Read_bool_by_byte(String k) {try {return Byte_.Cast(rdr.getObject(k)) == 1;} catch (Exception e) {throw Err_.new_exc(e, "db", "read failed", "key", k, "type", Bool_.Cls_val_name);}}
|
||||
public int Fld_len() {try {return rdr.getMetaData().getColumnCount();} catch (Exception e) {throw Err_.new_exc(e, "db", "field count failed", "sql", sql);}}
|
||||
public Object Read_obj(String k) {try {return rdr.getObject(k);} catch (Exception e) {throw Err_.new_exc(e, "db", "read failed", "key", k, "type", Object_.Cls_val_name);}}
|
||||
public Object Read_at(int i) {try {return rdr.getObject(i + 1);} catch (Exception e) {throw Err_.new_exc(e, "db", "read failed", "idx", i, "type", Object_.Cls_val_name);}}
|
||||
public void Rls() {
|
||||
try {rdr.close();}
|
||||
catch (Exception e) {throw Err_.new_exc(e, "db", "close failed");}
|
||||
if (stmt != null) {
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs; import gplx.*;
|
||||
import gplx.core.criterias.*;
|
||||
interface Db_sql_qry {
|
||||
@@ -20,7 +20,7 @@ interface Db_sql_qry {
|
||||
}
|
||||
class Db_sql_qry__select {
|
||||
public Db_sql_qry__select(String from) {this.from = from;}
|
||||
public String From() {return from;} private final String from;
|
||||
public String From() {return from;} private final String from;
|
||||
public Db_sql_col[] Select() {return select;} private Db_sql_col[] select;
|
||||
// public Criteria Where() {return where;} private Criteria where;
|
||||
// public Db_sql_col[] Group_bys() {return group_bys;} private Db_sql_col[] group_bys;
|
||||
@@ -49,7 +49,7 @@ class Db_sql_col_ {
|
||||
public static Db_sql_col[] Ary(Db_sql_col... v) {return v;}
|
||||
}
|
||||
class Db_sql_col_bldr {
|
||||
private final List_adp tmp_list = List_adp_.New();
|
||||
private final List_adp tmp_list = List_adp_.New();
|
||||
public Db_sql_col[] new_fld_many(String[] ary) {
|
||||
tmp_list.Clear();
|
||||
int ord = -1;
|
||||
@@ -61,16 +61,16 @@ class Db_sql_col_bldr {
|
||||
}
|
||||
return (Db_sql_col[])tmp_list.To_ary_and_clear(Db_sql_col.class);
|
||||
}
|
||||
public static final Db_sql_col_bldr Instance = new Db_sql_col_bldr(); Db_sql_col_bldr() {}
|
||||
public static final Db_sql_col_bldr Instance = new Db_sql_col_bldr(); Db_sql_col_bldr() {}
|
||||
}
|
||||
class Db_sql_col__name {
|
||||
public Db_sql_col__name(int ord, String key) {this.ord = ord; this.key = key;}
|
||||
public int Ord() {return ord;} private final int ord;
|
||||
public String Key() {return key;} private final String key;
|
||||
public int Ord() {return ord;} private final int ord;
|
||||
public String Key() {return key;} private final String key;
|
||||
}
|
||||
class Db_sql_col__all implements Db_sql_col {
|
||||
public Db_sql_col__all(int ord, String tbl) {this.ord = ord; this.tbl = tbl;}
|
||||
public int Ord() {return ord;} private final int ord;
|
||||
public String Tbl() {return tbl;} private final String tbl;
|
||||
public int Ord() {return ord;} private final int ord;
|
||||
public String Tbl() {return tbl;} private final String tbl;
|
||||
public String Alias() {return "*";}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs; import gplx.*;
|
||||
import gplx.dbs.qrys.*;
|
||||
public class Db_stmt_ {
|
||||
public static final Db_stmt Null = new Db_stmt_sql();
|
||||
public static final Db_stmt Null = new Db_stmt_sql();
|
||||
public static Db_stmt new_insert_(Db_conn conn, String tbl, String... flds) {
|
||||
Db_qry qry = Db_qry_insert.new_(tbl, flds);
|
||||
return conn.Stmt_new(qry);
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs; import gplx.*;
|
||||
import gplx.dbs.metas.*;
|
||||
public class Dbmeta_fld_itm {
|
||||
@@ -20,8 +20,8 @@ public class Dbmeta_fld_itm {
|
||||
this.name = name; this.type = type;
|
||||
this.primary = false; this.autonum = false; this.default_val = Default_value_null;
|
||||
}
|
||||
public String Name() {return name;} private final String name;
|
||||
public Dbmeta_fld_tid Type() {return type;} private final Dbmeta_fld_tid type;
|
||||
public String Name() {return name;} private final String name;
|
||||
public Dbmeta_fld_tid Type() {return type;} private final Dbmeta_fld_tid type;
|
||||
public int Nullable_tid() {return nullable_tid;} public Dbmeta_fld_itm Nullable_tid_(int v) {nullable_tid = v; return this;} private int nullable_tid;
|
||||
public Dbmeta_fld_itm Nullable_y_() {return Nullable_tid_(Nullable_null);}
|
||||
public boolean Primary() {return primary;} public Dbmeta_fld_itm Primary_y_() {primary = true; return this;} private boolean primary; public Dbmeta_fld_itm Primary_n_() {primary = false; return this;}
|
||||
@@ -37,10 +37,10 @@ public class Dbmeta_fld_itm {
|
||||
}
|
||||
|
||||
public static final int Nullable_unknown = 0, Nullable_null = 1, Nullable_not_null = 2;
|
||||
public static final Object Default_value_null = null;
|
||||
public static final Object Default_value_null = null;
|
||||
public static final String Key_null = null;
|
||||
public static final String[] Str_ary_empty = String_.Ary_empty;
|
||||
public static final Dbmeta_fld_itm[] Ary_empty = new Dbmeta_fld_itm[0];
|
||||
public static final String[] Str_ary_empty = String_.Ary_empty;
|
||||
public static final Dbmeta_fld_itm[] Ary_empty = new Dbmeta_fld_itm[0];
|
||||
|
||||
public static Dbmeta_fld_itm new_bool(String name) {return new Dbmeta_fld_itm(name, Dbmeta_fld_tid.Itm__bool);}
|
||||
public static Dbmeta_fld_itm new_byte(String name) {return new Dbmeta_fld_itm(name, Dbmeta_fld_tid.Itm__byte);}
|
||||
|
||||
@@ -15,7 +15,7 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs; import gplx.*;
|
||||
public class Dbmeta_fld_list {
|
||||
private final Ordered_hash flds = Ordered_hash_.New();
|
||||
private final Ordered_hash flds = Ordered_hash_.New();
|
||||
public void Clear() {flds.Clear(); str_ary = null; fld_ary = null;}
|
||||
public int Len() {return flds.Len();}
|
||||
public boolean Has(String key) {return flds.Has(key);}
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs; import gplx.*;
|
||||
import gplx.dbs.engines.sqlite.*; // for Tid_sqlite; note that Tid_sqlite is not used, and only exists for doc purposes
|
||||
public class Dbmeta_fld_tid {
|
||||
public Dbmeta_fld_tid(int tid_ansi, int tid_sqlite, byte[] name, int len_1, int len_2) {
|
||||
this.tid_ansi = tid_ansi; this.tid_sqlite = tid_sqlite; this.name = name; this.len_1 = len_1; this.len_2 = len_2;
|
||||
}
|
||||
public int Tid_ansi() {return tid_ansi;} private final int tid_ansi;
|
||||
public int Tid_sqlite() {return tid_sqlite;} private final int tid_sqlite;
|
||||
public byte[] Name() {return name;} private final byte[] name;
|
||||
public int Len_1() {return len_1;} private final int len_1;
|
||||
public int Len_2() {return len_2;} private final int len_2;
|
||||
public int Tid_ansi() {return tid_ansi;} private final int tid_ansi;
|
||||
public int Tid_sqlite() {return tid_sqlite;} private final int tid_sqlite;
|
||||
public byte[] Name() {return name;} private final byte[] name;
|
||||
public int Len_1() {return len_1;} private final int len_1;
|
||||
public int Len_2() {return len_2;} private final int len_2;
|
||||
public boolean Eq(Dbmeta_fld_tid comp) {
|
||||
return tid_ansi == comp.tid_ansi
|
||||
&& tid_sqlite == comp.tid_sqlite
|
||||
@@ -33,7 +33,7 @@ public class Dbmeta_fld_tid {
|
||||
}
|
||||
|
||||
public static final int Tid__bool = 0, Tid__byte = 1, Tid__short = 2, Tid__int = 3, Tid__long = 4, Tid__float = 5, Tid__double = 6, Tid__str = 7, Tid__text = 8, Tid__bry = 9, Tid__decimal = 10, Tid__date = 11;
|
||||
public static final Dbmeta_fld_tid
|
||||
public static final Dbmeta_fld_tid
|
||||
Itm__byte = new Dbmeta_fld_tid(Dbmeta_fld_tid.Tid__byte , Sqlite_tid.Tid_int , Bry_.new_a7("tinyint") , -1, -1)
|
||||
, Itm__short = new Dbmeta_fld_tid(Dbmeta_fld_tid.Tid__short , Sqlite_tid.Tid_int , Bry_.new_a7("smallint") , -1, -1)
|
||||
, Itm__int = new Dbmeta_fld_tid(Dbmeta_fld_tid.Tid__int , Sqlite_tid.Tid_int , Bry_.new_a7("integer") , -1, -1)
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs; import gplx.*;
|
||||
import gplx.dbs.metas.*; import gplx.dbs.sqls.*; import gplx.dbs.sqls.wtrs.*;
|
||||
import gplx.dbs.metas.*; import gplx.dbs.sqls.*;
|
||||
public class Dbmeta_idx_itm {
|
||||
public Dbmeta_idx_itm(boolean unique, String tbl, String name, Dbmeta_idx_fld[] flds) {
|
||||
this.tbl = tbl; this.name = name; this.unique = unique; this.Flds = flds;
|
||||
}
|
||||
public String Tbl() {return tbl;} private final String tbl;
|
||||
public String Name() {return name;} private final String name;
|
||||
public boolean Unique() {return unique;} private final boolean unique;
|
||||
public final Dbmeta_idx_fld[] Flds;
|
||||
public String To_sql_create(Sql_qry_wtr sql_wtr) {return sql_wtr.Schema_wtr().Bld_create_idx(this);}
|
||||
public String Tbl() {return tbl;} private final String tbl;
|
||||
public String Name() {return name;} private final String name;
|
||||
public boolean Unique() {return unique;} private final boolean unique;
|
||||
public final Dbmeta_idx_fld[] Flds;
|
||||
public String To_sql_create(SqlQryWtr sql_wtr) {return sql_wtr.Schema_wtr().Bld_create_idx(this);}
|
||||
public boolean Eq(Dbmeta_idx_itm comp) {
|
||||
return String_.Eq(name, comp.name)
|
||||
&& unique == comp.unique
|
||||
@@ -39,7 +39,7 @@ public class Dbmeta_idx_itm {
|
||||
public static Dbmeta_idx_itm new_unique_by_tbl_wo_null (String tbl, String name, String... flds) {return new Dbmeta_idx_itm(Bool_.Y, tbl, Bld_idx_name(tbl, name), To_fld_ary(flds));}
|
||||
public static Dbmeta_idx_itm new_normal_by_tbl_wo_null (String tbl, String name, String... flds) {return new Dbmeta_idx_itm(Bool_.N, tbl, Bld_idx_name(tbl, name), To_fld_ary(flds));}
|
||||
public static String Bld_idx_name(String tbl, String suffix) {return String_.Concat(tbl, "__", suffix);}
|
||||
public static final Dbmeta_idx_itm[] Ary_empty = new Dbmeta_idx_itm[0];
|
||||
public static final Dbmeta_idx_itm[] Ary_empty = new Dbmeta_idx_itm[0];
|
||||
public static Dbmeta_idx_fld[] To_fld_ary(String[] ary) {
|
||||
int len = ary.length;
|
||||
Dbmeta_idx_fld[] rv = new Dbmeta_idx_fld[len];
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs; import gplx.*;
|
||||
import gplx.dbs.metas.*; import gplx.dbs.sqls.*; import gplx.dbs.sqls.wtrs.*;
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs;
|
||||
import gplx.dbs.metas.*; import gplx.dbs.sqls.*;
|
||||
public class Dbmeta_tbl_itm {
|
||||
public String Name() {return name;} private String name;
|
||||
public Dbmeta_idx_mgr Idxs() {return idxs;} private final Dbmeta_idx_mgr idxs = new Dbmeta_idx_mgr();
|
||||
public Dbmeta_fld_mgr Flds() {return flds;} private final Dbmeta_fld_mgr flds = new Dbmeta_fld_mgr();
|
||||
public String To_sql_create(Sql_qry_wtr sql_wtr) {return sql_wtr.Schema_wtr().Bld_create_tbl(this);}
|
||||
public String To_sql_create(SqlQryWtr sql_wtr) {return sql_wtr.Schema_wtr().Bld_create_tbl(this);}
|
||||
|
||||
public static Dbmeta_tbl_itm New(String name, Dbmeta_fld_list flds, Dbmeta_idx_itm... idxs) {return New(name, flds.To_fld_ary(), idxs);}
|
||||
public static Dbmeta_tbl_itm New(String name, Dbmeta_fld_itm... flds) {return New(name, flds, Dbmeta_idx_itm.Ary_empty);}
|
||||
|
||||
@@ -13,14 +13,14 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.conn_props; import gplx.*; import gplx.dbs.*;
|
||||
public class Db_conn_props_mgr {
|
||||
private final Ordered_hash hash = Ordered_hash_.New();
|
||||
public boolean Has(String key) {return hash.Has(key);}
|
||||
public boolean Match(String key, String expd_val) {
|
||||
String actl_val = (String)hash.Get_by(key);
|
||||
return actl_val == null ? false : String_.Eq(expd_val,actl_val);
|
||||
}
|
||||
public void Add(String key, String val) {hash.Add(key, val);}
|
||||
public void Del(String key) {hash.Del(key);}
|
||||
}
|
||||
package gplx.dbs.conn_props; import gplx.*; import gplx.dbs.*;
|
||||
public class Db_conn_props_mgr {
|
||||
private final Ordered_hash hash = Ordered_hash_.New();
|
||||
public boolean Has(String key) {return hash.Has(key);}
|
||||
public boolean Match(String key, String expd_val) {
|
||||
String actl_val = (String)hash.Get_by(key);
|
||||
return actl_val == null ? false : String_.Eq(expd_val,actl_val);
|
||||
}
|
||||
public void Add(String key, String val) {hash.Add(key, val);}
|
||||
public void Del(String key) {hash.Del(key);}
|
||||
}
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.diffs; import gplx.*; import gplx.dbs.*;
|
||||
import gplx.dbs.diffs.itms.*;
|
||||
import gplx.dbs.diffs.builds.*;
|
||||
public class Gdif_core {
|
||||
private final Db_conn conn;
|
||||
private final Gdif_job_tbl job_tbl;
|
||||
private final Gdif_cmd_tbl cmd_tbl;
|
||||
private final Gdif_txn_tbl txn_tbl;
|
||||
private final Db_conn conn;
|
||||
private final Gdif_job_tbl job_tbl;
|
||||
private final Gdif_cmd_tbl cmd_tbl;
|
||||
private final Gdif_txn_tbl txn_tbl;
|
||||
public Gdif_core(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
this.db = new Gdif_db(conn);
|
||||
@@ -28,7 +28,7 @@ public class Gdif_core {
|
||||
this.cmd_tbl = db.Cmd_tbl();
|
||||
this.txn_tbl = db.Txn_tbl();
|
||||
}
|
||||
public Gdif_db Db() {return db;} private final Gdif_db db;
|
||||
public Gdif_db Db() {return db;} private final Gdif_db db;
|
||||
public Gdif_job_itm New_job(String name, String made_by) {
|
||||
int job_id = conn.Sys_mgr().Autonum_next(job_tbl.Tbl_name(), job_tbl.Fld_job_id());
|
||||
return job_tbl.Insert(job_id, name, made_by, Datetime_now.Get().XtoUtc(), "");
|
||||
|
||||
@@ -17,7 +17,7 @@ package gplx.dbs.diffs.builds; import gplx.*; import gplx.dbs.*; import gplx.dbs
|
||||
import org.junit.*;
|
||||
import gplx.dbs.*; import gplx.dbs.metas.*; import gplx.dbs.engines.mems.*;
|
||||
public class Gfdb_diff_bldr_tst {
|
||||
private final Gfdb_diff_bldr_fxt fxt = new Gfdb_diff_bldr_fxt();
|
||||
private final Gfdb_diff_bldr_fxt fxt = new Gfdb_diff_bldr_fxt();
|
||||
@Before public void init() {fxt.Clear();}
|
||||
@Test public void Same() {
|
||||
fxt.Init__tbl__old(Object_.Ary(1, "A") , Object_.Ary(2, "B"));
|
||||
@@ -54,13 +54,13 @@ public class Gfdb_diff_bldr_tst {
|
||||
}
|
||||
}
|
||||
class Gfdb_diff_bldr_fxt {
|
||||
private final Gfdb_diff_bldr bldr = new Gfdb_diff_bldr();
|
||||
private final Db_conn old_conn, new_conn;
|
||||
private final Gfdb_diff_tbl tbl;
|
||||
private final Gfdb_diff_wkr__test wkr = new Gfdb_diff_wkr__test();
|
||||
private final Dbmeta_fld_itm[] flds_ary;
|
||||
private final String tbl_name = "tbl";
|
||||
private final Gdif_bldr_ctx ctx = new Gdif_bldr_ctx();
|
||||
private final Gfdb_diff_bldr bldr = new Gfdb_diff_bldr();
|
||||
private final Db_conn old_conn, new_conn;
|
||||
private final Gfdb_diff_tbl tbl;
|
||||
private final Gfdb_diff_wkr__test wkr = new Gfdb_diff_wkr__test();
|
||||
private final Dbmeta_fld_itm[] flds_ary;
|
||||
private final String tbl_name = "tbl";
|
||||
private final Gdif_bldr_ctx ctx = new Gdif_bldr_ctx();
|
||||
public Gfdb_diff_bldr_fxt() {
|
||||
old_conn = Db_conn_utl.Conn__new("old_db");
|
||||
new_conn = Db_conn_utl.Conn__new("new_db");
|
||||
@@ -81,8 +81,8 @@ class Gfdb_diff_bldr_fxt {
|
||||
}
|
||||
}
|
||||
class Gfdb_diff_wkr__test implements Gfdb_diff_wkr {
|
||||
private final List_adp list = List_adp_.New();
|
||||
private final Bry_bfr bfr = Bry_bfr_.New();
|
||||
private final List_adp list = List_adp_.New();
|
||||
private final Bry_bfr bfr = Bry_bfr_.New();
|
||||
private Db_rdr old_rdr, new_rdr;
|
||||
public void Init_rdrs(Gdif_bldr_ctx ctx, Gfdb_diff_tbl tbl, Db_rdr old_rdr, Db_rdr new_rdr) {
|
||||
this.old_rdr = old_rdr; this.new_rdr = new_rdr;
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.diffs.cmds; import gplx.*; import gplx.dbs.*; import gplx.dbs.diffs.*;
|
||||
import gplx.core.srls.*; import gplx.core.brys.fmtrs.*;
|
||||
import gplx.dbs.metas.*;
|
||||
@@ -77,12 +77,12 @@ class Gfo_srl_mgr_rdr__db {
|
||||
}
|
||||
class Gfdb_diff_cmd__idx__delete {
|
||||
public Gfdb_diff_cmd__idx__delete(Dbmeta_idx_itm old) {this.Old = old;}
|
||||
public final Dbmeta_idx_itm Old;
|
||||
public final Dbmeta_idx_itm Old;
|
||||
}
|
||||
class Gfdb_diff_cmd__idx__modify {
|
||||
public Gfdb_diff_cmd__idx__modify(Dbmeta_idx_itm old, Dbmeta_idx_itm cur) {this.Old = old; this.Cur = cur;}
|
||||
public final Dbmeta_idx_itm Old;
|
||||
public final Dbmeta_idx_itm Cur;
|
||||
public final Dbmeta_idx_itm Old;
|
||||
public final Dbmeta_idx_itm Cur;
|
||||
}
|
||||
class Gfdb_diff_txn {
|
||||
public int Id = 0;
|
||||
@@ -123,20 +123,20 @@ class Gfdb_diff_cmd__fld__create {
|
||||
}
|
||||
class Gfdb_diff_cmd__fld__delete {
|
||||
public Gfdb_diff_cmd__fld__delete(Dbmeta_fld_itm old) {this.Old = old;}
|
||||
public final Dbmeta_fld_itm Old;
|
||||
public final Dbmeta_fld_itm Old;
|
||||
}
|
||||
class Gfdb_diff_cmd__fld__modify {
|
||||
public Gfdb_diff_cmd__fld__modify(Dbmeta_fld_itm old, Dbmeta_fld_itm cur) {this.Old = old; this.Cur = cur;}
|
||||
public final Dbmeta_fld_itm Old;
|
||||
public final Dbmeta_fld_itm Cur;
|
||||
public final Dbmeta_fld_itm Old;
|
||||
public final Dbmeta_fld_itm Cur;
|
||||
}
|
||||
class Gfdb_diff_cmd__tbl__create {
|
||||
public Gfdb_diff_cmd__tbl__create(Dbmeta_tbl_itm cur) {this.Cur = cur;}
|
||||
public final Dbmeta_tbl_itm Cur;
|
||||
public final Dbmeta_tbl_itm Cur;
|
||||
}
|
||||
class Gfdb_diff_cmd__tbl__delete {
|
||||
public Gfdb_diff_cmd__tbl__delete(Dbmeta_tbl_itm old) {this.Old = old;}
|
||||
public final Dbmeta_tbl_itm Old;
|
||||
public final Dbmeta_tbl_itm Old;
|
||||
}
|
||||
class Gfdb_diff_cmd_bldr {
|
||||
public void Chk_tbls(List_adp rv, Dbmeta_tbl_mgr old_tbls, Dbmeta_tbl_mgr cur_tbls) {
|
||||
@@ -232,8 +232,8 @@ class Gfdb_diff_cmd__insert {
|
||||
}
|
||||
}
|
||||
class Gfdb_diff_cmd_sql_bldr {
|
||||
private final Bry_fmtr fmtr = Bry_fmtr.new_();
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr_.New();
|
||||
private final Bry_fmtr fmtr = Bry_fmtr.new_();
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr_.New();
|
||||
public void Bld_insert(Bry_bfr bfr, String tbl_name, String[] keys, String[] vals, int rng_bgn, int rng_end) {
|
||||
fmtr.Fmt_(Insert__fmt).Keys_(Insert__keys);
|
||||
fmtr.Bld_bfr_many(bfr, tbl_name, Bld_flds(tmp_bfr, ", ", "d.", keys, vals), Bld_join(keys), rng_bgn, rng_end);
|
||||
@@ -271,8 +271,8 @@ class Gfdb_diff_cmd_sql_bldr {
|
||||
}
|
||||
return tmp_bfr.To_str_and_clear();
|
||||
}
|
||||
private static final String[] Insert__keys = String_.Ary("tbl", "flds", "join", "rng_bgn", "rng_end");
|
||||
private static final String Insert__fmt = String_.Concat_lines_nl_skip_last
|
||||
private static final String[] Insert__keys = String_.Ary("tbl", "flds", "join", "rng_bgn", "rng_end");
|
||||
private static final String Insert__fmt = String_.Concat_lines_nl_skip_last
|
||||
( "INSERT INTO db_curr.~{tbl}"
|
||||
, "SELECT ~{flds}"
|
||||
, "FROM db_temp.~{tbl}_pkey k"
|
||||
@@ -280,8 +280,8 @@ class Gfdb_diff_cmd_sql_bldr {
|
||||
, "WHERE k.diff_type = 1"
|
||||
, "AND k.diff_uid BETWEEN ~{rng_bgn} AND ~{rng_end};"
|
||||
);
|
||||
private static final String[] Update__keys = String_.Ary("tbl", "flds", "join", "rng_bgn", "rng_end");
|
||||
private static final String Update__fmt = String_.Concat_lines_nl_skip_last
|
||||
private static final String[] Update__keys = String_.Ary("tbl", "flds", "join", "rng_bgn", "rng_end");
|
||||
private static final String Update__fmt = String_.Concat_lines_nl_skip_last
|
||||
( "REPLACE INTO db_curr.~{tbl}"
|
||||
, "SELECT ~{flds}"
|
||||
, "FROM db_temp.~{tbl}_pkey k"
|
||||
@@ -289,8 +289,8 @@ class Gfdb_diff_cmd_sql_bldr {
|
||||
, "WHERE k.diff_type = 2"
|
||||
, "AND k.diff_uid BETWEEN ~{rng_bgn} AND ~{rng_end};"
|
||||
);
|
||||
private static final String[] Delete__keys = String_.Ary("tbl", "pkey_where", "pkey_select", "join", "rng_bgn", "rng_end");
|
||||
private static final String Delete__fmt = String_.Concat_lines_nl_skip_last
|
||||
private static final String[] Delete__keys = String_.Ary("tbl", "pkey_where", "pkey_select", "join", "rng_bgn", "rng_end");
|
||||
private static final String Delete__fmt = String_.Concat_lines_nl_skip_last
|
||||
( "DELETE db_curr.~{tbl}"
|
||||
, "WHERE ~{pkey_where} IN"
|
||||
, "( SELECT ~{pkey_select}"
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.diffs.cmds; import gplx.*; import gplx.dbs.*; import gplx.dbs.diffs.*;
|
||||
import gplx.core.srls.*; import gplx.dbs.metas.*;
|
||||
|
||||
@@ -65,7 +65,7 @@ class Gfdb_diff_cmd__idx__fld implements Gfo_srl_itm {
|
||||
rdr.Itm_end();
|
||||
}
|
||||
|
||||
public static final Gfdb_diff_cmd__idx__fld Instance = new Gfdb_diff_cmd__idx__fld();
|
||||
public static final Gfdb_diff_cmd__idx__fld Instance = new Gfdb_diff_cmd__idx__fld();
|
||||
}
|
||||
// class Gfdb_diff_cmd__tbl__fld : Gfo_srl_itm {
|
||||
// public Gfdb_diff_cmd__tbl__fld(Dbmeta_fld_itm cur) {this.cur = cur;}
|
||||
@@ -111,5 +111,5 @@ class Gfdb_diff_cmd__idx__fld implements Gfo_srl_itm {
|
||||
//// Dbmeta_fld_tid tid = tbl.Flds().Get_by(name).Type();
|
||||
// }
|
||||
//
|
||||
// public static final Gfdb_diff_cmd__tbl__fld Instance = new Gfdb_diff_cmd__tbl__fld();
|
||||
// public static final Gfdb_diff_cmd__tbl__fld Instance = new Gfdb_diff_cmd__tbl__fld();
|
||||
// }
|
||||
|
||||
@@ -17,7 +17,7 @@ package gplx.dbs.diffs.cmds; import gplx.*; import gplx.dbs.*; import gplx.dbs.d
|
||||
import org.junit.*;
|
||||
import gplx.dbs.*; import gplx.dbs.engines.mems.*;
|
||||
public class Gfdb_diff_cmd_sql_bldr_tst {
|
||||
private final Gfdb_diff_cmd_sql_bldr_fxt fxt = new Gfdb_diff_cmd_sql_bldr_fxt();
|
||||
private final Gfdb_diff_cmd_sql_bldr_fxt fxt = new Gfdb_diff_cmd_sql_bldr_fxt();
|
||||
@Test public void Insert() {
|
||||
fxt.Test__insert("tbl1", String_.Ary("key1", "key2"), String_.Ary("fld1", "fld2"), 0, 99, String_.Concat_lines_nl_skip_last
|
||||
( "INSERT INTO db_curr.tbl1"
|
||||
@@ -53,7 +53,7 @@ public class Gfdb_diff_cmd_sql_bldr_tst {
|
||||
}
|
||||
class Gfdb_diff_cmd_sql_bldr_fxt {
|
||||
private Gfdb_diff_cmd_sql_bldr bldr = new Gfdb_diff_cmd_sql_bldr();
|
||||
private final Bry_bfr bfr = Bry_bfr_.New();
|
||||
private final Bry_bfr bfr = Bry_bfr_.New();
|
||||
public void Test__insert(String tbl_name, String[] keys, String[] flds, int rng_bgn, int rng_end, String expd) {
|
||||
bldr.Bld_insert(bfr, tbl_name, keys, flds, 0, 99);
|
||||
Tfds.Eq_str_lines(expd, bfr.To_str_and_clear());
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.diffs.itms; import gplx.*; import gplx.dbs.*; import gplx.dbs.diffs.*;
|
||||
public class Gdif_cmd_tbl implements Rls_able {
|
||||
private String tbl_name = "gdif_cmd";
|
||||
private String fld_grp_id, fld_cmd_id, fld_tid, fld_data;
|
||||
private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private final Db_conn conn; private Db_stmt stmt_insert;
|
||||
private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private final Db_conn conn; private Db_stmt stmt_insert;
|
||||
public Gdif_cmd_tbl(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
fld_grp_id = flds.Add_int("grp_id"); fld_cmd_id = flds.Add_int("cmd_id"); fld_tid = flds.Add_int("tid"); fld_data = flds.Add_text("data");
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.diffs.itms; import gplx.*; import gplx.dbs.*; import gplx.dbs.diffs.*;
|
||||
public class Gdif_job_tbl implements Rls_able {
|
||||
private String tbl_name = "gdif_job";
|
||||
private String fld_job_id, fld_name, fld_made_by, fld_made_on, fld_data;
|
||||
private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private final Db_conn conn; private Db_stmt stmt_insert;
|
||||
private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private final Db_conn conn; private Db_stmt stmt_insert;
|
||||
public Gdif_job_tbl(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
fld_job_id = flds.Add_int_pkey("job_id"); fld_name = flds.Add_str("name", 255); fld_made_by = flds.Add_str("made_by", 255); fld_made_on = flds.Add_date("made_on"); fld_data = flds.Add_text("data");
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.diffs.itms; import gplx.*; import gplx.dbs.*; import gplx.dbs.diffs.*;
|
||||
public class Gdif_txn_tbl implements Rls_able {
|
||||
private String tbl_name = "gdif_txn";
|
||||
private String fld_job_id, fld_txn_id, fld_cmd_id, fld_owner_txn;
|
||||
private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private final Db_conn conn; private Db_stmt stmt_insert;
|
||||
private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private final Db_conn conn; private Db_stmt stmt_insert;
|
||||
public Gdif_txn_tbl(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
fld_job_id = flds.Add_int("job_id"); fld_txn_id = flds.Add_int("txn_id"); fld_cmd_id = flds.Add_int("cmd_id"); fld_owner_txn = flds.Add_int("owner_txn");
|
||||
|
||||
@@ -29,7 +29,7 @@ import gplx.dbs.Dbmeta_tbl_itm;
|
||||
import gplx.dbs.conn_props.Db_conn_props_mgr;
|
||||
import gplx.dbs.metas.Dbmeta_tbl_mgr;
|
||||
import gplx.dbs.qrys.bats.Db_batch_mgr;
|
||||
import gplx.dbs.sqls.Sql_qry_wtr;
|
||||
import gplx.dbs.sqls.SqlQryWtr;
|
||||
import gplx.dbs.wkrs.SqlWkrMgr;
|
||||
|
||||
public interface Db_engine {
|
||||
@@ -37,7 +37,7 @@ public interface Db_engine {
|
||||
Db_conn_info Conn_info();
|
||||
Db_conn_props_mgr Props();
|
||||
Db_batch_mgr Batch_mgr();
|
||||
Sql_qry_wtr Sql_wtr();
|
||||
SqlQryWtr Sql_wtr();
|
||||
void CtorConn(SqlWkrMgr wkrMgr);
|
||||
Db_engine New_clone(Db_conn_info conn_info);
|
||||
void Conn_open();
|
||||
|
||||
@@ -34,7 +34,7 @@ import gplx.dbs.metas.Dbmeta_tbl_mgr;
|
||||
import gplx.dbs.qrys.Db_qry_sql;
|
||||
import gplx.dbs.qrys.Db_stmt_cmd;
|
||||
import gplx.dbs.qrys.bats.Db_batch_mgr;
|
||||
import gplx.dbs.sqls.Sql_qry_wtr;
|
||||
import gplx.dbs.sqls.SqlQryWtr;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
@@ -45,9 +45,9 @@ public abstract class Db_engine_sql_base implements Db_engine {
|
||||
@gplx.Internal protected void Ctor(Db_conn_info conn_info) {this.conn_info = conn_info;}
|
||||
public abstract String Tid();
|
||||
public Db_conn_info Conn_info() {return conn_info;} protected Db_conn_info conn_info;
|
||||
public Db_conn_props_mgr Props() {return props;} private final Db_conn_props_mgr props = new Db_conn_props_mgr();
|
||||
public Db_batch_mgr Batch_mgr() {return batch_mgr;} private final Db_batch_mgr batch_mgr = new Db_batch_mgr();
|
||||
public abstract Sql_qry_wtr Sql_wtr();
|
||||
public Db_conn_props_mgr Props() {return props;} private final Db_conn_props_mgr props = new Db_conn_props_mgr();
|
||||
public Db_batch_mgr Batch_mgr() {return batch_mgr;} private final Db_batch_mgr batch_mgr = new Db_batch_mgr();
|
||||
public abstract SqlQryWtr Sql_wtr();
|
||||
public abstract Db_engine New_clone(Db_conn_info conn_info);
|
||||
public Db_rdr Exec_as_rdr__rls_manual(Object rdr_obj, String sql) {return New_rdr(null, rdr_obj, sql);}
|
||||
public Db_rdr Exec_as_rdr__rls_auto(Db_stmt stmt, Object rdr_obj, String sql) {return New_rdr(stmt, rdr_obj, sql);}
|
||||
@@ -64,7 +64,7 @@ public abstract class Db_engine_sql_base implements Db_engine {
|
||||
}
|
||||
public Object Exec_as_obj(Db_qry qry) {
|
||||
if (qry.Tid() == Db_qry_.Tid_flush) return null; // ignore flush (delete-db) statements
|
||||
String sql = this.Sql_wtr().To_sql_str(qry, false); // DBG: Tfds.Write(sql);
|
||||
String sql = this.Sql_wtr().ToSqlStr(qry, false); // DBG: Tfds.Write(sql);
|
||||
return qry.Exec_is_rdr() ? (Object)this.Exec_as_rdr(sql) : this.Exec_as_int(sql);
|
||||
}
|
||||
protected int Exec_as_int(String sql) {
|
||||
|
||||
@@ -18,17 +18,17 @@ import gplx.core.stores.*; import gplx.dbs.metas.*; import gplx.dbs.sqls.*; impo
|
||||
import gplx.dbs.wkrs.SqlWkrMgr;
|
||||
|
||||
public class Mem_engine implements Db_engine {
|
||||
private final Hash_adp tbl_hash = Hash_adp_.New();
|
||||
private final Hash_adp tbl_hash = Hash_adp_.New();
|
||||
Mem_engine(Db_conn_info conn_info) {
|
||||
this.conn_info = conn_info;
|
||||
this.qry_runner = new Mem_exec_select(this);
|
||||
}
|
||||
public String Tid() {return Mem_conn_info.Tid_const;}
|
||||
public Db_conn_info Conn_info() {return conn_info;} private Db_conn_info conn_info;
|
||||
public Db_conn_props_mgr Props() {return props;} private final Db_conn_props_mgr props = new Db_conn_props_mgr();
|
||||
public Db_batch_mgr Batch_mgr() {return batch_mgr;} private final Db_batch_mgr batch_mgr = new Db_batch_mgr();
|
||||
public Db_conn_props_mgr Props() {return props;} private final Db_conn_props_mgr props = new Db_conn_props_mgr();
|
||||
public Db_batch_mgr Batch_mgr() {return batch_mgr;} private final Db_batch_mgr batch_mgr = new Db_batch_mgr();
|
||||
public Mem_exec_select Qry_runner() {return qry_runner;} private Mem_exec_select qry_runner;
|
||||
public Sql_qry_wtr Sql_wtr() {return sql_wtr;} private final Sql_qry_wtr sql_wtr = Sql_qry_wtr_.New__basic();
|
||||
public SqlQryWtr Sql_wtr() {return sql_wtr;} private final SqlQryWtr sql_wtr = SqlQryWtrUtl.NewBasic();
|
||||
@Override public void CtorConn(SqlWkrMgr wkrMgr) {}
|
||||
public Db_engine New_clone(Db_conn_info conn_info) {return new Mem_engine(conn_info);}
|
||||
public Db_stmt Stmt_by_qry(Db_qry qry) {return new Mem_stmt(this, qry);}
|
||||
@@ -59,7 +59,7 @@ public class Mem_engine implements Db_engine {
|
||||
public void Meta_idx_create(Gfo_usr_dlg usr_dlg, Dbmeta_idx_itm... ary) {} // TODO_OLD: implement unique index
|
||||
public void Meta_idx_delete(String idx) {}
|
||||
public void Meta_fld_append(String tbl, Dbmeta_fld_itm fld) {}
|
||||
public Dbmeta_tbl_mgr Meta_mgr() {return meta_mgr;} private final Dbmeta_tbl_mgr meta_mgr = new Dbmeta_tbl_mgr(Dbmeta_reload_cmd_.Noop);
|
||||
public Dbmeta_tbl_mgr Meta_mgr() {return meta_mgr;} private final Dbmeta_tbl_mgr meta_mgr = new Dbmeta_tbl_mgr(Dbmeta_reload_cmd_.Noop);
|
||||
public boolean Meta_tbl_exists(String tbl) {return tbl_hash.Has(tbl);}
|
||||
public boolean Meta_fld_exists(String tbl, String fld) {
|
||||
Mem_tbl mem_tbl = (Mem_tbl)tbl_hash.Get_by(tbl); if (mem_tbl == null) return false;
|
||||
@@ -69,5 +69,5 @@ public class Mem_engine implements Db_engine {
|
||||
public void Env_db_attach(String alias, Db_conn conn) {}
|
||||
public void Env_db_attach(String alias, Io_url db_url) {}
|
||||
public void Env_db_detach(String alias) {}
|
||||
public static final Mem_engine Instance = new Mem_engine(); Mem_engine() {}
|
||||
public static final Mem_engine Instance = new Mem_engine(); Mem_engine() {}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.engines.mems; import gplx.*; import gplx.dbs.*; import gplx.dbs.engines.*;
|
||||
import gplx.core.criterias.*;
|
||||
import gplx.dbs.qrys.*; import gplx.dbs.sqls.itms.*;
|
||||
public class Mem_exec_select {
|
||||
private final Mem_engine engine;
|
||||
private final List_adp tmp_where_rows = List_adp_.New();
|
||||
private final Mem_engine engine;
|
||||
private final List_adp tmp_where_rows = List_adp_.New();
|
||||
public Mem_exec_select(Mem_engine engine) {this.engine = engine;}
|
||||
public Db_rdr Select(Mem_stmt stmt) {
|
||||
Db_qry stmt_qry = stmt.Qry();
|
||||
@@ -71,7 +71,7 @@ public class Mem_exec_select {
|
||||
}
|
||||
}
|
||||
class Mem_sorter implements gplx.core.lists.ComparerAble {
|
||||
private final Sql_order_fld[] flds;
|
||||
private final Sql_order_fld[] flds;
|
||||
public Mem_sorter(Sql_order_fld[] flds) {
|
||||
this.flds = flds;
|
||||
}
|
||||
|
||||
@@ -13,10 +13,10 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.engines.mems; import gplx.*; import gplx.dbs.*; import gplx.dbs.engines.*;
|
||||
public class Mem_qry_set {
|
||||
private final List_adp rows = List_adp_.New();
|
||||
public int Len() {return rows.Count();}
|
||||
public Mem_row Get_at(int i) {return (Mem_row)rows.Get_at(i);}
|
||||
public void Add(Mem_row row) {rows.Add(row);}
|
||||
}
|
||||
package gplx.dbs.engines.mems; import gplx.*; import gplx.dbs.*; import gplx.dbs.engines.*;
|
||||
public class Mem_qry_set {
|
||||
private final List_adp rows = List_adp_.New();
|
||||
public int Len() {return rows.Count();}
|
||||
public Mem_row Get_at(int i) {return (Mem_row)rows.Get_at(i);}
|
||||
public void Add(Mem_row row) {rows.Add(row);}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.engines.mems; import gplx.*; import gplx.dbs.*; import gplx.dbs.engines.*;
|
||||
public class Mem_rdr implements Db_rdr {
|
||||
private final Mem_row[] rows; private int row_idx = -1; private final int rows_len;
|
||||
private final Mem_row[] rows; private int row_idx = -1; private final int rows_len;
|
||||
private Mem_row row;
|
||||
public Mem_rdr(String[] cols, Mem_row[] rows) {
|
||||
this.rows = rows; this.rows_len = rows.length;
|
||||
@@ -29,7 +29,7 @@ public class Mem_rdr implements Db_rdr {
|
||||
public byte[] Read_bry(String k) {return (byte[])row.Get_by(k);}
|
||||
public String Read_str(String k) {return (String)row.Get_by(k);}
|
||||
public byte[] Read_bry_by_str(String k) {return Bry_.new_u8_safe((String)row.Get_by(k));} // NOTE: null b/c db can have NULL
|
||||
@gplx.Virtual public void Save_bry_in_parts(Io_url url, String tbl, String fld, String crt_key, Object crt_val) {throw Err_.new_unimplemented();}
|
||||
public void Save_bry_in_parts(Io_url url, String tbl, String fld, String crt_key, Object crt_val) {throw Err_.new_unimplemented();}
|
||||
public DateAdp Read_date_by_str(String k) {return DateAdp_.parse_iso8561((String)row.Get_by(k));}
|
||||
public byte Read_byte(String k) {return Byte_.Cast(row.Get_by(k));}
|
||||
public int Read_int(String k) {return Int_.Cast(row.Get_by(k));}
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.engines.mems; import gplx.*; import gplx.dbs.*; import gplx.dbs.engines.*;
|
||||
public class Mem_row implements Gfo_invk {
|
||||
private final Ordered_hash hash = Ordered_hash_.New();
|
||||
private final Ordered_hash flds = Ordered_hash_.New();
|
||||
private final Ordered_hash hash = Ordered_hash_.New();
|
||||
private final Ordered_hash flds = Ordered_hash_.New();
|
||||
public int Len() {return hash.Len();}
|
||||
public String Fld_at(int i) {return (String)flds.Get_at(i);}
|
||||
public Object Get_at(int i) {return hash.Get_at(i);}
|
||||
@@ -32,6 +32,6 @@ public class Mem_row implements Gfo_invk {
|
||||
if (rv == null) return Gfo_invk_.Rv_unhandled;
|
||||
return rv;
|
||||
}
|
||||
public static final Mem_row[] Ary_empty = new Mem_row[0];
|
||||
public static final Mem_row Null_row = new Mem_row();
|
||||
public static final Mem_row[] Ary_empty = new Mem_row[0];
|
||||
public static final Mem_row Null_row = new Mem_row();
|
||||
}
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.engines.mems; import gplx.*; import gplx.dbs.*; import gplx.dbs.engines.*;
|
||||
import gplx.core.stores.*;
|
||||
public class Mem_stmt implements Db_stmt {
|
||||
private static final String Key_na = ""; // key is not_available; only called by procs with signature of Val(<type> v);
|
||||
private final Ordered_hash val_list = Ordered_hash_.New();
|
||||
private final Ordered_hash val_list = Ordered_hash_.New();
|
||||
public Mem_stmt(Mem_engine engine, Db_qry qry) {Ctor_stmt(engine, qry);} private Mem_engine engine;
|
||||
public void Ctor_stmt(Db_engine engine, Db_qry qry) {this.engine = (Mem_engine)engine; this.qry = qry;}
|
||||
public Mem_stmt_args Stmt_args() {return stmt_args;} private final Mem_stmt_args stmt_args = new Mem_stmt_args();
|
||||
public Mem_stmt_args Stmt_args() {return stmt_args;} private final Mem_stmt_args stmt_args = new Mem_stmt_args();
|
||||
public int Args_len() {return val_list.Count();}
|
||||
public Object Args_get_at(int i) {return val_list.Get_at(i);}
|
||||
public Object Args_get_by(String k) {return val_list.Get_by(k);}
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.engines.mems; import gplx.*; import gplx.dbs.*; import gplx.dbs.engines.*;
|
||||
import gplx.core.criterias.*;
|
||||
public class Mem_stmt_args {
|
||||
private final List_adp list = List_adp_.New();
|
||||
private final List_adp list = List_adp_.New();
|
||||
private int cur_idx = -1;
|
||||
public void Clear() {list.Clear(); cur_idx = -1;}
|
||||
public void Add(String k, Object v) {list.Add(Keyval_.new_(k, v));}
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.engines.mems; import gplx.*; import gplx.dbs.*; import gplx.dbs.engines.*;
|
||||
import gplx.core.primitives.*; import gplx.core.criterias.*; import gplx.dbs.qrys.*; import gplx.dbs.sqls.itms.*;
|
||||
import gplx.dbs.metas.*;
|
||||
public class Mem_tbl {
|
||||
private final List_adp where_rows = List_adp_.New();
|
||||
private final Hash_adp autonum_hash = Hash_adp_.New();
|
||||
private final List_adp where_rows = List_adp_.New();
|
||||
private final Hash_adp autonum_hash = Hash_adp_.New();
|
||||
public Mem_tbl(Dbmeta_tbl_itm meta) {this.meta = meta;}
|
||||
public Dbmeta_tbl_itm Meta() {return meta;} private final Dbmeta_tbl_itm meta;
|
||||
public final List_adp rows = List_adp_.New();
|
||||
public Dbmeta_tbl_itm Meta() {return meta;} private final Dbmeta_tbl_itm meta;
|
||||
public final List_adp rows = List_adp_.New();
|
||||
public int Insert(Mem_stmt stmt) {
|
||||
Mem_row itm = new Mem_row();
|
||||
Dbmeta_fld_mgr flds = meta.Flds();
|
||||
|
||||
@@ -21,15 +21,15 @@ import gplx.dbs.Db_conn_info;
|
||||
import gplx.dbs.engines.Db_engine;
|
||||
import gplx.dbs.engines.Db_engine_sql_base;
|
||||
import gplx.dbs.metas.Dbmeta_tbl_mgr;
|
||||
import gplx.dbs.sqls.Sql_qry_wtr;
|
||||
import gplx.dbs.sqls.Sql_qry_wtr_;
|
||||
import gplx.dbs.sqls.SqlQryWtr;
|
||||
import gplx.dbs.sqls.SqlQryWtrUtl;
|
||||
import gplx.dbs.wkrs.SqlWkrMgr;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
public class Mysql_engine extends Db_engine_sql_base {
|
||||
@Override public String Tid() {return Mysql_conn_info.Tid_const;}
|
||||
@Override public Sql_qry_wtr Sql_wtr() {return Sql_qry_wtr_.New__mysql();}
|
||||
@Override public SqlQryWtr Sql_wtr() {return SqlQryWtrUtl.NewMysql();}
|
||||
@Override public void CtorConn(SqlWkrMgr wkrMgr) {}
|
||||
@Override protected String Txn_bgn_str() {return "START TRANSACTION;";}
|
||||
@Override protected String Txn_end_str() {return "COMMIT;";}
|
||||
@@ -45,7 +45,7 @@ public class Mysql_engine extends Db_engine_sql_base {
|
||||
Connection rv = Conn_make_by_url("jdbc:mysql://localhost/" + conn_info_as_mysql.Database() + "?characterEncoding=UTF8&useSSL=false", conn_info_as_mysql.Uid(), conn_info_as_mysql.Pwd());
|
||||
return rv;
|
||||
}
|
||||
public static final Mysql_engine Instance = new Mysql_engine(); Mysql_engine() {}
|
||||
public static final Mysql_engine Instance = new Mysql_engine(); Mysql_engine() {}
|
||||
}
|
||||
class Mysql_rdr extends Db_data_rdr {
|
||||
//PATCH:MYSQL:byte actually returned as int by Jdbc ResultSet (or MYSQL impmentation); convert to byte
|
||||
|
||||
@@ -13,10 +13,10 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.engines.noops; import gplx.*; import gplx.dbs.*; import gplx.dbs.engines.*;
|
||||
public class Noop_conn_info extends Db_conn_info__base {
|
||||
public Noop_conn_info(String raw, String db_api, String database) {super(raw, db_api, database);}
|
||||
@Override public String Key() {return Tid_const;} public static final String Tid_const = "null_db";
|
||||
@Override public Db_conn_info New_self(String raw, Keyval_hash hash) {return this;}
|
||||
public static final Noop_conn_info Instance = new Noop_conn_info("gplx_key=null_db", "", "");
|
||||
}
|
||||
package gplx.dbs.engines.noops; import gplx.*; import gplx.dbs.*; import gplx.dbs.engines.*;
|
||||
public class Noop_conn_info extends Db_conn_info__base {
|
||||
public Noop_conn_info(String raw, String db_api, String database) {super(raw, db_api, database);}
|
||||
@Override public String Key() {return Tid_const;} public static final String Tid_const = "null_db";
|
||||
@Override public Db_conn_info New_self(String raw, Keyval_hash hash) {return this;}
|
||||
public static final Noop_conn_info Instance = new Noop_conn_info("gplx_key=null_db", "", "");
|
||||
}
|
||||
|
||||
@@ -20,9 +20,9 @@ import gplx.dbs.wkrs.SqlWkrMgr;
|
||||
public class Noop_engine implements Db_engine {
|
||||
public String Tid() {return Noop_conn_info.Tid_const;}
|
||||
public Db_conn_info Conn_info() {return Db_conn_info_.Null;}
|
||||
public Db_conn_props_mgr Props() {return props;} private final Db_conn_props_mgr props = new Db_conn_props_mgr();
|
||||
public Db_batch_mgr Batch_mgr() {return batch_mgr;} private final Db_batch_mgr batch_mgr = new Db_batch_mgr();
|
||||
public Sql_qry_wtr Sql_wtr() {return sql_wtr;} private final Sql_qry_wtr sql_wtr = Sql_qry_wtr_.New__basic();
|
||||
public Db_conn_props_mgr Props() {return props;} private final Db_conn_props_mgr props = new Db_conn_props_mgr();
|
||||
public Db_batch_mgr Batch_mgr() {return batch_mgr;} private final Db_batch_mgr batch_mgr = new Db_batch_mgr();
|
||||
public SqlQryWtr Sql_wtr() {return sql_wtr;} private final SqlQryWtr sql_wtr = SqlQryWtrUtl.NewBasic();
|
||||
@Override public void CtorConn(SqlWkrMgr wkrMgr) {}
|
||||
public void Conn_open() {}
|
||||
public void Conn_term() {}
|
||||
@@ -48,6 +48,6 @@ public class Noop_engine implements Db_engine {
|
||||
public boolean Meta_tbl_exists(String tbl) {return false;}
|
||||
public boolean Meta_fld_exists(String tbl, String fld) {return false;}
|
||||
public boolean Meta_idx_exists(String idx) {return false;}
|
||||
public Dbmeta_tbl_mgr Meta_mgr() {return meta_tbl_mgr;} private final Dbmeta_tbl_mgr meta_tbl_mgr = new Dbmeta_tbl_mgr(Dbmeta_reload_cmd_.Noop);
|
||||
public static final Noop_engine Instance = new Noop_engine(); Noop_engine() {}
|
||||
public Dbmeta_tbl_mgr Meta_mgr() {return meta_tbl_mgr;} private final Dbmeta_tbl_mgr meta_tbl_mgr = new Dbmeta_tbl_mgr(Dbmeta_reload_cmd_.Noop);
|
||||
public static final Noop_engine Instance = new Noop_engine(); Noop_engine() {}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,8 @@ GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.engines.postgres; import gplx.*; import gplx.dbs.*; import gplx.dbs.engines.*;
|
||||
import gplx.core.stores.*; import gplx.dbs.engines.*; import gplx.dbs.sqls.*; import gplx.dbs.metas.*;
|
||||
import gplx.core.stores.*;
|
||||
import gplx.dbs.sqls.*; import gplx.dbs.metas.*;
|
||||
import gplx.dbs.wkrs.SqlWkrMgr;
|
||||
|
||||
import java.sql.Connection;
|
||||
@@ -22,7 +23,7 @@ import java.sql.ResultSet;
|
||||
|
||||
public class Postgres_engine extends Db_engine_sql_base {
|
||||
@Override public String Tid() {return Postgres_conn_info.Tid_const;}
|
||||
@Override public Sql_qry_wtr Sql_wtr() {return Sql_qry_wtr_.New__mysql();}
|
||||
@Override public SqlQryWtr Sql_wtr() {return SqlQryWtrUtl.NewMysql();}
|
||||
@Override public void CtorConn(SqlWkrMgr wkrMgr) {}
|
||||
@Override public Db_engine New_clone(Db_conn_info connectInfo) {
|
||||
Postgres_engine rv = new Postgres_engine();
|
||||
@@ -35,5 +36,5 @@ public class Postgres_engine extends Db_engine_sql_base {
|
||||
Postgres_conn_info conn_info_as_postgres = (Postgres_conn_info)conn_info;
|
||||
return Conn_make_by_url("jdbc:" + conn_info_as_postgres.Key() + "://localhost/" + conn_info_as_postgres.Database(), conn_info_as_postgres.Uid(), conn_info_as_postgres.Pwd());
|
||||
}
|
||||
public static final Postgres_engine Instance = new Postgres_engine(); Postgres_engine() {}
|
||||
public static final Postgres_engine Instance = new Postgres_engine(); Postgres_engine() {}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,8 @@ import gplx.dbs.Dbmeta_fld_itm;
|
||||
import gplx.dbs.engines.Db_engine;
|
||||
import gplx.dbs.engines.Db_engine_sql_base;
|
||||
import gplx.dbs.metas.Dbmeta_tbl_mgr;
|
||||
import gplx.dbs.sqls.Sql_qry_wtr_;
|
||||
import gplx.dbs.sqls.SqlQryWtr;
|
||||
import gplx.dbs.sqls.SqlQryWtrUtl;
|
||||
import gplx.dbs.wkrs.SqlWkrMgr;
|
||||
import gplx.dbs.wkrs.randoms.SqliteRandomWkr;
|
||||
import org.sqlite.SQLiteConnection;
|
||||
@@ -52,13 +53,13 @@ import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
public class Sqlite_engine extends Db_engine_sql_base {
|
||||
private final Sqlite_txn_mgr txn_mgr; private final Sqlite_schema_mgr schema_mgr;
|
||||
private final Sqlite_txn_mgr txn_mgr; private final Sqlite_schema_mgr schema_mgr;
|
||||
Sqlite_engine() {
|
||||
this.txn_mgr = new Sqlite_txn_mgr(this);
|
||||
this.schema_mgr = new Sqlite_schema_mgr(this);
|
||||
}
|
||||
@Override public String Tid() {return Sqlite_conn_info.Key_const;}
|
||||
@Override public gplx.dbs.sqls.Sql_qry_wtr Sql_wtr() {return Sql_qry_wtr_.New__sqlite();}
|
||||
@Override public SqlQryWtr Sql_wtr() {return SqlQryWtrUtl.NewSqlite();}
|
||||
public void CtorConn(SqlWkrMgr wkrMgr) {
|
||||
wkrMgr.Set(new SqliteRandomWkr());
|
||||
}
|
||||
@@ -122,7 +123,7 @@ public class Sqlite_engine extends Db_engine_sql_base {
|
||||
catch (SQLException e) {Gfo_usr_dlg_.Instance.Warn_many("", "", "failed to set busy timeout; err=~{0}", Err_.Message_gplx_log(e));}
|
||||
return rv;
|
||||
}
|
||||
public static final Sqlite_engine Instance = new Sqlite_engine();
|
||||
public static final Sqlite_engine Instance = new Sqlite_engine();
|
||||
}
|
||||
class Db_rdr__sqlite extends Db_rdr__basic { @Override public byte Read_byte(String k) {try {return (byte)Int_.Cast(rdr.getObject(k));} catch (Exception e) {throw Err_.new_exc(e, "db", "read failed", "k", k, "type", Byte_.Cls_val_name);}}
|
||||
@Override public boolean Read_bool_by_byte(String k) {
|
||||
|
||||
@@ -73,7 +73,7 @@ public class Sqlite_engine_ {
|
||||
public static final boolean Supports_read_binary_stream = false;
|
||||
public static final boolean Supports_indexed_by = true;
|
||||
public static String X_date_to_str(DateAdp v) {return v == Date_null ? "" : v.XtoStr_fmt_iso_8561();}
|
||||
public static final DateAdp Date_null = null;
|
||||
public static final DateAdp Date_null = null;
|
||||
public static final byte Wildcard_byte = Byte_ascii.Hash;
|
||||
public static final String Wildcard_str = "%";
|
||||
public static int Read_only_detection = Io_mgr.Read_only__basic__file;
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.engines.sqlite; import gplx.*; import gplx.dbs.*; import gplx.dbs.engines.*;
|
||||
import gplx.core.primitives.*; import gplx.dbs.qrys.*; import gplx.dbs.utls.*; import gplx.dbs.engines.*; import gplx.dbs.engines.sqlite.*;
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.engines.sqlite; import gplx.*; import gplx.dbs.*;
|
||||
import gplx.dbs.sqls.SqlQryWtr;
|
||||
public class Sqlite_pragma implements Db_qry {
|
||||
private final String sql;
|
||||
private final String sql;
|
||||
public Sqlite_pragma(boolean parens, String key, String val) {
|
||||
String fmt = parens ? "PRAGMA {0}({1});" : "PRAGMA {0} = {1};";
|
||||
this.sql = String_.Format(fmt, key, val);
|
||||
@@ -24,7 +24,7 @@ public class Sqlite_pragma implements Db_qry {
|
||||
public int Tid() {return Db_qry_.Tid_pragma;}
|
||||
public boolean Exec_is_rdr() {return false;}
|
||||
public String Base_table() {return "";}
|
||||
public String To_sql__exec(gplx.dbs.sqls.Sql_qry_wtr wtr) {return sql;}
|
||||
public String To_sql__exec(SqlQryWtr wtr) {return sql;}
|
||||
|
||||
public static final String Const__journal_mode = "journal_mode", Const__journal_mode__wal = "wal", Const__journal_mode__off = "off";
|
||||
public static Sqlite_pragma New__journal__delete() {return new Sqlite_pragma(Bool_.N, Const__journal_mode , "delete");} // default
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.engines.sqlite; import gplx.*; import gplx.dbs.*; import gplx.dbs.engines.*;
|
||||
import gplx.dbs.qrys.*;
|
||||
import gplx.dbs.metas.*; import gplx.dbs.metas.parsers.*;
|
||||
public class Sqlite_schema_mgr implements Dbmeta_reload_cmd {
|
||||
private final Db_engine engine; private boolean init = true;
|
||||
private final Dbmeta_idx_mgr idx_mgr = new Dbmeta_idx_mgr();
|
||||
private final Db_engine engine; private boolean init = true;
|
||||
private final Dbmeta_idx_mgr idx_mgr = new Dbmeta_idx_mgr();
|
||||
public Sqlite_schema_mgr(Db_engine engine) {
|
||||
this.engine = engine;
|
||||
this.tbl_mgr = new Dbmeta_tbl_mgr(this);
|
||||
@@ -26,7 +26,7 @@ public class Sqlite_schema_mgr implements Dbmeta_reload_cmd {
|
||||
public Dbmeta_tbl_mgr Tbl_mgr() {
|
||||
if (init) Init(engine);
|
||||
return tbl_mgr;
|
||||
} private final Dbmeta_tbl_mgr tbl_mgr;
|
||||
} private final Dbmeta_tbl_mgr tbl_mgr;
|
||||
public boolean Tbl_exists(String name) {
|
||||
if (init) Init(engine);
|
||||
return tbl_mgr.Has(name);
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.engines.sqlite; import gplx.*; import gplx.dbs.*; import gplx.dbs.engines.*;
|
||||
import gplx.dbs.qrys.*;
|
||||
public class Sqlite_txn_mgr {
|
||||
private final List_adp txn_list = List_adp_.New();
|
||||
public Sqlite_txn_mgr(Db_engine engine) {this.engine = engine;} private final Db_engine engine;
|
||||
private final List_adp txn_list = List_adp_.New();
|
||||
public Sqlite_txn_mgr(Db_engine engine) {this.engine = engine;} private final Db_engine engine;
|
||||
private boolean pragma_needed = Bool_.Y, txn_started = Bool_.N; // NOTE: txns only support 1 level; SQLite fails when nesting transactions; DATE:2015-03-11
|
||||
public void Txn_bgn(String name) {
|
||||
if (String_.Len_eq_0(name)) name = "unnamed";
|
||||
|
||||
@@ -20,9 +20,9 @@ import gplx.dbs.wkrs.SqlWkrMgr;
|
||||
public class TdbEngine implements Db_engine {
|
||||
public String Tid() {return Tdb_conn_info.Tid_const;}
|
||||
public Db_conn_info Conn_info() {return conn_info;} private Db_conn_info conn_info;
|
||||
public Db_conn_props_mgr Props() {return props;} private final Db_conn_props_mgr props = new Db_conn_props_mgr();
|
||||
public Db_batch_mgr Batch_mgr() {return batch_mgr;} private final Db_batch_mgr batch_mgr = new Db_batch_mgr();
|
||||
public Sql_qry_wtr Sql_wtr() {return sql_wtr;} private final Sql_qry_wtr sql_wtr = Sql_qry_wtr_.New__basic();
|
||||
public Db_conn_props_mgr Props() {return props;} private final Db_conn_props_mgr props = new Db_conn_props_mgr();
|
||||
public Db_batch_mgr Batch_mgr() {return batch_mgr;} private final Db_batch_mgr batch_mgr = new Db_batch_mgr();
|
||||
public SqlQryWtr Sql_wtr() {return sql_wtr;} private final SqlQryWtr sql_wtr = SqlQryWtrUtl.NewBasic();
|
||||
public TdbDatabase Db() {return db;} TdbDatabase db;
|
||||
@Override public void CtorConn(SqlWkrMgr wkrMgr) {}
|
||||
public void Conn_open() {
|
||||
@@ -45,7 +45,7 @@ public class TdbEngine implements Db_engine {
|
||||
Db_qryWkr wkr = (Db_qryWkr)wkrs.Get_by_or_fail(qry.Tid());
|
||||
return wkr.Exec(this, qry);
|
||||
}
|
||||
public Db_stmt Stmt_by_qry(Db_qry qry) {return new Db_stmt_sql().Parse(qry, sql_wtr.To_sql_str(qry, true));}
|
||||
public Db_stmt Stmt_by_qry(Db_qry qry) {return new Db_stmt_sql().Parse(qry, sql_wtr.ToSqlStr(qry, true));}
|
||||
public Object Stmt_by_sql(String sql) {throw Err_.new_unimplemented();}
|
||||
public Db_rdr Exec_as_rdr__rls_manual(Object rdr_obj, String sql) {return Db_rdr_.Empty;}
|
||||
public Db_rdr Exec_as_rdr__rls_auto(Db_stmt stmt, Object rdr_obj, String sql) {return Db_rdr_.Empty;}
|
||||
@@ -72,10 +72,10 @@ public class TdbEngine implements Db_engine {
|
||||
public void Env_db_attach(String alias, Db_conn conn) {}
|
||||
public void Env_db_attach(String alias, Io_url db_url) {}
|
||||
public void Env_db_detach(String alias) {}
|
||||
public Dbmeta_tbl_mgr Meta_mgr() {return meta_mgr;} private final Dbmeta_tbl_mgr meta_mgr = new Dbmeta_tbl_mgr(Dbmeta_reload_cmd_.Noop);
|
||||
public Dbmeta_tbl_mgr Meta_mgr() {return meta_mgr;} private final Dbmeta_tbl_mgr meta_mgr = new Dbmeta_tbl_mgr(Dbmeta_reload_cmd_.Noop);
|
||||
|
||||
Hash_adp wkrs = Hash_adp_.New(); TdbDbLoadMgr loadMgr = TdbDbLoadMgr.new_(); TdbDbSaveMgr saveMgr = TdbDbSaveMgr.new_();
|
||||
public static final TdbEngine Instance = new TdbEngine();
|
||||
public static final TdbEngine Instance = new TdbEngine();
|
||||
void CtorTdbEngine(Db_conn_info conn_info) {
|
||||
this.conn_info = conn_info;
|
||||
wkrs.Add(Db_qry_.Tid_select, TdbSelectWkr.Instance);
|
||||
@@ -91,7 +91,7 @@ interface Db_qryWkr {
|
||||
Object Exec(Db_engine engine, Db_qry cmd);
|
||||
}
|
||||
class Db_qryWkr_ {
|
||||
public static final Db_qryWkr Null = new Db_qryWrk_null();
|
||||
public static final Db_qryWkr Null = new Db_qryWrk_null();
|
||||
}
|
||||
class Db_qryWrk_null implements Db_qryWkr {
|
||||
public Object Exec(Db_engine engine, Db_qry cmd) {return null;}
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.metas; import gplx.*; import gplx.dbs.*;
|
||||
public class Dbmeta_fld_mgr {
|
||||
private final Ordered_hash hash = Ordered_hash_.New();
|
||||
private final Ordered_hash hash = Ordered_hash_.New();
|
||||
public int Len() {return hash.Count();}
|
||||
public void Clear() {hash.Clear();}
|
||||
public void Add(Dbmeta_fld_itm itm) {hash.Add(itm.Name(), itm);}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.metas; import gplx.*; import gplx.dbs.*;
|
||||
public class Dbmeta_idx_fld {
|
||||
public Dbmeta_idx_fld(String name, int sort_tid) {this.Name = name; this.Sort_tid = sort_tid;}
|
||||
@@ -23,7 +23,7 @@ public class Dbmeta_idx_fld {
|
||||
&& Sort_tid == comp.Sort_tid;
|
||||
}
|
||||
|
||||
public static final Dbmeta_idx_fld[] Ary_empty = new Dbmeta_idx_fld[0];
|
||||
public static final Dbmeta_idx_fld[] Ary_empty = new Dbmeta_idx_fld[0];
|
||||
public static final int Sort_tid__none = 0, Sort_tid__asc = 1, Sort_tid__desc = 2;
|
||||
public static boolean Ary_eq(Dbmeta_idx_fld[] lhs_ary, Dbmeta_idx_fld[] rhs_ary) {
|
||||
int lhs_len = lhs_ary.length, rhs_len = rhs_ary.length;
|
||||
|
||||
@@ -13,10 +13,10 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.metas; import gplx.*; import gplx.dbs.*;
|
||||
public class Dbmeta_reload_cmd_ {
|
||||
public static final Dbmeta_reload_cmd Noop = new Dbmeta_reload_cmd__noop();
|
||||
}
|
||||
class Dbmeta_reload_cmd__noop implements Dbmeta_reload_cmd {
|
||||
public void Load_all() {}
|
||||
}
|
||||
package gplx.dbs.metas; import gplx.*; import gplx.dbs.*;
|
||||
public class Dbmeta_reload_cmd_ {
|
||||
public static final Dbmeta_reload_cmd Noop = new Dbmeta_reload_cmd__noop();
|
||||
}
|
||||
class Dbmeta_reload_cmd__noop implements Dbmeta_reload_cmd {
|
||||
public void Load_all() {}
|
||||
}
|
||||
|
||||
@@ -13,16 +13,16 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.metas; import gplx.*; import gplx.dbs.*;
|
||||
public class Dbmeta_tbl_mgr {
|
||||
private final Ordered_hash hash = Ordered_hash_.New();
|
||||
private final Dbmeta_reload_cmd load_cmd;
|
||||
public Dbmeta_tbl_mgr(Dbmeta_reload_cmd load_cmd) {this.load_cmd = load_cmd;}
|
||||
public int Len() {return hash.Count();}
|
||||
public boolean Has(String name) {return hash.Has(name);}
|
||||
public Dbmeta_tbl_itm Get_at(int i) {return (Dbmeta_tbl_itm)hash.Get_at(i);}
|
||||
public Dbmeta_tbl_itm Get_by(String name) {return (Dbmeta_tbl_itm)hash.Get_by(name);}
|
||||
public void Add(Dbmeta_tbl_itm itm) {hash.Add_if_dupe_use_nth(itm.Name(), itm);}
|
||||
public void Clear() {hash.Clear();}
|
||||
public Dbmeta_tbl_mgr Load_all() {load_cmd.Load_all(); return this;}
|
||||
}
|
||||
package gplx.dbs.metas; import gplx.*; import gplx.dbs.*;
|
||||
public class Dbmeta_tbl_mgr {
|
||||
private final Ordered_hash hash = Ordered_hash_.New();
|
||||
private final Dbmeta_reload_cmd load_cmd;
|
||||
public Dbmeta_tbl_mgr(Dbmeta_reload_cmd load_cmd) {this.load_cmd = load_cmd;}
|
||||
public int Len() {return hash.Count();}
|
||||
public boolean Has(String name) {return hash.Has(name);}
|
||||
public Dbmeta_tbl_itm Get_at(int i) {return (Dbmeta_tbl_itm)hash.Get_at(i);}
|
||||
public Dbmeta_tbl_itm Get_by(String name) {return (Dbmeta_tbl_itm)hash.Get_by(name);}
|
||||
public void Add(Dbmeta_tbl_itm itm) {hash.Add_if_dupe_use_nth(itm.Name(), itm);}
|
||||
public void Clear() {hash.Clear();}
|
||||
public Dbmeta_tbl_mgr Load_all() {load_cmd.Load_all(); return this;}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.metas.parsers; import gplx.*; import gplx.dbs.*; import gplx.dbs.metas.*;
|
||||
import gplx.core.brys.*; import gplx.core.btries.*;
|
||||
abstract class Dbmeta_fld_wkr__base {
|
||||
private byte[] hook;
|
||||
private final Btrie_slim_mgr words_trie = Btrie_slim_mgr.ci_a7();
|
||||
private final Btrie_slim_mgr words_trie = Btrie_slim_mgr.ci_a7();
|
||||
private int words_len;
|
||||
@gplx.Virtual public int Tid() {return Tid_other;}
|
||||
public int Tid() {return Tid_other;}
|
||||
public void Ctor(byte[] hook, byte[]... words_ary) {
|
||||
this.hook = hook;
|
||||
this.words_len = words_ary.length;
|
||||
@@ -29,7 +29,7 @@ abstract class Dbmeta_fld_wkr__base {
|
||||
public void Reg(Btrie_slim_mgr trie) {
|
||||
trie.Add_obj(hook, this);
|
||||
}
|
||||
@gplx.Virtual public void Match(Bry_rdr rdr, Dbmeta_fld_itm fld) {
|
||||
public void Match(Bry_rdr rdr, Dbmeta_fld_itm fld) {
|
||||
int words_len = words_trie.Count();
|
||||
for (int i = 0; i < words_len; ++i) {
|
||||
rdr.Skip_ws();
|
||||
@@ -44,47 +44,47 @@ class Dbmeta_fld_wkr__end_comma extends Dbmeta_fld_wkr__base {
|
||||
public Dbmeta_fld_wkr__end_comma() {this.Ctor(Hook);}
|
||||
@Override public int Tid() {return Tid_end_comma;}
|
||||
@Override protected void When_match(Dbmeta_fld_itm fld) {}
|
||||
private static final byte[] Hook = Bry_.new_a7(",");
|
||||
public static final Dbmeta_fld_wkr__end_comma Instance = new Dbmeta_fld_wkr__end_comma();
|
||||
private static final byte[] Hook = Bry_.new_a7(",");
|
||||
public static final Dbmeta_fld_wkr__end_comma Instance = new Dbmeta_fld_wkr__end_comma();
|
||||
}
|
||||
class Dbmeta_fld_wkr__end_paren extends Dbmeta_fld_wkr__base {
|
||||
public Dbmeta_fld_wkr__end_paren() {this.Ctor(Hook);}
|
||||
@Override public int Tid() {return Tid_end_paren;}
|
||||
@Override protected void When_match(Dbmeta_fld_itm fld) {}
|
||||
private static final byte[] Hook = Bry_.new_a7(")");
|
||||
public static final Dbmeta_fld_wkr__end_paren Instance = new Dbmeta_fld_wkr__end_paren();
|
||||
private static final byte[] Hook = Bry_.new_a7(")");
|
||||
public static final Dbmeta_fld_wkr__end_paren Instance = new Dbmeta_fld_wkr__end_paren();
|
||||
}
|
||||
class Dbmeta_fld_wkr__nullable_null extends Dbmeta_fld_wkr__base {
|
||||
public Dbmeta_fld_wkr__nullable_null() {this.Ctor(Hook);}
|
||||
@Override protected void When_match(Dbmeta_fld_itm fld) {
|
||||
fld.Nullable_tid_(Dbmeta_fld_itm.Nullable_null);
|
||||
}
|
||||
private static final byte[] Hook = Bry_.new_a7("null");
|
||||
public static final Dbmeta_fld_wkr__nullable_null Instance = new Dbmeta_fld_wkr__nullable_null();
|
||||
private static final byte[] Hook = Bry_.new_a7("null");
|
||||
public static final Dbmeta_fld_wkr__nullable_null Instance = new Dbmeta_fld_wkr__nullable_null();
|
||||
}
|
||||
class Dbmeta_fld_wkr__nullable_not extends Dbmeta_fld_wkr__base {
|
||||
public Dbmeta_fld_wkr__nullable_not() {this.Ctor(Hook, Bry_null);}
|
||||
@Override protected void When_match(Dbmeta_fld_itm fld) {
|
||||
fld.Nullable_tid_(Dbmeta_fld_itm.Nullable_not_null);
|
||||
}
|
||||
private static final byte[] Hook = Bry_.new_a7("not"), Bry_null = Bry_.new_a7("null");
|
||||
public static final Dbmeta_fld_wkr__nullable_not Instance = new Dbmeta_fld_wkr__nullable_not();
|
||||
private static final byte[] Hook = Bry_.new_a7("not"), Bry_null = Bry_.new_a7("null");
|
||||
public static final Dbmeta_fld_wkr__nullable_not Instance = new Dbmeta_fld_wkr__nullable_not();
|
||||
}
|
||||
class Dbmeta_fld_wkr__primary_key extends Dbmeta_fld_wkr__base {
|
||||
public Dbmeta_fld_wkr__primary_key() {this.Ctor(Hook, Bry_key);}
|
||||
@Override protected void When_match(Dbmeta_fld_itm fld) {
|
||||
fld.Primary_y_();
|
||||
}
|
||||
private static final byte[] Hook = Bry_.new_a7("primary"), Bry_key = Bry_.new_a7("key");
|
||||
public static final Dbmeta_fld_wkr__primary_key Instance = new Dbmeta_fld_wkr__primary_key();
|
||||
private static final byte[] Hook = Bry_.new_a7("primary"), Bry_key = Bry_.new_a7("key");
|
||||
public static final Dbmeta_fld_wkr__primary_key Instance = new Dbmeta_fld_wkr__primary_key();
|
||||
}
|
||||
class Dbmeta_fld_wkr__autonumber extends Dbmeta_fld_wkr__base {
|
||||
public Dbmeta_fld_wkr__autonumber() {this.Ctor(Hook);}
|
||||
@Override protected void When_match(Dbmeta_fld_itm fld) {
|
||||
fld.Autonum_y_();
|
||||
}
|
||||
private static final byte[] Hook = Bry_.new_a7("autoincrement");
|
||||
public static final Dbmeta_fld_wkr__autonumber Instance = new Dbmeta_fld_wkr__autonumber();
|
||||
private static final byte[] Hook = Bry_.new_a7("autoincrement");
|
||||
public static final Dbmeta_fld_wkr__autonumber Instance = new Dbmeta_fld_wkr__autonumber();
|
||||
}
|
||||
class Dbmeta_fld_wkr__default extends Dbmeta_fld_wkr__base {
|
||||
public Dbmeta_fld_wkr__default() {this.Ctor(Hook);}
|
||||
@@ -141,6 +141,6 @@ class Dbmeta_fld_wkr__default extends Dbmeta_fld_wkr__base {
|
||||
return String_.new_a7(src, bgn, end);
|
||||
}
|
||||
@Override protected void When_match(Dbmeta_fld_itm fld) {}
|
||||
private static final byte[] Hook = Bry_.new_a7("default");
|
||||
public static final Dbmeta_fld_wkr__default Instance = new Dbmeta_fld_wkr__default();
|
||||
private static final byte[] Hook = Bry_.new_a7("default");
|
||||
public static final Dbmeta_fld_wkr__default Instance = new Dbmeta_fld_wkr__default();
|
||||
}
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.metas.parsers; import gplx.*; import gplx.dbs.*; import gplx.dbs.metas.*;
|
||||
import gplx.core.brys.*; import gplx.core.btries.*;
|
||||
import gplx.dbs.engines.sqlite.*;
|
||||
public class Dbmeta_parser__fld {
|
||||
private final Btrie_rv trv = new Btrie_rv();
|
||||
private final Btrie_rv trv = new Btrie_rv();
|
||||
public Dbmeta_fld_itm Parse_fld(Sql_bry_rdr rdr) { // starts after "(" or ","; EX: "(fld1 int", ", fld2 int"; ends at ")"
|
||||
byte[] name = rdr.Read_sql_identifier();
|
||||
Dbmeta_fld_tid type = this.Parse_type(rdr);
|
||||
@@ -68,7 +68,7 @@ public class Dbmeta_parser__fld {
|
||||
}
|
||||
return new Dbmeta_fld_tid(type_itm.Tid_ansi(), type_itm.Tid_sqlite(), type_itm.Word(), len_1, len_2);
|
||||
}
|
||||
private static final Btrie_slim_mgr fld_trie = fld_trie_init
|
||||
private static final Btrie_slim_mgr fld_trie = fld_trie_init
|
||||
( Dbmeta_fld_wkr__nullable_null.Instance
|
||||
, Dbmeta_fld_wkr__nullable_not.Instance
|
||||
, Dbmeta_fld_wkr__autonumber.Instance
|
||||
@@ -81,7 +81,7 @@ public class Dbmeta_parser__fld {
|
||||
wkr.Reg(rv);
|
||||
return rv;
|
||||
}
|
||||
private static final Btrie_slim_mgr type_trie = type_trie_init();
|
||||
private static final Btrie_slim_mgr type_trie = type_trie_init();
|
||||
private static Btrie_slim_mgr type_trie_init() {
|
||||
Btrie_slim_mgr rv = Btrie_slim_mgr.ci_a7();
|
||||
Dbmeta_parser__fld_itm.reg_many(rv, Dbmeta_fld_tid.Tid__byte , Sqlite_tid.Tid_int , 0, "tinyint", "int2");
|
||||
@@ -106,10 +106,10 @@ class Dbmeta_parser__fld_itm {
|
||||
this.tid_ansi = tid_ansi; this.tid_sqlite = tid_sqlite;
|
||||
this.word = word; this.paren_itms_count = paren_itms_count;
|
||||
}
|
||||
public int Tid_ansi() {return tid_ansi;} private final int tid_ansi;
|
||||
public int Tid_sqlite() {return tid_sqlite;} private final int tid_sqlite;
|
||||
public byte[] Word() {return word;} private final byte[] word;
|
||||
public int Paren_itms_count() {return paren_itms_count;} private final int paren_itms_count;
|
||||
public int Tid_ansi() {return tid_ansi;} private final int tid_ansi;
|
||||
public int Tid_sqlite() {return tid_sqlite;} private final int tid_sqlite;
|
||||
public byte[] Word() {return word;} private final byte[] word;
|
||||
public int Paren_itms_count() {return paren_itms_count;} private final int paren_itms_count;
|
||||
public static void reg_many(Btrie_slim_mgr trie, int tid_ansi, int tid_sqlite, int paren_itms_count, String... names_str) {
|
||||
int len = names_str.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
|
||||
@@ -38,8 +38,8 @@ public class Dbmeta_parser__fld_tst {
|
||||
}
|
||||
}
|
||||
class Dbmeta_parser__fld_fxt {
|
||||
private final Dbmeta_parser__fld fld_parser = new Dbmeta_parser__fld();
|
||||
private final Sql_bry_rdr rdr = new Sql_bry_rdr();
|
||||
private final Dbmeta_parser__fld fld_parser = new Dbmeta_parser__fld();
|
||||
private final Sql_bry_rdr rdr = new Sql_bry_rdr();
|
||||
public void Clear() {}
|
||||
public Dbmeta_fld_tid Make_type(int tid_ansi) {return new Dbmeta_fld_tid(tid_ansi, -1, null, Int_.Min_value, Int_.Min_value);}
|
||||
public Dbmeta_fld_tid Make_type(int tid_ansi, int len_1) {return new Dbmeta_fld_tid(tid_ansi, -1, null, len_1, Int_.Min_value);}
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.metas.parsers; import gplx.*; import gplx.dbs.*; import gplx.dbs.metas.*;
|
||||
import gplx.core.brys.*; import gplx.core.btries.*;
|
||||
public class Dbmeta_parser__idx {
|
||||
private final Sql_bry_rdr rdr = new Sql_bry_rdr();
|
||||
private final List_adp tmp_list = List_adp_.New();
|
||||
private final Sql_bry_rdr rdr = new Sql_bry_rdr();
|
||||
private final List_adp tmp_list = List_adp_.New();
|
||||
public Dbmeta_idx_itm Parse(byte[] src) {
|
||||
rdr.Init_by_page(Bry_.Empty, src, src.length);
|
||||
rdr.Skip_ws().Chk_trie_val(trie, Tid__create);
|
||||
@@ -43,12 +43,12 @@ public class Dbmeta_parser__idx {
|
||||
return new Dbmeta_idx_itm(unique, String_.new_u8(tbl_name), String_.new_u8(idx_name), (Dbmeta_idx_fld[])tmp_list.To_ary_and_clear(Dbmeta_idx_fld.class));
|
||||
}
|
||||
private static final byte Tid__create = 0, Tid__unique = 1, Tid__index = 2, Tid__on = 3;
|
||||
private static final byte[]
|
||||
private static final byte[]
|
||||
Bry__create = Bry_.new_a7("create")
|
||||
, Bry__unique = Bry_.new_a7("unique")
|
||||
, Bry__index = Bry_.new_a7("index")
|
||||
, Bry__on = Bry_.new_a7("on");
|
||||
private static final Btrie_slim_mgr trie = Btrie_slim_mgr.ci_a7()
|
||||
private static final Btrie_slim_mgr trie = Btrie_slim_mgr.ci_a7()
|
||||
.Add_bry_byte(Bry__create , Tid__create)
|
||||
.Add_bry_byte(Bry__unique , Tid__unique)
|
||||
.Add_bry_byte(Bry__index , Tid__index)
|
||||
|
||||
@@ -15,6 +15,7 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.qrys; import gplx.*; import gplx.dbs.*;
|
||||
import gplx.core.criterias.*;
|
||||
import gplx.dbs.sqls.SqlQryWtr;
|
||||
import gplx.dbs.sqls.itms.*;
|
||||
public class Db_qry__select_cmd implements Db_qry {
|
||||
public int Tid() {return Db_qry_.Tid_select;}
|
||||
@@ -107,6 +108,6 @@ public class Db_qry__select_cmd implements Db_qry {
|
||||
return this;
|
||||
}
|
||||
|
||||
public String To_sql__exec(gplx.dbs.sqls.Sql_qry_wtr wtr) {return wtr.To_sql_str(this, Bool_.N);}
|
||||
public String To_sql__prep(gplx.dbs.sqls.Sql_qry_wtr wtr) {return wtr.To_sql_str(this, Bool_.Y);}
|
||||
public String To_sql__exec(SqlQryWtr wtr) {return wtr.ToSqlStr(this, Bool_.N);}
|
||||
public String To_sql__prep(SqlQryWtr wtr) {return wtr.ToSqlStr(this, Bool_.Y);}
|
||||
}
|
||||
|
||||
@@ -1,31 +1,32 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.qrys; import gplx.*; import gplx.dbs.*;
|
||||
import gplx.core.strings.*; import gplx.core.criterias.*;
|
||||
import gplx.dbs.sqls.SqlQryWtr;
|
||||
public class Db_qry__select_in_tbl implements Db_qry {
|
||||
public Db_qry__select_in_tbl(String base_table, String[] select_flds, String[] where_flds, String group_by_sql, String having_sql, String order_by_sql, String limit_sql) {
|
||||
this.base_table = base_table; this.select_flds = select_flds; this.where_flds = where_flds; this.group_by_sql = group_by_sql; this.having_sql = having_sql; this.order_by_sql = order_by_sql; this.limit_sql = limit_sql;
|
||||
}
|
||||
public int Tid() {return Db_qry_.Tid_select_in_tbl;}
|
||||
public boolean Exec_is_rdr() {return true;}
|
||||
public String Base_table() {return base_table;} private final String base_table;
|
||||
public String Base_table() {return base_table;} private final String base_table;
|
||||
public Criteria Where() {return where;} private Criteria where;
|
||||
public void Where_(Criteria v) {this.where = v;}
|
||||
public String[] Select_flds() {return select_flds;} private final String[] select_flds;
|
||||
private final String[] where_flds;
|
||||
public String[] Select_flds() {return select_flds;} private final String[] select_flds;
|
||||
private final String[] where_flds;
|
||||
public void Where_sql(String_bldr sb) {
|
||||
if (where_flds == null) return;
|
||||
int where_flds_len = where_flds.length;
|
||||
@@ -35,11 +36,11 @@ public class Db_qry__select_in_tbl implements Db_qry {
|
||||
sb.Add(where_flds[i]).Add(" = ? ");
|
||||
}
|
||||
}
|
||||
public String Group_by_sql() {return group_by_sql;} private final String group_by_sql;
|
||||
public String Having_sql() {return having_sql;} private final String having_sql;
|
||||
public String Group_by_sql() {return group_by_sql;} private final String group_by_sql;
|
||||
public String Having_sql() {return having_sql;} private final String having_sql;
|
||||
public String Order_by_sql() {return order_by_sql;} public Db_qry__select_in_tbl Order_by_sql_(String v) {order_by_sql = v; return this;} private String order_by_sql;
|
||||
public String Limit_sql() {return limit_sql;} private final String limit_sql;
|
||||
public String To_sql__exec(gplx.dbs.sqls.Sql_qry_wtr wtr) {
|
||||
public String Limit_sql() {return limit_sql;} private final String limit_sql;
|
||||
public String To_sql__exec(SqlQryWtr wtr) {
|
||||
synchronized (this) {
|
||||
String_bldr sb = String_bldr_.new_();
|
||||
sb.Add("SELECT ");
|
||||
@@ -80,6 +81,6 @@ public class Db_qry__select_in_tbl implements Db_qry {
|
||||
return rv;
|
||||
}
|
||||
public static Db_qry__select_in_tbl as_(Object obj) {return obj instanceof Db_qry__select_in_tbl ? (Db_qry__select_in_tbl)obj : null;}
|
||||
public static final String[] Where_flds__all = String_.Ary_empty;
|
||||
public static final String[] Order_by_null = null;
|
||||
public static final String[] Where_flds__all = String_.Ary_empty;
|
||||
public static final String[] Order_by_null = null;
|
||||
}
|
||||
|
||||
@@ -13,18 +13,18 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.qrys; import gplx.*; import gplx.dbs.*;
|
||||
import gplx.core.criterias.*; import gplx.dbs.sqls.*;
|
||||
public class Db_qry_delete implements Db_qry {
|
||||
Db_qry_delete(String base_table, Criteria where) {this.base_table = base_table; this.where = where;}
|
||||
public int Tid() {return Db_qry_.Tid_delete;}
|
||||
public boolean Exec_is_rdr() {return Bool_.N;}
|
||||
public String Base_table() {return base_table;} private final String base_table;
|
||||
public String To_sql__exec(Sql_qry_wtr wtr) {return wtr.To_sql_str(this, false);}
|
||||
public Criteria Where() {return where;} private final Criteria where;
|
||||
public int Exec_qry(Db_conn conn) {return conn.Exec_qry(this);}
|
||||
public static Db_qry_delete new_all_(String tbl) {return new Db_qry_delete(tbl, Criteria_.All);}
|
||||
public static Db_qry_delete new_(String tbl, String... where) {return new Db_qry_delete(tbl, Db_crt_.eq_many_(where));}
|
||||
public static Db_qry_delete new_(String tbl, Criteria where) {return new Db_qry_delete(tbl, where);}
|
||||
public static final Criteria Where__null = null;
|
||||
}
|
||||
package gplx.dbs.qrys; import gplx.*; import gplx.dbs.*;
|
||||
import gplx.core.criterias.*; import gplx.dbs.sqls.*;
|
||||
public class Db_qry_delete implements Db_qry {
|
||||
Db_qry_delete(String base_table, Criteria where) {this.base_table = base_table; this.where = where;}
|
||||
public int Tid() {return Db_qry_.Tid_delete;}
|
||||
public boolean Exec_is_rdr() {return Bool_.N;}
|
||||
public String Base_table() {return base_table;} private final String base_table;
|
||||
public String To_sql__exec(SqlQryWtr wtr) {return wtr.ToSqlStr(this, false);}
|
||||
public Criteria Where() {return where;} private final Criteria where;
|
||||
public int Exec_qry(Db_conn conn) {return conn.Exec_qry(this);}
|
||||
public static Db_qry_delete new_all_(String tbl) {return new Db_qry_delete(tbl, Criteria_.All);}
|
||||
public static Db_qry_delete new_(String tbl, String... where) {return new Db_qry_delete(tbl, Db_crt_.eq_many_(where));}
|
||||
public static Db_qry_delete new_(String tbl, Criteria where) {return new Db_qry_delete(tbl, where);}
|
||||
public static final Criteria Where__null = null;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.qrys; import gplx.*; import gplx.dbs.*;
|
||||
import gplx.dbs.sqls.SqlQryWtrUtl;
|
||||
import org.junit.*;
|
||||
import gplx.core.criterias.*;
|
||||
public class Db_qry_dml_tst {
|
||||
@@ -38,5 +39,5 @@ public class Db_qry_dml_tst {
|
||||
qry.Where_(Criteria_.And(Db_crt_.New_eq("id", 0), Db_crt_.New_mt("startTime", DateAdp_.parse_gplx("2005-01-01"))));
|
||||
tst_XtoSql(qry, "UPDATE tbl0 SET id=1, name='me', startTime='2007-12-23 00:00:00.000' WHERE (id = 0 AND startTime > '2005-01-01 00:00:00.000')");
|
||||
}
|
||||
void tst_XtoSql(Db_qry qry, String expd) {Tfds.Eq(expd, qry.To_sql__exec(gplx.dbs.sqls.Sql_qry_wtr_.New__basic()));}
|
||||
void tst_XtoSql(Db_qry qry, String expd) {Tfds.Eq(expd, qry.To_sql__exec(SqlQryWtrUtl.NewBasic()));}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.qrys; import gplx.*; import gplx.dbs.*;
|
||||
import gplx.dbs.sqls.*;
|
||||
public class Db_qry_flush implements Db_qry {
|
||||
public int Tid() {return Db_qry_.Tid_flush;}
|
||||
public boolean Exec_is_rdr() {return false;}
|
||||
public String Base_table() {return tableNames[0];}
|
||||
public String To_sql__exec(Sql_qry_wtr wtr) {return wtr.To_sql_str(this, false);}
|
||||
public String To_sql__exec(SqlQryWtr wtr) {return wtr.ToSqlStr(this, false);}
|
||||
public int Exec_qry(Db_conn conn) {return conn.Exec_qry(this);}
|
||||
|
||||
public String[] TableNames() {return tableNames;} private String[] tableNames;
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.qrys; import gplx.*; import gplx.dbs.*;
|
||||
import gplx.dbs.sqls.*; import gplx.dbs.sqls.itms.*;
|
||||
public class Db_qry_insert implements Db_arg_owner {
|
||||
public class Db_qry_insert implements Db_arg_owner {
|
||||
public Db_qry_insert(String base_table) {this.base_table = base_table;}
|
||||
public int Tid() {return Db_qry_.Tid_insert;}
|
||||
public boolean Exec_is_rdr() {return false;}
|
||||
public String To_sql__exec(Sql_qry_wtr wtr) {return wtr.To_sql_str(this, false);}
|
||||
public String To_sql__exec(SqlQryWtr wtr) {return wtr.ToSqlStr(this, false);}
|
||||
public int Exec_qry(Db_conn conn) {return conn.Exec_qry(this);}
|
||||
public String Base_table() {return base_table;} private String base_table;
|
||||
public String[] Cols_for_insert() {return cols_for_insert;} private String[] cols_for_insert;
|
||||
|
||||
@@ -83,5 +83,5 @@ public class Db_qry_select_tst {
|
||||
// expd = "SELECT fld0, fld1 FROM tbl0 GROUP BY fld0, fld1 HAVING Count(fld0) > 1";
|
||||
// Tfds.Eq(cmd.To_str(), expd);
|
||||
// }
|
||||
void tst_XtoStr(Db_qry qry, String expd) {Tfds.Eq(expd, cmd.To_sql__exec(Sql_qry_wtr_.New__basic()));}
|
||||
void tst_XtoStr(Db_qry qry, String expd) {Tfds.Eq(expd, cmd.To_sql__exec(SqlQryWtrUtl.NewBasic()));}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.qrys; import gplx.*; import gplx.dbs.*;
|
||||
import gplx.dbs.sqls.*;
|
||||
public class Db_qry_sql implements Db_qry {
|
||||
public int Tid() {return Db_qry_.Tid_sql;}
|
||||
public boolean Exec_is_rdr() {return isReader;} private boolean isReader;
|
||||
public String Base_table() {throw Err_.new_unimplemented();}
|
||||
public String To_sql__exec(Sql_qry_wtr wtr) {return sql;} private String sql;
|
||||
public String To_sql__exec(SqlQryWtr wtr) {return sql;} private String sql;
|
||||
public int Exec_qry(Db_conn conn) {return conn.Exec_qry(this);}
|
||||
public static Db_qry_sql dml_(String sql) {return sql_(sql);}
|
||||
public static Db_qry_sql ddl_(String sql) {return sql_(sql);}
|
||||
@@ -36,8 +36,8 @@ public class Db_qry_sql implements Db_qry {
|
||||
}
|
||||
public static Db_qry_sql as_(Object obj) {return obj instanceof Db_qry_sql ? (Db_qry_sql)obj : null;}
|
||||
public static Db_qry_sql cast(Object obj) {try {return (Db_qry_sql)obj;} catch(Exception exc) {throw Err_.new_type_mismatch_w_exc(exc, Db_qry_sql.class, obj);}}
|
||||
public static String Gen_sql(Sql_qry_wtr qry_wtr, Db_qry qry, Object... args) {
|
||||
byte[] src = Bry_.new_u8(qry_wtr.To_sql_str(qry, true));
|
||||
public static String Gen_sql(SqlQryWtr qry_wtr, Db_qry qry, Object... args) {
|
||||
byte[] src = Bry_.new_u8(qry_wtr.ToSqlStr(qry, true));
|
||||
int src_len = src.length;
|
||||
int args_idx = 0, args_len = args.length, pos = 0;
|
||||
Bry_bfr bfr = Bry_bfr_.New_w_size(src_len);
|
||||
@@ -76,5 +76,5 @@ public class Db_qry_sql implements Db_qry {
|
||||
val_bry = Bry_.Replace(val_bry, Byte_ascii.Apos_bry, Bry_escape_apos);
|
||||
bfr.Add_byte_apos().Add(val_bry).Add_byte_apos();
|
||||
}
|
||||
} private static final byte[] Bry_null = Bry_.new_u8("NULL"), Bry_escape_apos = Bry_.new_a7("''");
|
||||
} private static final byte[] Bry_null = Bry_.new_u8("NULL"), Bry_escape_apos = Bry_.new_a7("''");
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class Db_qry_sql_tst {
|
||||
}
|
||||
}
|
||||
class Db_qry_sql_fxt {
|
||||
private final Sql_qry_wtr qry_wtr = Sql_qry_wtr_.New__sqlite();
|
||||
private final SqlQryWtr qry_wtr = SqlQryWtrUtl.NewSqlite();
|
||||
public void Clear() {}
|
||||
public void Test_qry(Db_qry qry, Object[] vals, String expd) {Tfds.Eq(expd, Db_qry_sql.Gen_sql(qry_wtr, qry, vals));}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.qrys; import gplx.*; import gplx.dbs.*;
|
||||
import gplx.core.criterias.*; import gplx.dbs.sqls.*;
|
||||
public class Db_qry_update implements Db_arg_owner {
|
||||
public int Tid() {return Db_qry_.Tid_update;}
|
||||
public boolean Exec_is_rdr() {return false;}
|
||||
public String To_sql__exec(Sql_qry_wtr wtr) {return wtr.To_sql_str(this, false);}
|
||||
public String To_sql__exec(SqlQryWtr wtr) {return wtr.ToSqlStr(this, false);}
|
||||
public int Exec_qry(Db_conn conn) {return conn.Exec_qry(this);}
|
||||
public String Base_table() {return base_table;} private String base_table;
|
||||
public String[] Cols_for_update() {return cols_for_update;} private String[] cols_for_update;
|
||||
|
||||
@@ -42,7 +42,7 @@ public class Db_stmt_cmd implements Db_stmt {
|
||||
public Db_stmt_cmd(Db_engine engine, Db_qry qry) {Ctor_stmt(engine, qry);}
|
||||
public void Ctor_stmt(Db_engine engine, Db_qry qry) {
|
||||
this.engine = engine;
|
||||
sql = qry.Tid() == Db_qry_.Tid_select_in_tbl ? ((Db_qry__select_in_tbl)qry).To_sql__exec(engine.Sql_wtr()) : engine.Sql_wtr().To_sql_str(qry, true);
|
||||
sql = qry.Tid() == Db_qry_.Tid_select_in_tbl ? ((Db_qry__select_in_tbl)qry).To_sql__exec(engine.Sql_wtr()) : engine.Sql_wtr().ToSqlStr(qry, true);
|
||||
Reset_stmt();
|
||||
}
|
||||
public Db_stmt Reset_stmt() {
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.qrys; import gplx.*; import gplx.dbs.*;
|
||||
import gplx.core.brys.fmtrs.*; import gplx.core.stores.*;
|
||||
import gplx.dbs.engines.*;
|
||||
public class Db_stmt_sql implements Db_stmt {// used for formatting SQL statements; not used for actual insert into database
|
||||
private static final String Key_na = ""; // key is not_available; only called by procs with signature of Val(<type> v);
|
||||
private final List_adp args = List_adp_.New();
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr_.New();
|
||||
private final Bry_fmtr tmp_fmtr = Bry_fmtr.new_();
|
||||
private final List_adp args = List_adp_.New();
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr_.New();
|
||||
private final Bry_fmtr tmp_fmtr = Bry_fmtr.new_();
|
||||
public void Ctor_stmt(Db_engine engine, Db_qry qry) {}
|
||||
public Db_conn Conn() {return conn;} public void Conn_(Db_conn v) {this.conn = v;} Db_conn conn;
|
||||
public Db_stmt Reset_stmt() {return this;}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.qrys.bats; import gplx.*; import gplx.dbs.*; import gplx.dbs.qrys.*;
|
||||
import gplx.dbs.engines.*; import gplx.dbs.engines.sqlite.*;
|
||||
public class Db_batch__journal_off {
|
||||
@@ -32,7 +32,7 @@ class Db_batch__journal_off__conn_bgn implements Db_batch_itm {
|
||||
engine.Exec_as_obj(Sqlite_pragma.New__journal__off()); // off b/c failure and corruption doesn't matter to import
|
||||
engine.Exec_as_obj(Sqlite_pragma.New__synchronous__off()); // off b/c failure and corruption doesn't matter to import
|
||||
}
|
||||
public static final Db_batch__journal_off__conn_bgn Instance = new Db_batch__journal_off__conn_bgn(); Db_batch__journal_off__conn_bgn() {}
|
||||
public static final Db_batch__journal_off__conn_bgn Instance = new Db_batch__journal_off__conn_bgn(); Db_batch__journal_off__conn_bgn() {}
|
||||
}
|
||||
class Db_batch__journal_off__conn_end implements Db_batch_itm {
|
||||
public String Key() {return KEY;} public static final String KEY = "journal_off.conn_end";
|
||||
@@ -42,5 +42,5 @@ class Db_batch__journal_off__conn_end implements Db_batch_itm {
|
||||
engine.Exec_as_obj(Sqlite_pragma.New__synchronous__full());
|
||||
engine.Props().Del(Sqlite_pragma.Const__journal_mode);
|
||||
}
|
||||
public static final Db_batch__journal_off__conn_end Instance = new Db_batch__journal_off__conn_end(); Db_batch__journal_off__conn_end() {}
|
||||
public static final Db_batch__journal_off__conn_end Instance = new Db_batch__journal_off__conn_end(); Db_batch__journal_off__conn_end() {}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.qrys.bats; import gplx.*; import gplx.dbs.*; import gplx.dbs.qrys.*;
|
||||
import gplx.dbs.engines.*; import gplx.dbs.engines.sqlite.*;
|
||||
public class Db_batch__journal_wal {
|
||||
@@ -37,7 +37,7 @@ class Db_batch__journal_wal__conn_bgn implements Db_batch_itm {
|
||||
engine.Exec_as_obj(Sqlite_pragma.New__synchronous__normal());
|
||||
engine.Exec_as_obj(Sqlite_pragma.New__wal_autocheckpoint(0));
|
||||
}
|
||||
public static final Db_batch__journal_wal__conn_bgn Instance = new Db_batch__journal_wal__conn_bgn(); Db_batch__journal_wal__conn_bgn() {}
|
||||
public static final Db_batch__journal_wal__conn_bgn Instance = new Db_batch__journal_wal__conn_bgn(); Db_batch__journal_wal__conn_bgn() {}
|
||||
}
|
||||
class Db_batch__journal_wal__conn_end implements Db_batch_itm {
|
||||
public String Key() {return KEY;} public static final String KEY = "journal_wal.conn_end";
|
||||
@@ -48,7 +48,7 @@ class Db_batch__journal_wal__conn_end implements Db_batch_itm {
|
||||
engine.Exec_as_obj(Sqlite_pragma.New__synchronous__full());
|
||||
engine.Props().Del(Sqlite_pragma.Const__journal_mode);
|
||||
}
|
||||
public static final Db_batch__journal_wal__conn_end Instance = new Db_batch__journal_wal__conn_end(); Db_batch__journal_wal__conn_end() {}
|
||||
public static final Db_batch__journal_wal__conn_end Instance = new Db_batch__journal_wal__conn_end(); Db_batch__journal_wal__conn_end() {}
|
||||
}
|
||||
class Db_batch__journal_wal__txn_end implements Db_batch_itm {
|
||||
public String Key() {return KEY;} public static final String KEY = "journal_wal.txn_end";
|
||||
@@ -56,5 +56,5 @@ class Db_batch__journal_wal__txn_end implements Db_batch_itm {
|
||||
if (!engine.Props().Match(Sqlite_pragma.Const__journal_mode, Sqlite_pragma.Const__journal_mode__wal)) return; // if in off mode, don't enable wal
|
||||
engine.Exec_as_obj(Sqlite_pragma.New__wal_checkpoint__truncate());
|
||||
}
|
||||
public static final Db_batch__journal_wal__txn_end Instance = new Db_batch__journal_wal__txn_end(); Db_batch__journal_wal__txn_end() {}
|
||||
public static final Db_batch__journal_wal__txn_end Instance = new Db_batch__journal_wal__txn_end(); Db_batch__journal_wal__txn_end() {}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.qrys.bats; import gplx.*; import gplx.dbs.*; import gplx.dbs.qrys.*;
|
||||
import gplx.dbs.engines.*;
|
||||
public class Db_batch_grp {
|
||||
public final Ordered_hash hash = Ordered_hash_.New();
|
||||
public final Ordered_hash hash = Ordered_hash_.New();
|
||||
public Db_batch_grp(byte tid) {this.tid = tid;}
|
||||
public byte Tid() {return tid;} private final byte tid;
|
||||
public byte Tid() {return tid;} private final byte tid;
|
||||
public int Len() {return hash.Len();}
|
||||
public Db_batch_itm Get_at(int idx) {return (Db_batch_itm)hash.Get_at(idx); }
|
||||
public void Add(Db_batch_itm itm) {hash.Add(itm.Key(), itm);}
|
||||
|
||||
@@ -13,14 +13,14 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.qrys.bats; import gplx.*; import gplx.dbs.*; import gplx.dbs.qrys.*;
|
||||
public class Db_batch_mgr {
|
||||
public Db_batch_grp Conn_bgn() {return conn_bgn;} private final Db_batch_grp conn_bgn = new Db_batch_grp(Db_batch_grp.Tid__conn_bgn);
|
||||
public Db_batch_grp Conn_end() {return conn_end;} private final Db_batch_grp conn_end = new Db_batch_grp(Db_batch_grp.Tid__conn_end);
|
||||
public Db_batch_grp Txn_end () {return txn_end;} private final Db_batch_grp txn_end = new Db_batch_grp(Db_batch_grp.Tid__txn_end);
|
||||
public void Copy(String src_tid, Db_batch_mgr src) {
|
||||
conn_bgn.Copy(src.conn_bgn);
|
||||
conn_end.Copy(src.conn_end);
|
||||
txn_end.Copy(src.txn_end);
|
||||
}
|
||||
}
|
||||
package gplx.dbs.qrys.bats; import gplx.*; import gplx.dbs.*; import gplx.dbs.qrys.*;
|
||||
public class Db_batch_mgr {
|
||||
public Db_batch_grp Conn_bgn() {return conn_bgn;} private final Db_batch_grp conn_bgn = new Db_batch_grp(Db_batch_grp.Tid__conn_bgn);
|
||||
public Db_batch_grp Conn_end() {return conn_end;} private final Db_batch_grp conn_end = new Db_batch_grp(Db_batch_grp.Tid__conn_end);
|
||||
public Db_batch_grp Txn_end () {return txn_end;} private final Db_batch_grp txn_end = new Db_batch_grp(Db_batch_grp.Tid__txn_end);
|
||||
public void Copy(String src_tid, Db_batch_mgr src) {
|
||||
conn_bgn.Copy(src.conn_bgn);
|
||||
conn_end.Copy(src.conn_end);
|
||||
txn_end.Copy(src.txn_end);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,9 +13,10 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.sqls; import gplx.*; import gplx.dbs.*;
|
||||
import gplx.dbs.sqls.wtrs.*;
|
||||
public interface Sql_qry_wtr {
|
||||
String To_sql_str(Db_qry qry, boolean mode_is_prep);
|
||||
Sql_schema_wtr Schema_wtr();
|
||||
}
|
||||
package gplx.dbs.sqls;
|
||||
import gplx.dbs.Db_qry;
|
||||
import gplx.dbs.sqls.wtrs.Sql_schema_wtr;
|
||||
public interface SqlQryWtr {
|
||||
String ToSqlStr(Db_qry qry, boolean mode_is_prep);
|
||||
Sql_schema_wtr Schema_wtr();
|
||||
}
|
||||
@@ -13,15 +13,19 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.sqls; import gplx.*; import gplx.dbs.*;
|
||||
import gplx.dbs.sqls.wtrs.*;
|
||||
public class Sql_qry_wtr_ {
|
||||
public static Sql_qry_wtr New__basic() {return new Sql_core_wtr();}
|
||||
public static Sql_qry_wtr New__mysql() {return new Sql_core_wtr__mysql();}
|
||||
public static Sql_qry_wtr New__sqlite() {return new Sql_core_wtr__sqlite();}
|
||||
|
||||
public static final byte Like_wildcard = Byte_ascii.Percent;
|
||||
public static String Quote_arg(String s) { // only for constructing DEBUG SQL strings
|
||||
return "'" + String_.Replace(s, "'", "''") + "'";
|
||||
}
|
||||
}
|
||||
package gplx.dbs.sqls;
|
||||
import gplx.Byte_ascii;
|
||||
import gplx.String_;
|
||||
import gplx.dbs.sqls.wtrs.Sql_core_wtr;
|
||||
import gplx.dbs.sqls.wtrs.Sql_core_wtr__mysql;
|
||||
import gplx.dbs.sqls.wtrs.Sql_core_wtr__sqlite;
|
||||
public class SqlQryWtrUtl {
|
||||
public static SqlQryWtr NewBasic() {return new Sql_core_wtr();}
|
||||
public static SqlQryWtr NewMysql() {return new Sql_core_wtr__mysql();}
|
||||
public static SqlQryWtr NewSqlite() {return new Sql_core_wtr__sqlite();}
|
||||
|
||||
public static final byte Like_wildcard = Byte_ascii.Percent;
|
||||
public static String QuoteArg(String s) { // only for constructing DEBUG SQL strings
|
||||
return "'" + String_.Replace(s, "'", "''") + "'";
|
||||
}
|
||||
}
|
||||
@@ -13,8 +13,9 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.sqls.itms; import gplx.*; import gplx.dbs.*; import gplx.dbs.sqls.*;
|
||||
import org.junit.*; import gplx.core.strings.*; import gplx.dbs.sqls.*;
|
||||
package gplx.dbs.sqls.itms; import gplx.*;
|
||||
import gplx.dbs.sqls.*;
|
||||
import org.junit.*;
|
||||
import gplx.dbs.sqls.wtrs.*;
|
||||
public class Db_obj_ary_tst {
|
||||
@Before public void init() {} private Db_obj_ary_fxt fxt = new Db_obj_ary_fxt();
|
||||
@@ -26,12 +27,12 @@ public class Db_obj_ary_tst {
|
||||
}
|
||||
}
|
||||
class Db_obj_ary_fxt {
|
||||
private final Db_obj_ary_crt crt = new Db_obj_ary_crt();
|
||||
private final Sql_wtr_ctx ctx = new Sql_wtr_ctx(false);
|
||||
private final Db_obj_ary_crt crt = new Db_obj_ary_crt();
|
||||
private final Sql_wtr_ctx ctx = new Sql_wtr_ctx(false);
|
||||
public Db_obj_ary_fxt Init_fld(String name, int tid) {flds_list.Add(new Db_obj_ary_fld(name, tid)); return this;} private List_adp flds_list = List_adp_.New();
|
||||
public Db_obj_ary_fxt Init_vals(Object... ary) {vals_list.Add(ary); return this;} private List_adp vals_list = List_adp_.New();
|
||||
public Db_obj_ary_fxt Test_sql(String expd) {
|
||||
Sql_core_wtr cmd_wtr = (Sql_core_wtr)Sql_qry_wtr_.New__basic();
|
||||
Sql_core_wtr cmd_wtr = (Sql_core_wtr)SqlQryWtrUtl.NewBasic();
|
||||
crt.Flds_((Db_obj_ary_fld[])flds_list.To_ary_and_clear(Db_obj_ary_fld.class));
|
||||
crt.Vals_((Object[][])vals_list.To_ary_and_clear(Object[].class));
|
||||
Bry_bfr bfr = Bry_bfr_.New();
|
||||
|
||||
@@ -13,12 +13,12 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.sqls.itms; import gplx.*; import gplx.dbs.*; import gplx.dbs.sqls.*;
|
||||
public class Sql_from_clause {
|
||||
public Sql_from_clause(Sql_tbl_itm base_tbl) {
|
||||
this.Base_tbl = base_tbl;
|
||||
Tbls.Add(base_tbl);
|
||||
}
|
||||
public final List_adp Tbls = List_adp_.New();
|
||||
public final Sql_tbl_itm Base_tbl;
|
||||
}
|
||||
package gplx.dbs.sqls.itms; import gplx.*; import gplx.dbs.*; import gplx.dbs.sqls.*;
|
||||
public class Sql_from_clause {
|
||||
public Sql_from_clause(Sql_tbl_itm base_tbl) {
|
||||
this.Base_tbl = base_tbl;
|
||||
Tbls.Add(base_tbl);
|
||||
}
|
||||
public final List_adp Tbls = List_adp_.New();
|
||||
public final Sql_tbl_itm Base_tbl;
|
||||
}
|
||||
|
||||
@@ -13,13 +13,13 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.sqls.itms; import gplx.*; import gplx.dbs.*; import gplx.dbs.sqls.*;
|
||||
public class Sql_order_clause {
|
||||
private final List_adp list = List_adp_.New();
|
||||
private Sql_order_fld[] ary;
|
||||
public void Flds__add(Sql_order_fld fld) {list.Add(fld);}
|
||||
public Sql_order_fld[] Flds() {
|
||||
if (ary == null) ary = (Sql_order_fld[])list.To_ary_and_clear(Sql_order_fld.class);
|
||||
return ary;
|
||||
}
|
||||
}
|
||||
package gplx.dbs.sqls.itms; import gplx.*; import gplx.dbs.*; import gplx.dbs.sqls.*;
|
||||
public class Sql_order_clause {
|
||||
private final List_adp list = List_adp_.New();
|
||||
private Sql_order_fld[] ary;
|
||||
public void Flds__add(Sql_order_fld fld) {list.Add(fld);}
|
||||
public Sql_order_fld[] Flds() {
|
||||
if (ary == null) ary = (Sql_order_fld[])list.To_ary_and_clear(Sql_order_fld.class);
|
||||
return ary;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.sqls.itms; import gplx.*; import gplx.dbs.*; import gplx.dbs.sqls.*;
|
||||
public class Sql_order_fld {
|
||||
public Sql_order_fld(String tbl, String name, byte sort) {this.Tbl = tbl; this.Name = name; this.Sort = sort;}
|
||||
public final String Tbl;
|
||||
public final String Name;
|
||||
public final byte Sort;
|
||||
public final String Tbl;
|
||||
public final String Name;
|
||||
public final byte Sort;
|
||||
public String To_sql() {
|
||||
String rv = this.Name;
|
||||
if (Tbl != null) rv = Tbl + "." + rv;
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.sqls.itms; import gplx.*; import gplx.dbs.*; import gplx.dbs.sqls.*;
|
||||
import gplx.core.gfo_ndes.*; import gplx.core.type_xtns.*;
|
||||
public abstract class Sql_select_fld {
|
||||
@@ -38,7 +38,7 @@ public abstract class Sql_select_fld {
|
||||
// tdb related functions
|
||||
public ClassXtn Val_type() {return val_type;} public void Val_type_(ClassXtn val) {val_type = val;} private ClassXtn val_type = ObjectClassXtn.Instance;
|
||||
public abstract Object GroupBy_eval(Object groupByVal, Object curVal, ClassXtn type);
|
||||
@gplx.Virtual public void GroupBy_type(ClassXtn type) {this.Val_type_(type);}
|
||||
public void GroupBy_type(ClassXtn type) {this.Val_type_(type);}
|
||||
}
|
||||
class Sql_select_fld_wild extends Sql_select_fld { Sql_select_fld_wild() {super(Sql_select_fld.Tbl__null, Fld__wildcard, Fld__wildcard);}
|
||||
@Override public String To_fld_sql() {return Fld__wildcard;}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.sqls.itms; import gplx.*; import gplx.dbs.*; import gplx.dbs.sqls.*;
|
||||
import gplx.core.type_xtns.*;
|
||||
abstract class Sql_select_fld_func extends Sql_select_fld { public Sql_select_fld_func(String tbl, String fld, String alias) {super(tbl, fld, alias);}
|
||||
@@ -37,7 +37,7 @@ class Sql_select_fld_sum extends Sql_select_fld_func { public Sql_select_fld_s
|
||||
return Int_.Cast(groupByVal) + Int_.Cast(curVal);
|
||||
}
|
||||
}
|
||||
class Sql_select_fld_minMax extends Sql_select_fld_func { private final int compareType;
|
||||
class Sql_select_fld_minMax extends Sql_select_fld_func { private final int compareType;
|
||||
public Sql_select_fld_minMax(int compareType, String tbl, String fld, String alias) {super(tbl, fld, alias);
|
||||
this.compareType = compareType;
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.sqls.itms; import gplx.*; import gplx.dbs.*; import gplx.dbs.sqls.*;
|
||||
public class Sql_tbl_itm {
|
||||
public Sql_tbl_itm(int join_tid, String db, String name, String alias, Sql_join_fld[] join_flds) {
|
||||
@@ -22,12 +22,12 @@ public class Sql_tbl_itm {
|
||||
this.Alias = alias;
|
||||
this.Join_flds = join_flds;
|
||||
}
|
||||
public final int Join_tid;
|
||||
public final String Db;
|
||||
public final String Name;
|
||||
public final String Alias;
|
||||
public final int Join_tid;
|
||||
public final String Db;
|
||||
public final String Name;
|
||||
public final String Alias;
|
||||
public boolean Db_enabled = true;
|
||||
public final Sql_join_fld[] Join_flds;
|
||||
public final Sql_join_fld[] Join_flds;
|
||||
|
||||
public static final String Alias__null = null;
|
||||
public static final String Db__null = null;
|
||||
|
||||
@@ -13,91 +13,105 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.sqls.wtrs; import gplx.*; import gplx.dbs.*; import gplx.dbs.sqls.*;
|
||||
import gplx.core.criterias.*; import gplx.dbs.qrys.*; import gplx.dbs.sqls.wtrs.*; import gplx.dbs.sqls.itms.*;
|
||||
public class Sql_core_wtr implements Sql_qry_wtr {
|
||||
private final Bry_bfr bfr = Bry_bfr_.New_w_size(64);
|
||||
public byte[] Seq__nl = Byte_ascii.Space_bry;
|
||||
public byte Seq__quote = Byte_ascii.Apos, Seq__escape = Byte_ascii.Backslash;
|
||||
public Sql_core_wtr() {
|
||||
this.val_wtr = Make__val_wtr();
|
||||
this.from_wtr = Make__from_wtr();
|
||||
this.where_wtr = Make__where_wtr(this, val_wtr);
|
||||
this.select_wtr = Make__select_wtr(this);
|
||||
this.schema_wtr = Make__schema_wtr();
|
||||
}
|
||||
public Sql_schema_wtr Schema_wtr() {return schema_wtr;} private final Sql_schema_wtr schema_wtr;
|
||||
public Sql_val_wtr Val_wtr() {return val_wtr;} private final Sql_val_wtr val_wtr;
|
||||
public Sql_from_wtr From_wtr() {return from_wtr;} private final Sql_from_wtr from_wtr;
|
||||
public Sql_where_wtr Where_wtr() {return where_wtr;} private final Sql_where_wtr where_wtr;
|
||||
public Sql_select_wtr Select_wtr() {return select_wtr;} private final Sql_select_wtr select_wtr;
|
||||
public String To_sql_str(Db_qry qry, boolean mode_is_prep) {
|
||||
synchronized (bfr) {
|
||||
Sql_wtr_ctx ctx = new Sql_wtr_ctx(mode_is_prep);
|
||||
switch (qry.Tid()) {
|
||||
case Db_qry_.Tid_insert: return Bld_qry_insert(ctx, (Db_qry_insert)qry);
|
||||
case Db_qry_.Tid_delete: return Bld_qry_delete(ctx, (Db_qry_delete)qry);
|
||||
case Db_qry_.Tid_update: return Bld_qry_update(ctx, (Db_qry_update)qry);
|
||||
case Db_qry_.Tid_select_in_tbl:
|
||||
case Db_qry_.Tid_select: select_wtr.Bld_qry_select(bfr, ctx, (Db_qry__select_cmd)qry); return bfr.To_str_and_clear();
|
||||
case Db_qry_.Tid_pragma: return ((gplx.dbs.engines.sqlite.Sqlite_pragma)qry).To_sql__exec(this);
|
||||
case Db_qry_.Tid_sql: return ((Db_qry_sql)qry).To_sql__exec(this);
|
||||
default: throw Err_.new_unhandled(qry.Tid());
|
||||
}
|
||||
}
|
||||
}
|
||||
private String Bld_qry_delete(Sql_wtr_ctx ctx, Db_qry_delete qry) {
|
||||
bfr.Add_str_u8_many("DELETE FROM ", qry.Base_table());
|
||||
where_wtr.Bld_where(bfr, ctx, qry.Where());
|
||||
return bfr.To_str_and_clear();
|
||||
}
|
||||
private String Bld_qry_insert(Sql_wtr_ctx ctx, Db_qry_insert qry) {
|
||||
if (qry.Select() != null) {
|
||||
bfr.Add_str_u8_many("INSERT INTO ", qry.Base_table(), " (");
|
||||
int cols_len = qry.Cols().Len();
|
||||
for (int i = 0; i < cols_len; i++) {
|
||||
Sql_select_fld fld = qry.Cols().Get_at(i);
|
||||
bfr.Add_str_a7(fld.Alias);
|
||||
bfr.Add_str_a7(i == cols_len - 1 ? ") " : ", ");
|
||||
}
|
||||
select_wtr.Bld_qry_select(bfr, ctx, qry.Select());
|
||||
return bfr.To_str_and_clear();
|
||||
}
|
||||
int arg_count = qry.Args().Count(); if (arg_count == 0) throw Err_.new_wo_type("Db_qry_insert has no columns", "base_table", qry.Base_table());
|
||||
int last = arg_count - 1;
|
||||
bfr.Add_str_u8_many("INSERT INTO ", qry.Base_table(), " (");
|
||||
for (int i = 0; i < arg_count; i++) {
|
||||
Keyval pair = qry.Args().Get_at(i);
|
||||
this.Bld_col_name(bfr, pair.Key());
|
||||
bfr.Add_str_a7(i == last ? ")" : ", ");
|
||||
}
|
||||
bfr.Add_str_a7(" VALUES (");
|
||||
for (int i = 0; i < arg_count; i++) {
|
||||
Keyval pair = qry.Args().Get_at(i);
|
||||
Db_arg arg = (Db_arg)pair.Val();
|
||||
val_wtr.Bld_val(bfr, ctx, arg.Val);
|
||||
bfr.Add_str_a7(i == last ? ")" : ", ");
|
||||
}
|
||||
return bfr.To_str_and_clear();
|
||||
}
|
||||
private String Bld_qry_update(Sql_wtr_ctx ctx, Db_qry_update qry) {
|
||||
int arg_count = qry.Args().Count(); if (arg_count == 0) throw Err_.new_wo_type("Db_qry_update has no columns", "base_table", qry.Base_table());
|
||||
bfr.Add_str_u8_many("UPDATE ", qry.Base_table(), " SET ");
|
||||
for (int i = 0; i < arg_count; i++) {
|
||||
Keyval pair = qry.Args().Get_at(i);
|
||||
if (i > 0) bfr.Add_str_a7(", ");
|
||||
this.Bld_col_name(bfr, pair.Key());
|
||||
bfr.Add_str_a7("=");
|
||||
Db_arg arg = (Db_arg)pair.Val();
|
||||
val_wtr.Bld_val(bfr, ctx, arg.Val);
|
||||
}
|
||||
where_wtr.Bld_where(bfr, ctx, qry.Where());
|
||||
return bfr.To_str_and_clear();
|
||||
}
|
||||
public void Bld_col_name(Bry_bfr bfr, String key) {bfr.Add_str_u8(key);}
|
||||
@gplx.Virtual protected Sql_val_wtr Make__val_wtr () {return new Sql_val_wtr();}
|
||||
@gplx.Virtual protected Sql_from_wtr Make__from_wtr () {return new Sql_from_wtr();}
|
||||
@gplx.Virtual protected Sql_select_wtr Make__select_wtr(Sql_core_wtr qry_wtr) {return new Sql_select_wtr(qry_wtr);}
|
||||
@gplx.Virtual protected Sql_where_wtr Make__where_wtr (Sql_core_wtr qry_wtr, Sql_val_wtr val_wtr) {return new Sql_where_wtr(qry_wtr, val_wtr);}
|
||||
@gplx.Virtual protected Sql_schema_wtr Make__schema_wtr() {return new Sql_schema_wtr();}
|
||||
}
|
||||
package gplx.dbs.sqls.wtrs;
|
||||
import gplx.Bry_bfr;
|
||||
import gplx.Bry_bfr_;
|
||||
import gplx.Byte_ascii;
|
||||
import gplx.Err_;
|
||||
import gplx.Keyval;
|
||||
import gplx.dbs.Db_qry;
|
||||
import gplx.dbs.Db_qry_;
|
||||
import gplx.dbs.qrys.Db_arg;
|
||||
import gplx.dbs.qrys.Db_qry__select_cmd;
|
||||
import gplx.dbs.qrys.Db_qry_delete;
|
||||
import gplx.dbs.qrys.Db_qry_insert;
|
||||
import gplx.dbs.qrys.Db_qry_sql;
|
||||
import gplx.dbs.qrys.Db_qry_update;
|
||||
import gplx.dbs.sqls.SqlQryWtr;
|
||||
import gplx.dbs.sqls.itms.Sql_select_fld;
|
||||
public class Sql_core_wtr implements SqlQryWtr {
|
||||
private final Bry_bfr bfr = Bry_bfr_.New_w_size(64);
|
||||
public byte[] Seq__nl = Byte_ascii.Space_bry;
|
||||
public byte Seq__quote = Byte_ascii.Apos, Seq__escape = Byte_ascii.Backslash;
|
||||
public Sql_core_wtr() {
|
||||
this.val_wtr = Make__val_wtr();
|
||||
this.from_wtr = Make__from_wtr();
|
||||
this.where_wtr = Make__where_wtr(this, val_wtr);
|
||||
this.select_wtr = Make__select_wtr(this);
|
||||
this.schema_wtr = Make__schema_wtr();
|
||||
}
|
||||
public Sql_schema_wtr Schema_wtr() {return schema_wtr;} private final Sql_schema_wtr schema_wtr;
|
||||
public Sql_val_wtr Val_wtr() {return val_wtr;} private final Sql_val_wtr val_wtr;
|
||||
public Sql_from_wtr From_wtr() {return from_wtr;} private final Sql_from_wtr from_wtr;
|
||||
public Sql_where_wtr Where_wtr() {return where_wtr;} private final Sql_where_wtr where_wtr;
|
||||
public Sql_select_wtr Select_wtr() {return select_wtr;} private final Sql_select_wtr select_wtr;
|
||||
public String ToSqlStr(Db_qry qry, boolean mode_is_prep) {
|
||||
synchronized (bfr) {
|
||||
Sql_wtr_ctx ctx = new Sql_wtr_ctx(mode_is_prep);
|
||||
switch (qry.Tid()) {
|
||||
case Db_qry_.Tid_insert: return Bld_qry_insert(ctx, (Db_qry_insert)qry);
|
||||
case Db_qry_.Tid_delete: return Bld_qry_delete(ctx, (Db_qry_delete)qry);
|
||||
case Db_qry_.Tid_update: return Bld_qry_update(ctx, (Db_qry_update)qry);
|
||||
case Db_qry_.Tid_select_in_tbl:
|
||||
case Db_qry_.Tid_select: select_wtr.Bld_qry_select(bfr, ctx, (Db_qry__select_cmd)qry); return bfr.To_str_and_clear();
|
||||
case Db_qry_.Tid_pragma: return ((gplx.dbs.engines.sqlite.Sqlite_pragma)qry).To_sql__exec(this);
|
||||
case Db_qry_.Tid_sql: return ((Db_qry_sql)qry).To_sql__exec(this);
|
||||
default: throw Err_.new_unhandled(qry.Tid());
|
||||
}
|
||||
}
|
||||
}
|
||||
private String Bld_qry_delete(Sql_wtr_ctx ctx, Db_qry_delete qry) {
|
||||
bfr.Add_str_u8_many("DELETE FROM ", qry.Base_table());
|
||||
where_wtr.Bld_where(bfr, ctx, qry.Where());
|
||||
return bfr.To_str_and_clear();
|
||||
}
|
||||
private String Bld_qry_insert(Sql_wtr_ctx ctx, Db_qry_insert qry) {
|
||||
if (qry.Select() != null) {
|
||||
bfr.Add_str_u8_many("INSERT INTO ", qry.Base_table(), " (");
|
||||
int cols_len = qry.Cols().Len();
|
||||
for (int i = 0; i < cols_len; i++) {
|
||||
Sql_select_fld fld = qry.Cols().Get_at(i);
|
||||
bfr.Add_str_a7(fld.Alias);
|
||||
bfr.Add_str_a7(i == cols_len - 1 ? ") " : ", ");
|
||||
}
|
||||
select_wtr.Bld_qry_select(bfr, ctx, qry.Select());
|
||||
return bfr.To_str_and_clear();
|
||||
}
|
||||
int arg_count = qry.Args().Count(); if (arg_count == 0) throw Err_.new_wo_type("Db_qry_insert has no columns", "base_table", qry.Base_table());
|
||||
int last = arg_count - 1;
|
||||
bfr.Add_str_u8_many("INSERT INTO ", qry.Base_table(), " (");
|
||||
for (int i = 0; i < arg_count; i++) {
|
||||
Keyval pair = qry.Args().Get_at(i);
|
||||
this.Bld_col_name(bfr, pair.Key());
|
||||
bfr.Add_str_a7(i == last ? ")" : ", ");
|
||||
}
|
||||
bfr.Add_str_a7(" VALUES (");
|
||||
for (int i = 0; i < arg_count; i++) {
|
||||
Keyval pair = qry.Args().Get_at(i);
|
||||
Db_arg arg = (Db_arg)pair.Val();
|
||||
val_wtr.Bld_val(bfr, ctx, arg.Val);
|
||||
bfr.Add_str_a7(i == last ? ")" : ", ");
|
||||
}
|
||||
return bfr.To_str_and_clear();
|
||||
}
|
||||
private String Bld_qry_update(Sql_wtr_ctx ctx, Db_qry_update qry) {
|
||||
int arg_count = qry.Args().Count(); if (arg_count == 0) throw Err_.new_wo_type("Db_qry_update has no columns", "base_table", qry.Base_table());
|
||||
bfr.Add_str_u8_many("UPDATE ", qry.Base_table(), " SET ");
|
||||
for (int i = 0; i < arg_count; i++) {
|
||||
Keyval pair = qry.Args().Get_at(i);
|
||||
if (i > 0) bfr.Add_str_a7(", ");
|
||||
this.Bld_col_name(bfr, pair.Key());
|
||||
bfr.Add_str_a7("=");
|
||||
Db_arg arg = (Db_arg)pair.Val();
|
||||
val_wtr.Bld_val(bfr, ctx, arg.Val);
|
||||
}
|
||||
where_wtr.Bld_where(bfr, ctx, qry.Where());
|
||||
return bfr.To_str_and_clear();
|
||||
}
|
||||
public void Bld_col_name(Bry_bfr bfr, String key) {bfr.Add_str_u8(key);}
|
||||
protected Sql_val_wtr Make__val_wtr() {return new Sql_val_wtr();}
|
||||
protected Sql_from_wtr Make__from_wtr() {return new Sql_from_wtr();}
|
||||
protected Sql_select_wtr Make__select_wtr(Sql_core_wtr qry_wtr) {return new Sql_select_wtr(qry_wtr);}
|
||||
protected Sql_where_wtr Make__where_wtr(Sql_core_wtr qry_wtr, Sql_val_wtr val_wtr) {return new Sql_where_wtr(qry_wtr, val_wtr);}
|
||||
protected Sql_schema_wtr Make__schema_wtr() {return new Sql_schema_wtr();}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,8 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.sqls.wtrs; import gplx.*; import gplx.dbs.*; import gplx.dbs.sqls.*;
|
||||
public class Sql_core_wtr__sqlite extends Sql_core_wtr { @Override protected Sql_val_wtr Make__val_wtr() {return new Sql_val_wtr_sqlite();}
|
||||
@Override protected Sql_select_wtr Make__select_wtr(Sql_core_wtr qry_wtr) {return new Sql_select_wtr_sqlite(qry_wtr);}
|
||||
}
|
||||
package gplx.dbs.sqls.wtrs;
|
||||
public class Sql_core_wtr__sqlite extends Sql_core_wtr {
|
||||
@Override protected Sql_val_wtr Make__val_wtr() {return new Sql_val_wtr_sqlite();}
|
||||
@Override protected Sql_select_wtr Make__select_wtr(Sql_core_wtr qry_wtr) {return new Sql_select_wtr_sqlite(qry_wtr);}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,31 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.sqls.wtrs; import gplx.*; import gplx.dbs.*; import gplx.dbs.sqls.*;
|
||||
import gplx.dbs.metas.*;
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.sqls.wtrs; import gplx.Bool_;
|
||||
import gplx.Bry_bfr;
|
||||
import gplx.Bry_bfr_;
|
||||
import gplx.Byte_ascii;
|
||||
import gplx.Err_;
|
||||
import gplx.Object_;
|
||||
import gplx.String_;
|
||||
import gplx.dbs.Dbmeta_fld_itm;
|
||||
import gplx.dbs.Dbmeta_fld_tid;
|
||||
import gplx.dbs.Dbmeta_idx_itm;
|
||||
import gplx.dbs.Dbmeta_tbl_itm;
|
||||
import gplx.dbs.metas.Dbmeta_fld_mgr;
|
||||
import gplx.dbs.metas.Dbmeta_idx_fld;
|
||||
public class Sql_schema_wtr {
|
||||
private Bry_bfr tmp_bfr = Bry_bfr_.Reset(255);
|
||||
public Sql_schema_wtr Bfr_(Bry_bfr bfr) {this.tmp_bfr = bfr; return this;}
|
||||
@@ -99,5 +110,5 @@ public class Sql_schema_wtr {
|
||||
default: throw Err_.new_unhandled(tid);
|
||||
}
|
||||
}
|
||||
// public static final Sql_schema_wtr Instance = new Sql_schema_wtr();
|
||||
// public static final Sql_schema_wtr Instance = new Sql_schema_wtr();
|
||||
}
|
||||
|
||||
@@ -1,20 +1,25 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.sqls.wtrs; import gplx.*; import gplx.dbs.*; import gplx.dbs.sqls.*;
|
||||
import gplx.dbs.qrys.*; import gplx.dbs.sqls.itms.*;
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.sqls.wtrs; import gplx.Bry_bfr;
|
||||
import gplx.dbs.qrys.Db_qry__select_cmd;
|
||||
import gplx.dbs.sqls.itms.Sql_group_clause;
|
||||
import gplx.dbs.sqls.itms.Sql_order_clause;
|
||||
import gplx.dbs.sqls.itms.Sql_order_fld;
|
||||
import gplx.dbs.sqls.itms.Sql_select_fld;
|
||||
import gplx.dbs.sqls.itms.Sql_select_fld_list;
|
||||
public class Sql_select_wtr {
|
||||
private final Sql_core_wtr qry_wtr;
|
||||
public Sql_select_wtr(Sql_core_wtr qry_wtr) {this.qry_wtr = qry_wtr;}
|
||||
@@ -61,7 +66,7 @@ public class Sql_select_wtr {
|
||||
if (limit == Db_qry__select_cmd.Limit__disabled) return;
|
||||
bfr.Add_str_a7(" LIMIT ").Add_int_variable(limit);
|
||||
}
|
||||
@gplx.Virtual protected void Bld_offset(Bry_bfr bfr, Sql_wtr_ctx ctx, Db_qry__select_cmd qry, int offset) {
|
||||
protected void Bld_offset(Bry_bfr bfr, Sql_wtr_ctx ctx, Db_qry__select_cmd qry, int offset) {
|
||||
bfr.Add_str_a7(" OFFSET ").Add_int_variable(offset);
|
||||
}
|
||||
private void Bld_indexed_by(Bry_bfr bfr, Sql_wtr_ctx ctx, Db_qry__select_cmd qry, String idx_name) {
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.sqls.wtrs; import gplx.*; import gplx.dbs.*; import gplx.dbs.sqls.*;
|
||||
public class Sql_val_wtr {
|
||||
// private final Bry_bfr tmp_bfr = Bry_bfr_.New(32);
|
||||
// private final Bry_bfr tmp_bfr = Bry_bfr_.New(32);
|
||||
public byte Seq__quote = Byte_ascii.Apos, Seq__escape = Byte_ascii.Backslash;
|
||||
public void Bld_val(Bry_bfr bfr, Sql_wtr_ctx ctx, Object val) {
|
||||
if (ctx.Mode_is_prep) {
|
||||
@@ -41,16 +41,16 @@ public class Sql_val_wtr {
|
||||
case Type_ids_.Id__obj: Bld_val__str (bfr, Object_.Xto_str_strict_or_null(val)); break;
|
||||
}
|
||||
}
|
||||
@gplx.Virtual public void Bld_val__bool (Bry_bfr bfr, boolean val) {bfr.Add_int_digits(1, val ? 1 : 0);} // NOTE: save boolean to 0 or 1 b/c sqlite doesn't support true / false //{bfr.Add_str_a7(val ? "true" : "false");}
|
||||
@gplx.Virtual public void Bld_val__byte (Bry_bfr bfr, byte val) {bfr.Add_byte_variable(val);}
|
||||
@gplx.Virtual public void Bld_val__short (Bry_bfr bfr, short val) {bfr.Add_short_variable(val);}
|
||||
@gplx.Virtual public void Bld_val__int (Bry_bfr bfr, int val) {bfr.Add_int_variable(val);}
|
||||
@gplx.Virtual public void Bld_val__long (Bry_bfr bfr, long val) {bfr.Add_long_variable(val);}
|
||||
@gplx.Virtual public void Bld_val__float (Bry_bfr bfr, float val) {bfr.Add_float(val);}
|
||||
@gplx.Virtual public void Bld_val__double (Bry_bfr bfr, double val) {bfr.Add_double(val);}
|
||||
@gplx.Virtual public void Bld_val__date (Bry_bfr bfr, DateAdp val) {bfr.Add_str_u8_many("'", val.XtoStr_gplx_long(), "'");}
|
||||
@gplx.Virtual public void Bld_val__decimal (Bry_bfr bfr, Decimal_adp val) {bfr.Add_str_u8_many("'", val.To_str(), "'");}
|
||||
@gplx.Virtual public void Bld_val__str (Bry_bfr bfr, String val) {
|
||||
public void Bld_val__bool (Bry_bfr bfr, boolean val) {bfr.Add_int_digits(1, val ? 1 : 0);} // NOTE: save boolean to 0 or 1 b/c sqlite doesn't support true / false //{bfr.Add_str_a7(val ? "true" : "false");}
|
||||
public void Bld_val__byte (Bry_bfr bfr, byte val) {bfr.Add_byte_variable(val);}
|
||||
public void Bld_val__short (Bry_bfr bfr, short val) {bfr.Add_short_variable(val);}
|
||||
public void Bld_val__int (Bry_bfr bfr, int val) {bfr.Add_int_variable(val);}
|
||||
public void Bld_val__long (Bry_bfr bfr, long val) {bfr.Add_long_variable(val);}
|
||||
public void Bld_val__float (Bry_bfr bfr, float val) {bfr.Add_float(val);}
|
||||
public void Bld_val__double (Bry_bfr bfr, double val) {bfr.Add_double(val);}
|
||||
public void Bld_val__date (Bry_bfr bfr, DateAdp val) {bfr.Add_str_u8_many("'", val.XtoStr_gplx_long(), "'");}
|
||||
public void Bld_val__decimal (Bry_bfr bfr, Decimal_adp val) {bfr.Add_str_u8_many("'", val.To_str(), "'");}
|
||||
public void Bld_val__str (Bry_bfr bfr, String val) {
|
||||
// byte[] bry = Bry_.new_u8(val); int len = bry.length; int pos = 0; int prv = -1; boolean dirty = false;
|
||||
// while (true) {
|
||||
// if (pos == len) break;
|
||||
|
||||
@@ -1,23 +1,41 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.sqls.wtrs; import gplx.*; import gplx.dbs.*; import gplx.dbs.sqls.*;
|
||||
import gplx.core.criterias.*; import gplx.dbs.sqls.itms.*;
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.sqls.wtrs; import gplx.Bry_bfr;
|
||||
import gplx.Byte_ascii;
|
||||
import gplx.CompareAble_;
|
||||
import gplx.Err_;
|
||||
import gplx.Object_;
|
||||
import gplx.String_;
|
||||
import gplx.Type_ids_;
|
||||
import gplx.core.criterias.Criteria;
|
||||
import gplx.core.criterias.Criteria_;
|
||||
import gplx.core.criterias.Criteria_between;
|
||||
import gplx.core.criterias.Criteria_bool_base;
|
||||
import gplx.core.criterias.Criteria_comp;
|
||||
import gplx.core.criterias.Criteria_eq;
|
||||
import gplx.core.criterias.Criteria_fld;
|
||||
import gplx.core.criterias.Criteria_in;
|
||||
import gplx.core.criterias.Criteria_ioMatch;
|
||||
import gplx.core.criterias.Criteria_like;
|
||||
import gplx.dbs.sqls.itms.Db_obj_ary_crt;
|
||||
import gplx.dbs.sqls.itms.Db_obj_ary_fld;
|
||||
import gplx.dbs.sqls.itms.Sql_where_clause;
|
||||
public class Sql_where_wtr {
|
||||
private final Sql_core_wtr qry_wtr;
|
||||
private final Sql_val_wtr val_wtr;
|
||||
private final Sql_core_wtr qry_wtr;
|
||||
private final Sql_val_wtr val_wtr;
|
||||
public Sql_where_wtr(Sql_core_wtr qry_wtr, Sql_val_wtr val_wtr) {this.qry_wtr = qry_wtr; this.val_wtr = val_wtr;}
|
||||
public void Bld_where(Bry_bfr bfr, Sql_wtr_ctx ctx, Sql_where_clause where_itm) {
|
||||
if (where_itm == Sql_where_clause.Where__null) return;
|
||||
|
||||
@@ -13,11 +13,11 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.stmts; import gplx.*; import gplx.dbs.*;
|
||||
public class Db_stmt_arg {
|
||||
public Db_stmt_arg(boolean crt, int tid, String key, Object val) {this.Crt = crt; this.Tid = tid; this.Key = key; this.Val = val;}
|
||||
public final boolean Crt;
|
||||
public final int Tid;
|
||||
public final String Key;
|
||||
public Object Val;
|
||||
}
|
||||
package gplx.dbs.stmts; import gplx.*; import gplx.dbs.*;
|
||||
public class Db_stmt_arg {
|
||||
public Db_stmt_arg(boolean crt, int tid, String key, Object val) {this.Crt = crt; this.Tid = tid; this.Key = key; this.Val = val;}
|
||||
public final boolean Crt;
|
||||
public final int Tid;
|
||||
public final String Key;
|
||||
public Object Val;
|
||||
}
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.stmts; import gplx.*; import gplx.dbs.*;
|
||||
public class Db_stmt_arg_list {
|
||||
private final List_adp list = List_adp_.New();
|
||||
private final List_adp list = List_adp_.New();
|
||||
public void Clear() {list.Clear();}
|
||||
public int Len() {return list.Len();}
|
||||
public Db_stmt_arg Get_at(int i) {return (Db_stmt_arg)list.Get_at(i);}
|
||||
|
||||
@@ -1,31 +1,32 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.stmts; import gplx.*; import gplx.dbs.*;
|
||||
import gplx.dbs.sqls.SqlQryWtrUtl;
|
||||
public class Db_stmt_mgr {
|
||||
private final List_adp fmt_list = List_adp_.New();
|
||||
private final Db_stmt_arg_list arg_list = new Db_stmt_arg_list();
|
||||
private final List_adp fmt_list = List_adp_.New();
|
||||
private final Db_stmt_arg_list arg_list = new Db_stmt_arg_list();
|
||||
public boolean Mode_is_stmt() {return mode_is_stmt;} public Db_stmt_mgr Mode_is_stmt_(boolean v) {mode_is_stmt = v; return this;} private boolean mode_is_stmt = true;
|
||||
public void Clear() {arg_list.Clear(); fmt_list.Clear(); bfr.Clear();}
|
||||
public Bry_bfr Bfr() {return bfr;} private final Bry_bfr bfr = Bry_bfr_.New();
|
||||
public Bry_bfr Bfr() {return bfr;} private final Bry_bfr bfr = Bry_bfr_.New();
|
||||
public void Add_var_many(Object... ary) {
|
||||
for (Object o : ary)
|
||||
fmt_list.Add(o);
|
||||
}
|
||||
public void Add_crt_str(String key, String val) {
|
||||
fmt_list.Add(mode_is_stmt ? stmt_arg_placeholder : gplx.dbs.sqls.Sql_qry_wtr_.Quote_arg(val));
|
||||
fmt_list.Add(mode_is_stmt ? stmt_arg_placeholder : SqlQryWtrUtl.QuoteArg(val));
|
||||
arg_list.Add(Bool_.Y, Dbmeta_fld_tid.Tid__str, key, val);
|
||||
}
|
||||
public void Add_crt_int(String key, int val) {
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.sys; import gplx.*; import gplx.dbs.*;
|
||||
public class Db_sys_mgr {
|
||||
private final Db_conn conn;
|
||||
private final Db_sys_tbl sys_tbl;
|
||||
private final Db_conn conn;
|
||||
private final Db_sys_tbl sys_tbl;
|
||||
private boolean assert_exists = true;
|
||||
public Db_sys_mgr(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.sys; import gplx.*; import gplx.dbs.*;
|
||||
class Db_sys_tbl implements Rls_able {
|
||||
private final String tbl_name = "gfdb_sys";
|
||||
private final String tbl_name = "gfdb_sys";
|
||||
private String fld_key, fld_val;
|
||||
private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private final Db_conn conn; private Db_stmt stmt_insert, stmt_update, stmt_select;
|
||||
private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private final Db_conn conn; private Db_stmt stmt_insert, stmt_update, stmt_select;
|
||||
public Db_sys_tbl(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
fld_key = flds.Add_str_pkey("sys_key", 255); fld_val = flds.Add_text("sys_val");
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.utls; import gplx.*; import gplx.dbs.*;
|
||||
import gplx.core.envs.*;
|
||||
public class Db_cmd_backup implements Gfo_invk {
|
||||
@@ -41,7 +41,7 @@ public class Db_cmd_backup implements Gfo_invk {
|
||||
else if (ctx.Match(k, Invk_BkpFilNameFmt_)) bkpFilNameFmt = GfoMsgUtl.SetStr(ctx, m, bkpFilNameFmt);
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
} public static final String
|
||||
} public static final String
|
||||
Invk_ExeUrl = "ExeUrl", Invk_BkpDir = "BkpDir", Invk_Usr = "Usr", Invk_Pwd = "Pwd", Invk_DteFmt = "DteFmt", Invk_BkpFilNameFmt = "BkpFilNameFmt"
|
||||
, Invk_ExeUrl_ = "ExeUrl_", Invk_BkpDir_ = "BkpDir_", Invk_Usr_ = "Usr_", Invk_Pwd_ = "Pwd_", Invk_DteFmt_ = "DteFmt_", Invk_BkpFilNameFmt_ = "BkpFilNameFmt_"
|
||||
;
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.utls; import gplx.*; import gplx.dbs.*;
|
||||
public abstract class Db_in_wkr__base {
|
||||
@gplx.Virtual protected int Interval() {return gplx.dbs.engines.sqlite.Sqlite_engine_.Stmt_arg_max - 10;} // -10 for safety's sake
|
||||
protected int Interval() {return gplx.dbs.engines.sqlite.Sqlite_engine_.Stmt_arg_max - 10;} // -10 for safety's sake
|
||||
protected abstract Db_qry Make_qry (int bgn, int end);
|
||||
protected abstract void Fill_stmt (Db_stmt stmt, int bgn, int end);
|
||||
protected abstract void Read_data (Cancelable cancelable, Db_rdr rdr);
|
||||
@gplx.Virtual protected boolean Show_progress() {return false;}
|
||||
protected boolean Show_progress() {return false;}
|
||||
public void Select_in(Cancelable cancelable, Db_conn conn, int full_bgn, int full_end) {
|
||||
int part_len = Interval();
|
||||
Gfo_usr_dlg usr_dlg = Gfo_usr_dlg_.Instance;
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.utls; import gplx.*; import gplx.dbs.*;
|
||||
import gplx.core.stores.*;
|
||||
import gplx.dbs.qrys.*;
|
||||
@@ -43,8 +43,8 @@ public class PoolIds {
|
||||
}
|
||||
if (rv != 1) throw Err_.new_wo_type("failed to update nextId", "url", url, "nextId", val);
|
||||
}
|
||||
public static final String Tbl_Name = "pool_ids";
|
||||
@gplx.Internal protected static final String Fld_id_path = "id_path";
|
||||
@gplx.Internal protected static final String Fld_id_next_id = "id_next_id";
|
||||
public static final PoolIds Instance = new PoolIds(); PoolIds() {}
|
||||
public static final String Tbl_Name = "pool_ids";
|
||||
@gplx.Internal protected static final String Fld_id_path = "id_path";
|
||||
@gplx.Internal protected static final String Fld_id_next_id = "id_next_id";
|
||||
public static final PoolIds Instance = new PoolIds(); PoolIds() {}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs; import gplx.*;
|
||||
import gplx.core.stores.*;
|
||||
import gplx.dbs.engines.sqlite.*; import gplx.dbs.engines.mysql.*; import gplx.dbs.engines.postgres.*; import gplx.core.gfo_ndes.*;
|
||||
@@ -49,5 +49,5 @@ public class Db_conn_fxt implements Rls_able {
|
||||
public static Db_conn Tdb(String fileName) {return Db_conn_pool.Instance.Get_or_new(Db_conn_info_.tdb_(Tfds.RscDir.GenSubDir_nest("140_dbs", "tdbs").GenSubFil(fileName)));}
|
||||
public static Db_conn Postgres() {return Db_conn_pool.Instance.Get_or_new(Postgres_conn_info.new_("127.0.0.1", "unit_tests", "gplx_user", "gplx_password"));}
|
||||
public static Db_conn Sqlite() {return Db_conn_pool.Instance.Get_or_new(Sqlite_conn_info.load_(Tfds.RscDir.GenSubFil_nest("140_dbs", "sqlite", "unit_tests.db")));}
|
||||
public static final boolean SkipPostgres = Tfds.SkipDb || true;
|
||||
public static final boolean SkipPostgres = Tfds.SkipDb || true;
|
||||
}
|
||||
@@ -1,25 +1,25 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.dbs.sqls.wtrs; import gplx.*; import gplx.dbs.*; import gplx.dbs.sqls.*;
|
||||
import gplx.core.criterias.*;
|
||||
class Sql_core_wtr_fxt {
|
||||
private final Sql_core_wtr__sqlite wtr = new Sql_core_wtr__sqlite();
|
||||
private final Sql_wtr_ctx ctx = new Sql_wtr_ctx(false);
|
||||
private final Bry_bfr bfr = Bry_bfr_.New();
|
||||
public Sql_core_wtr_fxt Sql_wtr_(Sql_qry_wtr v) {sql_wtr = v; return this;} private Sql_qry_wtr sql_wtr = Sql_qry_wtr_.New__sqlite();
|
||||
private final Sql_core_wtr__sqlite wtr = new Sql_core_wtr__sqlite();
|
||||
private final Sql_wtr_ctx ctx = new Sql_wtr_ctx(false);
|
||||
private final Bry_bfr bfr = Bry_bfr_.New();
|
||||
public Sql_core_wtr_fxt Sql_wtr_(SqlQryWtr v) {sql_wtr = v; return this;} private SqlQryWtr sql_wtr = SqlQryWtrUtl.NewSqlite();
|
||||
public void Test__val(Object val, String expd) {
|
||||
wtr.Val_wtr().Bld_val(bfr, ctx, val);
|
||||
Tfds.Eq_str(expd, bfr.To_str_and_clear());
|
||||
@@ -29,6 +29,6 @@ class Sql_core_wtr_fxt {
|
||||
Tfds.Eq_str_lines(String_.Concat_lines_nl_skip_last(expd), bfr.To_str_and_clear());
|
||||
}
|
||||
public void Test__qry(Db_qry qry, String expd) {
|
||||
Tfds.Eq_str_lines(expd, sql_wtr.To_sql_str(qry, Bool_.N));
|
||||
Tfds.Eq_str_lines(expd, sql_wtr.ToSqlStr(qry, Bool_.N));
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user