mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
'v3.4.1.1'
This commit is contained in:
21
140_dbs/src/gplx/dbs/metas/Dbmeta_reload_cmd.java
Normal file
21
140_dbs/src/gplx/dbs/metas/Dbmeta_reload_cmd.java
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.dbs.metas; import gplx.*; import gplx.dbs.*;
|
||||
public interface Dbmeta_reload_cmd {
|
||||
void Load_all();
|
||||
}
|
||||
24
140_dbs/src/gplx/dbs/metas/Dbmeta_reload_cmd_.java
Normal file
24
140_dbs/src/gplx/dbs/metas/Dbmeta_reload_cmd_.java
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.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() {}
|
||||
}
|
||||
@@ -17,11 +17,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.dbs.metas; import gplx.*; import gplx.dbs.*;
|
||||
public class Dbmeta_tbl_mgr {
|
||||
private final Ordered_hash hash = Ordered_hash_.New();
|
||||
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;}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,16 @@ public class Dbmeta_parser__fld {
|
||||
switch (src[rdr.Pos()]) {
|
||||
case Byte_ascii.Comma: return fld;
|
||||
case Byte_ascii.Paren_end: return fld;
|
||||
case Byte_ascii.Dash:
|
||||
int nxt_pos = rdr.Pos() + 1;
|
||||
if (src[nxt_pos] == Byte_ascii.Dash) {
|
||||
nxt_pos = Bry_find_.Find_fwd(src, Byte_ascii.Nl, nxt_pos);
|
||||
rdr.Move_to(nxt_pos + 1);
|
||||
}
|
||||
else {
|
||||
throw Err_.new_("sqls.dbs", "expected double dash for comment");
|
||||
}
|
||||
return fld;
|
||||
}
|
||||
Dbmeta_fld_wkr__base type_wkr = (Dbmeta_fld_wkr__base)rdr.Chk_trie_as_obj(fld_trie);
|
||||
switch (type_wkr.Tid()) {
|
||||
@@ -59,7 +69,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
|
||||
@@ -72,7 +82,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");
|
||||
@@ -81,7 +91,7 @@ public class Dbmeta_parser__fld {
|
||||
Dbmeta_parser__fld_itm.reg_many(rv, Dbmeta_fld_tid.Tid__long , Sqlite_tid.Tid_int , 0, "bigint", "int8"); // "UNSIGNED BIG INT"
|
||||
Dbmeta_parser__fld_itm.reg_many(rv, Dbmeta_fld_tid.Tid__str , Sqlite_tid.Tid_text , 1, "character", "varchar", "nchar"); // "varying character", "native character"
|
||||
Dbmeta_parser__fld_itm.reg_many(rv, Dbmeta_fld_tid.Tid__text , Sqlite_tid.Tid_text , 0, "text", "clob");
|
||||
Dbmeta_parser__fld_itm.reg_many(rv, Dbmeta_fld_tid.Tid__bry , Sqlite_tid.Tid_none , 0, "blob");
|
||||
Dbmeta_parser__fld_itm.reg_many(rv, Dbmeta_fld_tid.Tid__bry , Sqlite_tid.Tid_none , 0, "blob", "mediumblob");
|
||||
Dbmeta_parser__fld_itm.reg_many(rv, Dbmeta_fld_tid.Tid__float , Sqlite_tid.Tid_real , 0, "float");
|
||||
Dbmeta_parser__fld_itm.reg_many(rv, Dbmeta_fld_tid.Tid__double , Sqlite_tid.Tid_real , 0, "real", "double"); // "double precision"
|
||||
Dbmeta_parser__fld_itm.reg_many(rv, Dbmeta_fld_tid.Tid__decimal , Sqlite_tid.Tid_numeric , 0, "numeric");
|
||||
@@ -97,10 +107,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) {
|
||||
|
||||
@@ -35,10 +35,13 @@ public class Dbmeta_parser__fld_tst {
|
||||
fxt.Test_parse_fld("name_1 int not null default -1" , fxt.Make_fld("name_1", Dbmeta_fld_tid.Tid__int, Dbmeta_fld_itm.Nullable_not_null, Bool_.Y, Bool_.N, -1));
|
||||
fxt.Test_parse_fld("name_1 varchar(3) not null default 'abc'" , fxt.Make_fld("name_1", Dbmeta_fld_tid.Tid__str, Dbmeta_fld_itm.Nullable_not_null, Bool_.Y, Bool_.N, "abc"));
|
||||
}
|
||||
@Test public void Comment() {
|
||||
fxt.Test_parse_fld("name_1 int --a\n" , fxt.Make_fld("name_1", Dbmeta_fld_tid.Tid__int, Dbmeta_fld_itm.Nullable_unknown));
|
||||
}
|
||||
}
|
||||
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);}
|
||||
|
||||
Reference in New Issue
Block a user