1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00

'v3.3.4.1'

This commit is contained in:
gnosygnu
2016-03-27 23:44:59 -04:00
parent de67253a9c
commit baaef32df2
903 changed files with 13339 additions and 8695 deletions

View File

@@ -16,8 +16,8 @@ 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.sqls.itms; import gplx.*; import gplx.dbs.*; import gplx.dbs.sqls.*;
public class Sql_from_itm {
public Sql_from_itm(Sql_tbl_itm base_tbl) {
public class Sql_from_clause {
public Sql_from_clause(Sql_tbl_itm base_tbl) {
this.Base_tbl = base_tbl;
Tbls.Add(base_tbl);
}

View File

@@ -16,13 +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.sqls.itms; import gplx.*; import gplx.dbs.*; import gplx.dbs.sqls.*;
public class Sql_group_itm {
public class Sql_group_clause {
public List_adp Flds() {return flds;} List_adp flds = List_adp_.new_();
public static Sql_group_itm new_(String... ary) {
Sql_group_itm rv = new Sql_group_itm();
public static Sql_group_clause new_(String... ary) {
Sql_group_clause rv = new Sql_group_clause();
for (String itm : ary)
rv.flds.Add(itm);
return rv;
} Sql_group_itm() {}
} Sql_group_clause() {}
}

View File

@@ -16,8 +16,8 @@ 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.sqls.itms; import gplx.*; import gplx.dbs.*; import gplx.dbs.sqls.*;
public class Sql_join_itm {
public Sql_join_itm(String trg_fld, String src_tbl, String src_fld) {
public class Sql_join_fld {
public Sql_join_fld(String trg_fld, String src_tbl, String src_fld) {
this.Trg_fld = trg_fld;
this.Src_tbl = src_tbl;
this.Src_fld = src_fld;
@@ -26,5 +26,9 @@ public class Sql_join_itm {
public final String Src_fld;
public final String Trg_fld;
public static final Sql_join_itm[] Ary__empty = new Sql_join_itm[0];
public String To_fld_sql(boolean fld_is_src, String trg_tbl) {
return fld_is_src ? Src_tbl + "." + Src_fld : trg_tbl + "." + Trg_fld;
}
public static final Sql_join_fld[] Ary__empty = new Sql_join_fld[0];
}

View File

@@ -0,0 +1,27 @@
/*
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.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;
}
}

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.sqls.itms; import gplx.*; import gplx.dbs.*; import gplx.dbs.sqls.*;
public class Sql_order_itm {
public Sql_order_itm(Sql_order_fld[] flds) {this.Flds = flds;}
public final Sql_order_fld[] Flds;
public class Sql_select_clause {
public boolean Distinct = false;
public final Sql_select_fld_list Flds = new Sql_select_fld_list();
}

View File

@@ -21,37 +21,40 @@ public abstract class Sql_select_fld {
public Sql_select_fld(String tbl, String fld, String alias) {
this.Tbl = tbl; this.Fld = fld; this.Alias = alias;
}
public final String Tbl;
public final String Fld;
public final String Alias;
public abstract String To_sql();
public final String Tbl; // tbl_alias; EX: "t1."
public final String Fld; // fld_key; EX: "fld"
public final String Alias; // alias; EX: " AS [Field Name]"; NOTE: must be fld name if no alias defined; EX: "SELECT fld1" should have tbl='', fld='fld1' and alias='fld1'
public abstract String To_fld_sql(); // EX: "t1.fld AS [Field Name]"
public String To_fld_alias() {return Alias;} // EX: "t1.fld AS [Field Name]" -> "Field Name"; "t1.fld1" -> "fld1"
public String To_fld_key() {return Tbl == Tbl__null ? Fld : Tbl + "." + Fld;}
public static final String Tbl_null = null;
public static final String Tbl__null = null, Fld__wildcard = "*";
public static Sql_select_fld New_fld (String tbl, String fld, String alias) {return new Sql_select_fld_col(tbl, fld, alias);}
public static Sql_select_fld Wildcard = Sql_select_fld_wild.Instance;
public static Sql_select_fld New_count (String tbl, String fld, String alias) {return new Sql_select_fld_count(tbl, fld, alias);}
public static Sql_select_fld New_sum (String tbl, String fld, String alias) {return new Sql_select_fld_sum(tbl, fld, alias);}
public static Sql_select_fld New_min (String tbl, String fld, String alias) {return new Sql_select_fld_minMax(CompareAble_.Less, tbl, fld, alias);}
public static Sql_select_fld New_max (String tbl, String fld, String alias) {return new Sql_select_fld_minMax(CompareAble_.More, tbl, fld, alias);}
public static String Bld_tbl_w_fld(String tbl, String fld) {return tbl == null ? fld : tbl + "." + 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);}
}
class Sql_select_fld_wild extends Sql_select_fld { Sql_select_fld_wild() {super(Tbl_null, Fld_wildcard, Fld_wildcard);}
@Override public String To_sql() {return Fld_wildcard;}
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;}
public static final Sql_select_fld_wild Instance = new Sql_select_fld_wild();
public static final String Fld_wildcard = "*";
// tdb-related functions
@Override public Object GroupBy_eval(Object groupByVal, Object curVal, ClassXtn type) {throw Err_.new_wo_type("group by eval not allowed on *");}
@Override public void GroupBy_type(ClassXtn type) {throw Err_.new_wo_type("group by type not allowed on *");}
}
class Sql_select_fld_col extends Sql_select_fld { public Sql_select_fld_col(String tbl, String fld, String alias) {super(tbl, fld, alias);}
@Override public String To_sql() {
@Override public String To_fld_sql() {
String rv = Fld;
if (this.Tbl != Tbl_null)
if (this.Tbl != Tbl__null)
rv = this.Tbl + "." + Fld;
if (!String_.Eq(Alias, Fld))
rv = rv + " AS " + Alias;

View File

@@ -19,7 +19,7 @@ package gplx.dbs.sqls.itms; import gplx.*; import gplx.dbs.*; import gplx.dbs.sq
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);}
public abstract String XtoSql_functionName();
@Override public String To_sql() {
@Override public String To_fld_sql() {
return String_.Format("{0}({1}) AS {2}", XtoSql_functionName(), Fld, Alias);
}
}

View File

@@ -18,7 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.dbs.sqls.itms; import gplx.*; import gplx.dbs.*; import gplx.dbs.sqls.*;
public class Sql_select_fld_list {
private final Ordered_hash hash = Ordered_hash_.New();
public int Len() {return hash.Count();}
public Sql_select_fld Get_at(int i) {return (Sql_select_fld)hash.Get_at(i);}
public void Add(Sql_select_fld fld) {hash.Add(fld.Alias, fld);}
public int Len() {return hash.Count();}
public Sql_select_fld_list Clear() {hash.Clear();return this;}
public Sql_select_fld Get_at(int i) {return (Sql_select_fld)hash.Get_at(i);}
public void Add(Sql_select_fld fld) {hash.Add(fld.Alias, fld);}
}

View File

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

View File

@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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_itm[] join_flds) {
public Sql_tbl_itm(int join_tid, String db, String name, String alias, Sql_join_fld[] join_flds) {
this.Join_tid = join_tid;
this.Db = db;
this.Name = name;
@@ -28,7 +28,8 @@ public class Sql_tbl_itm {
public final String Db;
public final String Name;
public final String Alias;
public final Sql_join_itm[] Join_flds;
public boolean Db_enabled = true;
public final Sql_join_fld[] Join_flds;
public static final String Alias__null = String_.Null;
public static final String Db__null = String_.Null;

View File

@@ -17,9 +17,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.dbs.sqls.itms; import gplx.*; import gplx.dbs.*; import gplx.dbs.sqls.*;
import gplx.core.criterias.*;
public class Sql_where_itm {
public class Sql_where_clause {
public Criteria Root = Criteria_.All;
public static final Object Where__null = null;
public static final Sql_where_itm All = new Sql_where_itm();
public static final Sql_where_clause All = new Sql_where_clause();
}