1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00
This commit is contained in:
gnosygnu
2016-01-17 23:18:07 -05:00
parent 096045614c
commit 235228976e
314 changed files with 4458 additions and 2694 deletions

View File

@@ -16,9 +16,13 @@ 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 Meta_idx_mgr {
public class Dbmeta_fld_mgr {
private final Ordered_hash hash = Ordered_hash_.New();
public void Add(Meta_idx_itm itm) {hash.Add(itm.Name(), itm);}
public boolean Has(String name) {return hash.Has(name);}
public Meta_idx_itm Get(String name) {return (Meta_idx_itm)hash.Get_by(name);}
public int Len() {return hash.Count();}
public void Clear() {hash.Clear();}
public void Add(Dbmeta_fld_itm itm) {hash.Add(itm.Name(), itm);}
public boolean Has(String name) {return hash.Has(name);}
public Dbmeta_fld_itm Get_at(int idx) {return (Dbmeta_fld_itm)hash.Get_at(idx);}
public Dbmeta_fld_itm Get_by(String name) {return (Dbmeta_fld_itm)hash.Get_by(name);}
public Dbmeta_fld_itm[] To_ary() {return hash.Count() == 0 ? Dbmeta_fld_itm.Ary_empty : (Dbmeta_fld_itm[])hash.To_ary(Dbmeta_fld_itm.class);}
}

View File

@@ -0,0 +1,70 @@
/*
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.*;
import gplx.dbs.engines.sqlite.*;
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 boolean Eq(Dbmeta_fld_tid comp) {
return tid_ansi == comp.tid_ansi
&& tid_sqlite == comp.tid_sqlite
&& Bry_.Eq(name, comp.name)
&& len_1 == comp.len_1
&& len_2 == comp.len_2;
}
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
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)
, Itm__long = new Dbmeta_fld_tid(Dbmeta_fld_tid.Tid__long , Sqlite_tid.Tid_int , Bry_.new_a7("bigint") , -1, -1)
, Itm__text = new Dbmeta_fld_tid(Dbmeta_fld_tid.Tid__text , Sqlite_tid.Tid_text , Bry_.new_a7("text") , -1, -1)
, Itm__bry = new Dbmeta_fld_tid(Dbmeta_fld_tid.Tid__bry , Sqlite_tid.Tid_none , Bry_.new_a7("blob") , -1, -1)
, Itm__float = new Dbmeta_fld_tid(Dbmeta_fld_tid.Tid__float , Sqlite_tid.Tid_real , Bry_.new_a7("float") , -1, -1)
, Itm__double = new Dbmeta_fld_tid(Dbmeta_fld_tid.Tid__double , Sqlite_tid.Tid_real , Bry_.new_a7("double") , -1, -1)
, Itm__numeric = new Dbmeta_fld_tid(Dbmeta_fld_tid.Tid__decimal , Sqlite_tid.Tid_numeric , Bry_.new_a7("numeric") , -1, -1)
, Itm__bool = new Dbmeta_fld_tid(Dbmeta_fld_tid.Tid__bool , Sqlite_tid.Tid_numeric , Bry_.new_a7("bit") , -1, -1) // "bit" is not SQLITE
, Itm__date = new Dbmeta_fld_tid(Dbmeta_fld_tid.Tid__date , Sqlite_tid.Tid_numeric , Bry_.new_a7("date") , -1, -1)
;
public static Dbmeta_fld_tid Itm__str (int len) {return new Dbmeta_fld_tid(Dbmeta_fld_tid.Tid__str , Sqlite_tid.Tid_text , Bry_.new_a7("varchar") , len, -1);}
public static Dbmeta_fld_tid Itm__decimal (int len_1, int len_2) {return new Dbmeta_fld_tid(Dbmeta_fld_tid.Tid__decimal , Sqlite_tid.Tid_numeric , Bry_.new_a7("decimal") , len_1, len_2);}
public static Dbmeta_fld_tid New(int tid, int len1) {
switch (tid) {
case Dbmeta_fld_tid.Tid__bool: return Itm__bool;
case Dbmeta_fld_tid.Tid__byte: return Itm__byte;
case Dbmeta_fld_tid.Tid__short: return Itm__short;
case Dbmeta_fld_tid.Tid__int: return Itm__int;
case Dbmeta_fld_tid.Tid__long: return Itm__long;
case Dbmeta_fld_tid.Tid__float: return Itm__float;
case Dbmeta_fld_tid.Tid__double: return Itm__double;
case Dbmeta_fld_tid.Tid__str: return Itm__str(len1);
case Dbmeta_fld_tid.Tid__text: return Itm__text;
case Dbmeta_fld_tid.Tid__bry: return Itm__bry;
case Dbmeta_fld_tid.Tid__date: return Itm__date;
case Dbmeta_fld_tid.Tid__decimal: // return Itm__decimal(len1);
default: throw Err_.new_unhandled(tid);
}
}
}

View File

@@ -0,0 +1,39 @@
/*
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_idx_fld {
public Dbmeta_idx_fld(int order, String name, int sort_tid) {this.Name = name; this.Order = order; this.Sort_tid = sort_tid;}
public int Order;
public String Name;
public int Sort_tid;
public boolean Eq(Dbmeta_idx_fld comp) {
return String_.Eq(Name, comp.Name)
&& Order == comp.Order
&& Sort_tid == comp.Sort_tid;
}
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;
if (lhs_len != rhs_len) return false;
for (int i = 0; i < lhs_len; ++i)
if (!lhs_ary[i].Eq(rhs_ary[i])) return false;
return true;
}
}

View File

@@ -16,11 +16,13 @@ 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 Meta_fld_mgr {
public class Dbmeta_idx_mgr {
private final Ordered_hash hash = Ordered_hash_.New();
public int Len() {return hash.Count();}
public void Add(Meta_fld_itm itm) {hash.Add(itm.Name(), itm);}
public boolean Has(String name) {return hash.Has(name);}
public Meta_fld_itm Get_by(String name) {return (Meta_fld_itm)hash.Get_by(name);}
public Meta_fld_itm Get_at(int i) {return (Meta_fld_itm)hash.Get_at(i);}
public int Len() {return hash.Count();}
public boolean Has(String name) {return hash.Has(name);}
public Dbmeta_idx_itm Get_at(int idx) {return (Dbmeta_idx_itm)hash.Get_at(idx);}
public Dbmeta_idx_itm Get_by(String name) {return (Dbmeta_idx_itm)hash.Get_by(name);}
public void Add(Dbmeta_idx_itm itm) {hash.Add(itm.Name(), itm);}
public void Clear() {hash.Clear();}
public Dbmeta_idx_itm[] To_ary() {return (Dbmeta_idx_itm[])hash.To_ary(Dbmeta_idx_itm.class);}
}

View File

@@ -16,7 +16,7 @@ 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 Meta_itm_tid {
public class Dbmeta_itm_tid {
public static final int Tid_unknown = 0, Tid_table = 1, Tid_index = 2;
public static final String Key_table = "table", Key_index = "index";
public static int Xto_int(String s) {

View File

@@ -16,11 +16,12 @@ 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 Meta_tbl_mgr {
public class Dbmeta_tbl_mgr {
private final Ordered_hash hash = Ordered_hash_.New();
public int Len() {return hash.Count();}
public void Add(Meta_tbl_itm itm) {hash.Add(itm.Name(), itm);}
public boolean Has(String name) {return hash.Has(name);}
public Meta_tbl_itm Get_at(int i) {return (Meta_tbl_itm)hash.Get_at(i);}
public Meta_tbl_itm Get_by(String name) {return (Meta_tbl_itm)hash.Get_by(name);}
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();}
}

View File

@@ -1,31 +0,0 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.dbs.metas; import gplx.*; import gplx.dbs.*;
public class Meta_fld_itm {
public Meta_fld_itm(String name, Meta_type_itm type) {
this.name = name; this.type = type;
}
public String Name() {return name;} private final String name;
public Meta_type_itm Type() {return type;} private final Meta_type_itm type;
public int Nullable_tid() {return nullable_tid;} public void Nullable_tid_(int v) {nullable_tid = v;} private int nullable_tid;
public boolean Autonumber() {return autonumber;} public void Autonumber_y_() {autonumber = true;} private boolean autonumber;
public boolean Primary_key() {return primary_key;} public void Primary_key_y_() {primary_key = true;} private boolean primary_key;
public Object Default_val() {return default_val;} private Object default_val;
public void Default_val_(Object v) {this.default_val = v;}
public static final int Nullable_unknown = 0, Nullable_null = 1, Nullable_not_null = 2;
}

View File

@@ -1,23 +0,0 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.dbs.metas; import gplx.*; import gplx.dbs.*;
public class Meta_idx_itm {
public Meta_idx_itm(String name, String sql) {this.name = name; this.sql = sql;}
public String Name() {return name;} private final String name;
public String Sql() {return sql;} private final String sql;
}

View File

@@ -1,24 +0,0 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.dbs.metas; import gplx.*; import gplx.dbs.*;
public class Meta_tbl_itm {
public Meta_tbl_itm(String name, String sql) {this.name = name; this.sql = sql;}
public Meta_fld_mgr Flds() {return flds;} private final Meta_fld_mgr flds = new Meta_fld_mgr();
public String Name() {return name;} private final String name;
public String Sql() {return sql;} private final String sql;
}

View File

@@ -1,28 +0,0 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.dbs.metas; import gplx.*; import gplx.dbs.*;
public class Meta_type_itm {
public Meta_type_itm(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;
}

View File

@@ -0,0 +1,119 @@
/*
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.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 int words_len;
@gplx.Virtual public int Tid() {return Tid_other;}
public void Ctor(byte[] hook, byte[]... words_ary) {
this.hook = hook;
this.words_len = words_ary.length;
for (byte i = 0; i < words_len; ++i)
words_trie.Add_bry_byte(words_ary[i], i);
}
public void Reg(Btrie_slim_mgr trie) {
trie.Add_obj(hook, this);
}
@gplx.Virtual 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();
rdr.Chk(words_trie);
}
When_match(fld);
}
protected abstract void When_match(Dbmeta_fld_itm fld);
public static final int Tid_end_comma = 1, Tid_end_paren = 2, Tid_other = 3;
}
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();
}
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();
}
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();
}
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();
}
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();
}
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();
}
class Dbmeta_fld_wkr__default extends Dbmeta_fld_wkr__base {
public Dbmeta_fld_wkr__default() {this.Ctor(Hook);}
@Override public void Match(Bry_rdr rdr, Dbmeta_fld_itm fld) {
Object default_val = null;
rdr.Skip_ws();
byte[] src = rdr.Src();
byte b = src[rdr.Pos()];
switch (b) {
case Byte_ascii.Quote:
case Byte_ascii.Apos:
int bgn_pos = rdr.Pos() + 1;
int end_pos = Bry_find_.Find_fwd(src, b, bgn_pos); if (end_pos == Bry_find_.Not_found) rdr.Err_wkr().Fail("unclosed quote");
default_val = Bry_.Mid(src, bgn_pos, end_pos);
rdr.Move_to(end_pos + 1);
break;
case Byte_ascii.Dash:
case Byte_ascii.Num_0: case Byte_ascii.Num_1: case Byte_ascii.Num_2: case Byte_ascii.Num_3: case Byte_ascii.Num_4:
case Byte_ascii.Num_5: case Byte_ascii.Num_6: case Byte_ascii.Num_7: case Byte_ascii.Num_8: case Byte_ascii.Num_9:
default_val = rdr.Read_int_to_non_num();
break;
default:
rdr.Err_wkr().Fail("invalid field_default"); break;
}
fld.Default_(default_val);
}
@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();
}

View File

@@ -0,0 +1,112 @@
/*
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.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 {
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);
Dbmeta_fld_itm fld = new Dbmeta_fld_itm(String_.new_u8(name), type);
byte[] src = rdr.Src(); int src_len = rdr.Src_end();
while (true) {
rdr.Skip_ws();
if (rdr.Pos() == src_len) return fld; // eos
switch (src[rdr.Pos()]) {
case Byte_ascii.Comma: return fld;
case Byte_ascii.Paren_end: return fld;
}
Dbmeta_fld_wkr__base type_wkr = (Dbmeta_fld_wkr__base)rdr.Chk_trie_as_obj(fld_trie);
switch (type_wkr.Tid()) {
case Dbmeta_fld_wkr__base.Tid_end_comma:
case Dbmeta_fld_wkr__base.Tid_end_paren: return fld;
default:
rdr.Move_to(fld_trie.Match_pos());
type_wkr.Match(rdr, fld);
break;
}
}
}
@gplx.Internal protected Dbmeta_fld_tid Parse_type(Bry_rdr rdr) {
rdr.Skip_ws();
Dbmeta_parser__fld_itm type_itm = (Dbmeta_parser__fld_itm)rdr.Chk_trie_as_obj(type_trie);
rdr.Move_by(type_itm.Word().length);
int paren_itms_count = type_itm.Paren_itms_count();
int len_1 = Int_.Min_value, len_2 = Int_.Min_value;
if (paren_itms_count > 0) {
rdr.Skip_ws().Chk(Byte_ascii.Paren_bgn);
len_1 = rdr.Skip_ws().Read_int_to_non_num(); if (len_1 == Int_.Min_value) rdr.Err_wkr().Fail("invalid fld len_1");
if (paren_itms_count == 2) {
rdr.Skip_ws().Chk(Byte_ascii.Comma);
len_2 = rdr.Skip_ws().Read_int_to_non_num(); if (len_2 == Int_.Min_value) rdr.Err_wkr().Fail("invalid fld len_2");
}
rdr.Skip_ws().Chk(Byte_ascii.Paren_end);
}
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
( Dbmeta_fld_wkr__nullable_null.Instance
, Dbmeta_fld_wkr__nullable_not.Instance
, Dbmeta_fld_wkr__autonumber.Instance
, Dbmeta_fld_wkr__primary_key.Instance
, Dbmeta_fld_wkr__default.Instance
);
private static Btrie_slim_mgr fld_trie_init(Dbmeta_fld_wkr__base... wkrs) {
Btrie_slim_mgr rv = Btrie_slim_mgr.ci_a7();
for (Dbmeta_fld_wkr__base wkr : wkrs)
wkr.Reg(rv);
return rv;
}
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");
Dbmeta_parser__fld_itm.reg_many(rv, Dbmeta_fld_tid.Tid__short , Sqlite_tid.Tid_int , 0, "smallint");
Dbmeta_parser__fld_itm.reg_many(rv, Dbmeta_fld_tid.Tid__int , Sqlite_tid.Tid_int , 0, "int", "integer", "mediumint");
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__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");
Dbmeta_parser__fld_itm.reg_many(rv, Dbmeta_fld_tid.Tid__decimal , Sqlite_tid.Tid_numeric , 2, "decimal");
Dbmeta_parser__fld_itm.reg_many(rv, Dbmeta_fld_tid.Tid__decimal , Sqlite_tid.Tid_numeric , 2, "decimal");
Dbmeta_parser__fld_itm.reg_many(rv, Dbmeta_fld_tid.Tid__bool , Sqlite_tid.Tid_numeric , 0, "boolean", "bit"); // "bit" is not SQLITE
Dbmeta_parser__fld_itm.reg_many(rv, Dbmeta_fld_tid.Tid__date , Sqlite_tid.Tid_numeric , 0, "date", "datetime");
return rv;
}
}
class Dbmeta_parser__fld_itm {
public Dbmeta_parser__fld_itm(int tid_ansi, int tid_sqlite, byte[] word, int paren_itms_count) {
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 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) {
byte[] name_bry = Bry_.new_a7(names_str[i]);
Dbmeta_parser__fld_itm itm = new Dbmeta_parser__fld_itm(tid_ansi, tid_sqlite, name_bry, paren_itms_count);
trie.Add_obj(name_bry, itm);
}
}
}

View File

@@ -0,0 +1,71 @@
/*
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.parsers; import gplx.*; import gplx.dbs.*; import gplx.dbs.metas.*;
import org.junit.*;
public class Dbmeta_parser__fld_tst {
@Before public void init() {fxt.Clear();} private Dbmeta_parser__fld_fxt fxt = new Dbmeta_parser__fld_fxt();
@Test public void Parse_type() {
fxt.Test_parse_type("int" , fxt.Make_type(Dbmeta_fld_tid.Tid__int));
fxt.Test_parse_type("varchar(255)" , fxt.Make_type(Dbmeta_fld_tid.Tid__str, 255));
fxt.Test_parse_type("decimal(12,10)" , fxt.Make_type(Dbmeta_fld_tid.Tid__decimal, 12, 10));
fxt.Test_parse_type(" int" , fxt.Make_type(Dbmeta_fld_tid.Tid__int));
fxt.Test_parse_type(" decimal ( 12 , 10 )" , fxt.Make_type(Dbmeta_fld_tid.Tid__decimal, 12, 10));
}
@Test public void Parse_fld() {
fxt.Test_parse_fld("name_1 int" , fxt.Make_fld("name_1", Dbmeta_fld_tid.Tid__int, Dbmeta_fld_itm.Nullable_unknown));
fxt.Test_parse_fld("name_1 int null" , fxt.Make_fld("name_1", Dbmeta_fld_tid.Tid__int, Dbmeta_fld_itm.Nullable_null));
fxt.Test_parse_fld("name_1 int not null" , fxt.Make_fld("name_1", Dbmeta_fld_tid.Tid__int, Dbmeta_fld_itm.Nullable_not_null));
fxt.Test_parse_fld("name_1 int not null autoincrement" , fxt.Make_fld("name_1", Dbmeta_fld_tid.Tid__int, Dbmeta_fld_itm.Nullable_not_null, Bool_.N, Bool_.Y));
fxt.Test_parse_fld("name_1 int not null primary key" , fxt.Make_fld("name_1", Dbmeta_fld_tid.Tid__int, Dbmeta_fld_itm.Nullable_not_null, Bool_.Y, Bool_.N));
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 int not null default 'abc'" , fxt.Make_fld("name_1", Dbmeta_fld_tid.Tid__int, Dbmeta_fld_itm.Nullable_not_null, Bool_.Y, Bool_.N, "abc"));
}
}
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();
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);}
public Dbmeta_fld_tid Make_type(int tid_ansi, int len_1, int len_2) {return new Dbmeta_fld_tid(tid_ansi, -1, null, len_1, len_2);}
public Dbmeta_fld_itm Make_fld(String name, int tid_ansi, int nullable) {return Make_fld(name, tid_ansi, nullable, false, false, null);}
public Dbmeta_fld_itm Make_fld(String name, int tid_ansi, int nullable, boolean autonumber, boolean primary_key) {return Make_fld(name, tid_ansi, nullable, false, false, null);}
public Dbmeta_fld_itm Make_fld(String name, int tid_ansi, int nullable, boolean autonumber, boolean primary_key, Object default_val) {
Dbmeta_fld_itm rv = new Dbmeta_fld_itm(name, Make_type(tid_ansi));
rv.Nullable_tid_(nullable);
if (autonumber) rv.Autonum_y_();
if (primary_key) rv.Primary_y_();
rv.Default_(default_val);
return rv;
}
public void Test_parse_type(String src, Dbmeta_fld_tid expd_type) {
rdr.Init_by_src(Bry_.new_u8(src));
Dbmeta_fld_tid actl_type = fld_parser.Parse_type(rdr);
Tfds.Eq(expd_type.Tid_ansi() , actl_type.Tid_ansi());
Tfds.Eq(expd_type.Len_1() , actl_type.Len_1());
Tfds.Eq(expd_type.Len_2() , actl_type.Len_2());
}
public void Test_parse_fld(String src, Dbmeta_fld_itm expd_fld) {
rdr.Init_by_src(Bry_.new_u8(src));
Dbmeta_fld_itm actl_fld = fld_parser.Parse_fld(rdr);
Tfds.Eq(expd_fld.Name() , actl_fld.Name());
Tfds.Eq(expd_fld.Type().Tid_ansi() , actl_fld.Type().Tid_ansi());
Tfds.Eq(expd_fld.Nullable_tid() , actl_fld.Nullable_tid());
Tfds.Eq(Object_.Xto_str_strict_or_empty(expd_fld.Default()), Object_.Xto_str_strict_or_empty(actl_fld.Default()));
}
}

View File

@@ -0,0 +1,59 @@
/*
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.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_();
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);
boolean unique = false;
byte tid = rdr.Skip_ws().Chk_or(trie, Byte_.Max_value_127);
switch (tid) {
case Tid__index: break;
case Tid__unique: rdr.Skip_ws().Chk_trie_val(trie, Tid__index); unique = true; break;
default: throw Err_.new_("db", "index parse failed; 'CREATE' should be followed by 'INDEX' or 'UNIQUE'", "src", src);
}
byte[] idx_name = rdr.Read_sql_identifier();
rdr.Skip_ws().Chk_trie_val(trie, Tid__on);
byte[] tbl_name = rdr.Read_sql_identifier();
rdr.Skip_ws().Chk(Byte_ascii.Paren_bgn);
int order = -1;
while (true) {
byte[] fld_bry = rdr.Read_sql_identifier(); if (fld_bry == null) throw Err_.new_("db", "index parse failed; index field is not an identifier", "src", src);
// TODO: check for ASC / DESC
Dbmeta_idx_fld fld_itm = new Dbmeta_idx_fld(++order, String_.new_u8(fld_bry), Dbmeta_idx_fld.Sort_tid__none);
tmp_list.Add(fld_itm);
byte sym = rdr.Skip_ws().Read_byte();
if (sym == Byte_ascii.Paren_end) break;
}
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[]
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()
.Add_bry_byte(Bry__create , Tid__create)
.Add_bry_byte(Bry__unique , Tid__unique)
.Add_bry_byte(Bry__index , Tid__index)
.Add_bry_byte(Bry__on , Tid__on);
}

View File

@@ -0,0 +1,37 @@
/*
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.parsers; import gplx.*; import gplx.dbs.*; import gplx.dbs.metas.*;
import org.junit.*;
public class Dbmeta_parser__idx_tst {
@Before public void init() {fxt.Clear();} private final Dbmeta_parser__idx_fxt fxt = new Dbmeta_parser__idx_fxt();
@Test public void Unique() {fxt.Test_parse("CREATE UNIQUE INDEX idx_1 ON tbl_1 (fld_1, fld_2, fld_3)" , fxt.Make_idx(Bool_.Y, "idx_1", "tbl_1", "fld_1", "fld_2", "fld_3"));}
@Test public void Normal() {fxt.Test_parse("CREATE INDEX idx_1 ON tbl_1 (fld_1, fld_2, fld_3)" , fxt.Make_idx(Bool_.N, "idx_1", "tbl_1", "fld_1", "fld_2", "fld_3"));}
@Test public void Fld_1() {fxt.Test_parse("CREATE INDEX idx_1 ON tbl_1 (fld_1)" , fxt.Make_idx(Bool_.N, "idx_1", "tbl_1", "fld_1"));}
}
class Dbmeta_parser__idx_fxt {
private final Dbmeta_parser__idx parser = new Dbmeta_parser__idx();
public void Clear() {}
public Dbmeta_idx_itm Make_idx(boolean unique, String idx_name, String tbl_name, String... fld_names) {return new Dbmeta_idx_itm(unique, tbl_name, idx_name, Dbmeta_idx_itm.To_fld_ary(fld_names));}
public void Test_parse(String src, Dbmeta_idx_itm expd) {
Dbmeta_idx_itm actl = parser.Parse(Bry_.new_u8(src));
Tfds.Eq_bool(expd.Unique(), actl.Unique());
Tfds.Eq_str(expd.Name(), actl.Name());
Tfds.Eq_str(expd.Tbl(), actl.Tbl());
Tfds.Eq_bool(Bool_.Y, Dbmeta_idx_fld.Ary_eq(expd.Flds, actl.Flds));
}
}

View File

@@ -0,0 +1,51 @@
/*
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.parsers; import gplx.*; import gplx.dbs.*; import gplx.dbs.metas.*;
import gplx.core.brys.*; import gplx.core.btries.*;
public class Dbmeta_parser__tbl {
private final Sql_bry_rdr rdr = new Sql_bry_rdr();
private final Dbmeta_parser__fld fld_parser = new Dbmeta_parser__fld();
public Dbmeta_tbl_itm Parse(byte[] src) {
rdr.Init_by_page(Bry_.Empty, src, src.length);
rdr.Skip_ws().Chk_trie_val(trie, Tid__create);
rdr.Skip_ws().Chk_trie_val(trie, Tid__table);
byte[] tbl_name = rdr.Read_sql_identifier();
rdr.Skip_ws().Chk(Byte_ascii.Paren_bgn);
Dbmeta_tbl_itm rv = Dbmeta_tbl_itm.New(String_.new_u8(tbl_name));
boolean loop = true;
while (loop) {
Dbmeta_fld_itm fld = fld_parser.Parse_fld(rdr); if (fld == null) rdr.Err_wkr().Fail("unknown field", "src", src);
rv.Flds().Add(fld);
int pos = rdr.Pos();
byte b = pos == rdr.Src_end() ? Byte_ascii.Null : src[pos];
switch (b) {
case Byte_ascii.Comma: rdr.Move_by_one(); break;
case Byte_ascii.Paren_end: rdr.Move_by_one(); loop = false; break;
default: rdr.Err_wkr().Fail("premature end of flds"); break;
}
}
return rv;
}
private static final byte Tid__create = 0, Tid__table = 1;
private static final byte[]
Bry__create = Bry_.new_a7("create")
, Bry__table = Bry_.new_a7("table");
private static final Btrie_slim_mgr trie = Btrie_slim_mgr.ci_a7()
.Add_bry_byte(Bry__create , Tid__create)
.Add_bry_byte(Bry__table , Tid__table);
}

View File

@@ -16,9 +16,9 @@ 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.parsers; import gplx.*; import gplx.dbs.*; import gplx.dbs.metas.*;
import org.junit.*;
public class Meta_parser__tbl_tst {
@Before public void init() {fxt.Clear();} private Meta_parser__tbl_fxt fxt = new Meta_parser__tbl_fxt();
import org.junit.*; import gplx.dbs.engines.sqlite.*;
public class Dbmeta_parser__tbl_tst {
@Before public void init() {fxt.Clear();} private Dbmeta_parser__tbl_fxt fxt = new Dbmeta_parser__tbl_fxt();
@Test public void Test_parse() {
fxt.Test_parse("CREATE TABLE tbl_1 (fld_1 int, fld_2 int)", fxt.Make_tbl("tbl_1", "fld_1", "fld_2"));
}
@@ -39,23 +39,22 @@ public class Meta_parser__tbl_tst {
), fxt.Make_tbl("page", "page_id", "page_namespace", "page_title", "page_is_redirect", "page_touched", "page_len", "page_random_int", "page_text_db_id", "page_html_db_id", "page_redirect_id"));
}
}
class Meta_parser__tbl_fxt {
private final Meta_parser__tbl tbl_parser = new Meta_parser__tbl();
class Dbmeta_parser__tbl_fxt {
private final Dbmeta_parser__tbl tbl_parser = new Dbmeta_parser__tbl();
public void Clear() {}
public Meta_tbl_itm Make_tbl(String tbl_name, String... fld_names) {
Meta_tbl_itm rv = new Meta_tbl_itm(tbl_name, "NONE");
public Dbmeta_tbl_itm Make_tbl(String tbl_name, String... fld_names) {
int len = fld_names.length;
for (int i = 0; i < len; ++i) {
rv.Flds().Add(new Meta_fld_itm(fld_names[i], new Meta_type_itm(Db_meta_fld.Tid_int, Sqlite_tid.Tid_int, Bry_.new_a7("int"), Int_.Min_value, Int_.Min_value)));
}
return rv;
Dbmeta_fld_itm[] flds = new Dbmeta_fld_itm[len];
for (int i = 0; i < len; ++i)
flds[i] = new Dbmeta_fld_itm(fld_names[i], new Dbmeta_fld_tid(Dbmeta_fld_tid.Tid__int, Sqlite_tid.Tid_int, Bry_.new_a7("int"), Int_.Min_value, Int_.Min_value));
return Dbmeta_tbl_itm.New(tbl_name, flds);
}
public void Test_parse(String src, Meta_tbl_itm expd_tbl) {
Meta_tbl_itm actl_tbl = tbl_parser.Parse(Bry_.new_u8(src));
public void Test_parse(String src, Dbmeta_tbl_itm expd_tbl) {
Dbmeta_tbl_itm actl_tbl = tbl_parser.Parse(Bry_.new_u8(src));
Tfds.Eq(expd_tbl.Name(), actl_tbl.Name());
Tfds.Eq_ary_str(To_str_ary(expd_tbl.Flds()), To_str_ary(actl_tbl.Flds()));
}
private static String[] To_str_ary(Meta_fld_mgr fld_mgr) {
private static String[] To_str_ary(Dbmeta_fld_mgr fld_mgr) {
int len = fld_mgr.Len();
String[] rv = new String[len];
for (int i = 0; i < len; ++i) {

View File

@@ -1,117 +0,0 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.dbs.metas.parsers; import gplx.*; import gplx.dbs.*; import gplx.dbs.metas.*;
import gplx.core.brys.*; import gplx.core.btries.*;
abstract class Meta_fld_wkr__base {
private byte[] hook;
private byte[][] words_ary; private int words_len;
@gplx.Virtual public int Tid() {return Tid_other;}
public void Ctor(byte[] hook, byte[]... words_ary) {
this.hook = hook;
this.words_ary = words_ary;
this.words_len = words_ary.length;
}
public void Reg(Btrie_slim_mgr trie) {
trie.Add_obj(hook, this);
}
@gplx.Virtual public void Match(Bry_rdr_old rdr, Meta_fld_itm fld) {
for (int i = 0; i < words_len; ++i) {
rdr.Skip_ws();
byte[] word = words_ary[i];
rdr.Chk_bry_or_fail(word);
}
When_match(fld);
}
protected abstract void When_match(Meta_fld_itm fld);
public static final int Tid_end_comma = 1, Tid_end_paren = 2, Tid_other = 3;
}
class Meta_fld_wkr__end_comma extends Meta_fld_wkr__base {
public Meta_fld_wkr__end_comma() {this.Ctor(Hook);}
@Override public int Tid() {return Tid_end_comma;}
@Override protected void When_match(Meta_fld_itm fld) {}
private static final byte[] Hook = Bry_.new_a7(",");
public static final Meta_fld_wkr__end_comma Instance = new Meta_fld_wkr__end_comma();
}
class Meta_fld_wkr__end_paren extends Meta_fld_wkr__base {
public Meta_fld_wkr__end_paren() {this.Ctor(Hook);}
@Override public int Tid() {return Tid_end_paren;}
@Override protected void When_match(Meta_fld_itm fld) {}
private static final byte[] Hook = Bry_.new_a7(")");
public static final Meta_fld_wkr__end_paren Instance = new Meta_fld_wkr__end_paren();
}
class Meta_fld_wkr__nullable_null extends Meta_fld_wkr__base {
public Meta_fld_wkr__nullable_null() {this.Ctor(Hook);}
@Override protected void When_match(Meta_fld_itm fld) {
fld.Nullable_tid_(Meta_fld_itm.Nullable_null);
}
private static final byte[] Hook = Bry_.new_a7("null");
public static final Meta_fld_wkr__nullable_null Instance = new Meta_fld_wkr__nullable_null();
}
class Meta_fld_wkr__nullable_not extends Meta_fld_wkr__base {
public Meta_fld_wkr__nullable_not() {this.Ctor(Hook, Bry_null);}
@Override protected void When_match(Meta_fld_itm fld) {
fld.Nullable_tid_(Meta_fld_itm.Nullable_not_null);
}
private static final byte[] Hook = Bry_.new_a7("not"), Bry_null = Bry_.new_a7("null");
public static final Meta_fld_wkr__nullable_not Instance = new Meta_fld_wkr__nullable_not();
}
class Meta_fld_wkr__primary_key extends Meta_fld_wkr__base {
public Meta_fld_wkr__primary_key() {this.Ctor(Hook, Bry_key);}
@Override protected void When_match(Meta_fld_itm fld) {
fld.Primary_key_y_();
}
private static final byte[] Hook = Bry_.new_a7("primary"), Bry_key = Bry_.new_a7("key");
public static final Meta_fld_wkr__primary_key Instance = new Meta_fld_wkr__primary_key();
}
class Meta_fld_wkr__autonumber extends Meta_fld_wkr__base {
public Meta_fld_wkr__autonumber() {this.Ctor(Hook);}
@Override protected void When_match(Meta_fld_itm fld) {
fld.Autonumber_y_();
}
private static final byte[] Hook = Bry_.new_a7("autoincrement");
public static final Meta_fld_wkr__autonumber Instance = new Meta_fld_wkr__autonumber();
}
class Meta_fld_wkr__default extends Meta_fld_wkr__base {
public Meta_fld_wkr__default() {this.Ctor(Hook);}
@Override public void Match(Bry_rdr_old rdr, Meta_fld_itm fld) {
Object default_val = null;
rdr.Skip_ws();
byte[] src = rdr.Src();
byte b = src[rdr.Pos()];
switch (b) {
case Byte_ascii.Quote:
case Byte_ascii.Apos:
int bgn_pos = rdr.Pos() + 1;
int end_pos = Bry_find_.Find_fwd(src, b, bgn_pos); if (end_pos == Bry_find_.Not_found) throw Err_.new_wo_type("unclosed quote", "snip", rdr.Mid_by_len_safe(40));
default_val = Bry_.Mid(src, bgn_pos, end_pos);
rdr.Pos_(end_pos + 1);
break;
case Byte_ascii.Dash:
case Byte_ascii.Num_0: case Byte_ascii.Num_1: case Byte_ascii.Num_2: case Byte_ascii.Num_3: case Byte_ascii.Num_4:
case Byte_ascii.Num_5: case Byte_ascii.Num_6: case Byte_ascii.Num_7: case Byte_ascii.Num_8: case Byte_ascii.Num_9:
default_val = rdr.Read_int_to_non_num();
break;
default:
throw Err_.new_wo_type("invalid field_default", "snip", rdr.Mid_by_len_safe(40));
}
fld.Default_val_(default_val);
}
@Override protected void When_match(Meta_fld_itm fld) {}
private static final byte[] Hook = Bry_.new_a7("default");
public static final Meta_fld_wkr__default Instance = new Meta_fld_wkr__default();
}

View File

@@ -1,118 +0,0 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.dbs.metas.parsers; import gplx.*; import gplx.dbs.*; import gplx.dbs.metas.*;
import gplx.core.brys.*; import gplx.core.btries.*;
public class Meta_parser__fld {
public Meta_type_itm Parse_type(Bry_rdr_old rdr) {
rdr.Skip_ws();
Object type_obj = type_trie.Match_bgn(rdr.Src(), rdr.Pos(), rdr.Src_len());
if (type_obj == null) throw Err_.new_wo_type("invalid fld type", "snip", rdr.Mid_by_len_safe(40));
Meta_parser__fld_itm type_itm = (Meta_parser__fld_itm)type_obj;
rdr.Pos_add(type_itm.Word().length);
int paren_itms_count = type_itm.Paren_itms_count();
int len_1 = Int_.Min_value, len_2 = Int_.Min_value;
if (paren_itms_count > 0) {
rdr.Skip_ws().Chk_byte_or_fail(Byte_ascii.Paren_bgn);
len_1 = rdr.Skip_ws().Read_int_to_non_num(); if (len_1 == Int_.Min_value) throw Err_.new_wo_type("invalid fld len_1", "snip", rdr.Mid_by_len_safe(40));
if (paren_itms_count == 2) {
rdr.Skip_ws().Chk_byte_or_fail(Byte_ascii.Comma);
len_2 = rdr.Skip_ws().Read_int_to_non_num(); if (len_2 == Int_.Min_value) throw Err_.new_wo_type("invalid fld len_2", "snip", rdr.Mid_by_len_safe(40));
}
rdr.Skip_ws().Chk_byte_or_fail(Byte_ascii.Paren_end);
}
return new Meta_type_itm(type_itm.Tid_ansi(), type_itm.Tid_sqlite(), type_itm.Word(), len_1, len_2);
}
public Meta_fld_itm Parse_fld(Sql_bry_rdr rdr) { // starts after "(" or ","; EX: "(fld1 int", ", fld2 int"; ends at ")"
byte[] name = rdr.Read_sql_identifier();
Meta_type_itm type = this.Parse_type(rdr);
Meta_fld_itm fld = new Meta_fld_itm(String_.new_u8(name), type);
byte[] src = rdr.Src(); int src_len = rdr.Src_len();
while (true) {
rdr.Skip_ws();
if (rdr.Pos() == src_len) return fld; // eos
switch (src[rdr.Pos()]) {
case Byte_ascii.Comma: return fld;
case Byte_ascii.Paren_end: return fld;
}
Object type_obj = fld_trie.Match_bgn(src, rdr.Pos(), src_len); if (type_obj == null) throw Err_.new_wo_type("invalid", "snip", rdr.Mid_by_len_safe(40));
Meta_fld_wkr__base type_wkr = (Meta_fld_wkr__base)type_obj;
switch (type_wkr.Tid()) {
case Meta_fld_wkr__base.Tid_end_comma:
case Meta_fld_wkr__base.Tid_end_paren: return fld;
default:
rdr.Pos_(fld_trie.Match_pos());
type_wkr.Match(rdr, fld);
break;
}
}
// return fld; // NOTE: will happen for tests; EX: "fld_1 int" vs "fld_1 int,"
}
private static final Btrie_slim_mgr fld_trie = fld_trie_init
( Meta_fld_wkr__nullable_null.Instance
, Meta_fld_wkr__nullable_not.Instance
, Meta_fld_wkr__autonumber.Instance
, Meta_fld_wkr__primary_key.Instance
, Meta_fld_wkr__default.Instance
);
private static Btrie_slim_mgr fld_trie_init(Meta_fld_wkr__base... wkrs) {
Btrie_slim_mgr rv = Btrie_slim_mgr.ci_a7();
for (Meta_fld_wkr__base wkr : wkrs)
wkr.Reg(rv);
return rv;
}
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();
Meta_parser__fld_itm.reg_many(rv, Db_meta_fld.Tid_byte , Sqlite_tid.Tid_int , 0, "tinyint", "int2");
Meta_parser__fld_itm.reg_many(rv, Db_meta_fld.Tid_short , Sqlite_tid.Tid_int , 0, "smallint");
Meta_parser__fld_itm.reg_many(rv, Db_meta_fld.Tid_int , Sqlite_tid.Tid_int , 0, "int", "integer", "mediumint");
Meta_parser__fld_itm.reg_many(rv, Db_meta_fld.Tid_long , Sqlite_tid.Tid_int , 0, "bigint", "int8"); // "UNSIGNED BIG INT"
Meta_parser__fld_itm.reg_many(rv, Db_meta_fld.Tid_str , Sqlite_tid.Tid_text , 1, "character", "varchar", "nchar"); // "varying character", "native character"
Meta_parser__fld_itm.reg_many(rv, Db_meta_fld.Tid_text , Sqlite_tid.Tid_text , 0, "text", "clob");
Meta_parser__fld_itm.reg_many(rv, Db_meta_fld.Tid_bry , Sqlite_tid.Tid_none , 0, "blob");
Meta_parser__fld_itm.reg_many(rv, Db_meta_fld.Tid_float , Sqlite_tid.Tid_real , 0, "float");
Meta_parser__fld_itm.reg_many(rv, Db_meta_fld.Tid_double , Sqlite_tid.Tid_real , 0, "real", "double"); // "double precision"
Meta_parser__fld_itm.reg_many(rv, Db_meta_fld.Tid_decimal , Sqlite_tid.Tid_numeric , 0, "numeric");
Meta_parser__fld_itm.reg_many(rv, Db_meta_fld.Tid_decimal , Sqlite_tid.Tid_numeric , 2, "decimal");
Meta_parser__fld_itm.reg_many(rv, Db_meta_fld.Tid_decimal , Sqlite_tid.Tid_numeric , 2, "decimal");
Meta_parser__fld_itm.reg_many(rv, Db_meta_fld.Tid_bool , Sqlite_tid.Tid_numeric , 0, "boolean", "bit"); // "bit" is not SQLITE
Meta_parser__fld_itm.reg_many(rv, Db_meta_fld.Tid_date , Sqlite_tid.Tid_numeric , 0, "date", "datetime");
return rv;
}
}
class Meta_parser__fld_itm {
public Meta_parser__fld_itm(int tid_ansi, int tid_sqlite, byte[] word, int paren_itms_count) {
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 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) {
byte[] name_bry = Bry_.new_a7(names_str[i]);
Meta_parser__fld_itm itm = new Meta_parser__fld_itm(tid_ansi, tid_sqlite, name_bry, paren_itms_count);
trie.Add_obj(name_bry, itm);
}
}
}
class Sqlite_tid {
public static final int Tid_int = 1, Tid_text = 2, Tid_none = 3, Tid_real = 4, Tid_numeric = 5;
}

View File

@@ -1,71 +0,0 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.dbs.metas.parsers; import gplx.*; import gplx.dbs.*; import gplx.dbs.metas.*;
import org.junit.*;
public class Meta_parser__fld_tst {
@Before public void init() {fxt.Clear();} private Meta_parser__fld_fxt fxt = new Meta_parser__fld_fxt();
@Test public void Parse_type() {
fxt.Test_parse_type("int" , fxt.Make_type(Db_meta_fld.Tid_int));
fxt.Test_parse_type("varchar(255)" , fxt.Make_type(Db_meta_fld.Tid_str, 255));
fxt.Test_parse_type("decimal(12,10)" , fxt.Make_type(Db_meta_fld.Tid_decimal, 12, 10));
fxt.Test_parse_type(" int" , fxt.Make_type(Db_meta_fld.Tid_int));
fxt.Test_parse_type(" decimal ( 12 , 10 )" , fxt.Make_type(Db_meta_fld.Tid_decimal, 12, 10));
}
@Test public void Parse_fld() {
fxt.Test_parse_fld("name_1 int" , fxt.Make_fld("name_1", Db_meta_fld.Tid_int, Meta_fld_itm.Nullable_unknown));
fxt.Test_parse_fld("name_1 int null" , fxt.Make_fld("name_1", Db_meta_fld.Tid_int, Meta_fld_itm.Nullable_null));
fxt.Test_parse_fld("name_1 int not null" , fxt.Make_fld("name_1", Db_meta_fld.Tid_int, Meta_fld_itm.Nullable_not_null));
fxt.Test_parse_fld("name_1 int not null autoincrement" , fxt.Make_fld("name_1", Db_meta_fld.Tid_int, Meta_fld_itm.Nullable_not_null, Bool_.N, Bool_.Y));
fxt.Test_parse_fld("name_1 int not null primary key" , fxt.Make_fld("name_1", Db_meta_fld.Tid_int, Meta_fld_itm.Nullable_not_null, Bool_.Y, Bool_.N));
fxt.Test_parse_fld("name_1 int not null default -1" , fxt.Make_fld("name_1", Db_meta_fld.Tid_int, Meta_fld_itm.Nullable_not_null, Bool_.Y, Bool_.N, -1));
fxt.Test_parse_fld("name_1 int not null default 'abc'" , fxt.Make_fld("name_1", Db_meta_fld.Tid_int, Meta_fld_itm.Nullable_not_null, Bool_.Y, Bool_.N, "abc"));
}
}
class Meta_parser__fld_fxt {
private final Meta_parser__fld fld_parser = new Meta_parser__fld();
private final Sql_bry_rdr rdr = new Sql_bry_rdr();
public void Clear() {}
public Meta_type_itm Make_type(int tid_ansi) {return new Meta_type_itm(tid_ansi, -1, null, Int_.Min_value, Int_.Min_value);}
public Meta_type_itm Make_type(int tid_ansi, int len_1) {return new Meta_type_itm(tid_ansi, -1, null, len_1, Int_.Min_value);}
public Meta_type_itm Make_type(int tid_ansi, int len_1, int len_2) {return new Meta_type_itm(tid_ansi, -1, null, len_1, len_2);}
public Meta_fld_itm Make_fld(String name, int tid_ansi, int nullable) {return Make_fld(name, tid_ansi, nullable, false, false, null);}
public Meta_fld_itm Make_fld(String name, int tid_ansi, int nullable, boolean autonumber, boolean primary_key) {return Make_fld(name, tid_ansi, nullable, false, false, null);}
public Meta_fld_itm Make_fld(String name, int tid_ansi, int nullable, boolean autonumber, boolean primary_key, Object default_val) {
Meta_fld_itm rv = new Meta_fld_itm(name, Make_type(tid_ansi));
rv.Nullable_tid_(nullable);
if (autonumber) rv.Autonumber_y_();
if (primary_key) rv.Primary_key_y_();
rv.Default_val_(default_val);
return rv;
}
public void Test_parse_type(String src, Meta_type_itm expd_type) {
rdr.Init(Bry_.new_u8(src));
Meta_type_itm actl_type = fld_parser.Parse_type(rdr);
Tfds.Eq(expd_type.Tid_ansi() , actl_type.Tid_ansi());
Tfds.Eq(expd_type.Len_1() , actl_type.Len_1());
Tfds.Eq(expd_type.Len_2() , actl_type.Len_2());
}
public void Test_parse_fld(String src, Meta_fld_itm expd_fld) {
rdr.Init(Bry_.new_u8(src));
Meta_fld_itm actl_fld = fld_parser.Parse_fld(rdr);
Tfds.Eq(expd_fld.Name() , actl_fld.Name());
Tfds.Eq(expd_fld.Type().Tid_ansi() , actl_fld.Type().Tid_ansi());
Tfds.Eq(expd_fld.Nullable_tid() , actl_fld.Nullable_tid());
Tfds.Eq(Object_.Xto_str_strict_or_empty(expd_fld.Default_val()), Object_.Xto_str_strict_or_empty(actl_fld.Default_val()));
}
}

View File

@@ -1,57 +0,0 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.dbs.metas.parsers; import gplx.*; import gplx.dbs.*; import gplx.dbs.metas.*;
import gplx.core.brys.*; import gplx.core.btries.*;
public class Meta_parser__tbl {
private final Sql_bry_rdr rdr = new Sql_bry_rdr();
private final Meta_parser__fld fld_parser = new Meta_parser__fld();
private Meta_tbl_itm tbl;
public Meta_tbl_itm Parse(byte[] src) {
src = Bry_.Lcase__all(src);
rdr.Init(src);
tbl = null;
Parse_hdr();
Parse_flds();
return tbl;
}
private void Parse_hdr() {
rdr.Skip_ws().Chk_bry_or_fail(Tkn_create);
rdr.Skip_ws().Chk_bry_or_fail(Tkn_table);
byte[] tbl_name = rdr.Read_sql_identifier();
this.tbl = new Meta_tbl_itm(String_.new_u8(tbl_name), String_.new_u8(rdr.Src()));
rdr.Skip_ws().Chk_byte_or_fail(Byte_ascii.Paren_bgn);
}
private void Parse_flds() {
byte[] src = rdr.Src();
while (true) {
Meta_fld_itm fld = fld_parser.Parse_fld(rdr); if (fld == null) throw Err_.new_wo_type("unknown field", "src", rdr.Src());
tbl.Flds().Add(fld);
int pos = rdr.Pos();
byte b = pos == rdr.Src_len() ? Byte_ascii.Null : src[pos];
switch (b) {
case Byte_ascii.Comma: rdr.Pos_add_one(); break;
case Byte_ascii.Paren_end: rdr.Pos_add_one(); return;
default: throw Err_.new_wo_type("premature end of flds", "src", rdr.Mid_by_len_safe(40));
}
}
}
private static final byte[]
Tkn_create = Bry_.new_a7("create")
, Tkn_table = Bry_.new_a7("table")
;
}

View File

@@ -17,14 +17,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.dbs.metas.parsers; import gplx.*; import gplx.dbs.*; import gplx.dbs.metas.*;
import gplx.core.brys.*;
public class Sql_bry_rdr extends Bry_rdr_old { public byte[] Read_sql_identifier() {
public class Sql_bry_rdr extends Bry_rdr { public byte[] Read_sql_identifier() {
this.Skip_ws();
int bgn = pos, end = -1;
if (pos == src_len) return null;
if (pos == src_end) return null;
if (src[pos] == Byte_ascii.Brack_bgn) { // EX: [name with space]
bgn = ++pos; // set bgn after [
end = this.Find_fwd(Byte_ascii.Brack_end);
pos = end + 1; // set pos after ]
end = this.Find_fwd_lr(Byte_ascii.Brack_end);
}
else {
this.Skip_alpha_num_under(); // ASSUME: identifier is ASCII and alpha / num / underscore
@@ -33,8 +32,8 @@ public class Sql_bry_rdr extends Bry_rdr_old { public byte[] Read_sql_identifie
}
return Bry_.Mid(src, bgn, end);
}
@Override public Bry_rdr_old Skip_ws() {
byte b_0 = pos < src_len ? src[pos] : Byte_ascii.Null;
@Override public Bry_rdr Skip_ws() {
byte b_0 = pos < src_end ? src[pos] : Byte_ascii.Null;
byte bgn_1 = Byte_ascii.Null;
byte[] end_bry = null;
switch (b_0) {
@@ -46,12 +45,12 @@ public class Sql_bry_rdr extends Bry_rdr_old { public byte[] Read_sql_identifie
default:
return this;
}
byte b_1 = pos + 1 < src_len ? src[pos + 1] : Byte_ascii.Null;
byte b_1 = pos + 1 < src_end ? src[pos + 1] : Byte_ascii.Null;
if (b_1 != bgn_1) return this;
int end_pos = Bry_find_.Find_fwd(src, end_bry, pos + 2, src_len);
int end_pos = Bry_find_.Find_fwd(src, end_bry, pos + 2, src_end);
if (end_pos == Bry_find_.Not_found) return this;
pos = end_pos + end_bry.length;
return this.Skip_ws();
return super.Skip_ws();
}
private static final byte[] Comm_end_line = Byte_ascii.Nl_bry, Comm_end_multi = Bry_.new_a7("*/");
}

View File

@@ -41,12 +41,12 @@ class Sql_bry_rdr_fxt {
private final Sql_bry_rdr rdr = new Sql_bry_rdr();
public void Clear() {}
public void Test_skip_ws(String src, int expd_pos) {
rdr.Init(Bry_.new_u8(src));
rdr.Init_by_src(Bry_.new_u8(src));
rdr.Skip_ws();
Tfds.Eq(expd_pos, rdr.Pos());
}
public void Test_read_sql_identifier(String src, String expd) {
rdr.Init(Bry_.new_u8(src));
rdr.Init_by_src(Bry_.new_u8(src));
Tfds.Eq(expd, String_.new_u8(rdr.Read_sql_identifier()));
}
}