2014-07-03 07:48:39 +02:00
|
|
|
/**
|
|
|
|
* This is free and unencumbered software released into the public domain.
|
2014-12-04 15:31:29 +01:00
|
|
|
*
|
2014-07-03 07:48:39 +02:00
|
|
|
* Anyone is free to copy, modify, publish, use, compile, sell, or
|
|
|
|
* distribute this software, either in source code form or as a compiled
|
|
|
|
* binary, for any purpose, commercial or non-commercial, and by any
|
|
|
|
* means.
|
2014-12-04 15:31:29 +01:00
|
|
|
*
|
2014-07-03 07:48:39 +02:00
|
|
|
* In jurisdictions that recognize copyright laws, the author or authors
|
|
|
|
* of this software dedicate any and all copyright interest in the
|
|
|
|
* software to the public domain. We make this dedication for the benefit
|
|
|
|
* of the public at large and to the detriment of our heirs and
|
|
|
|
* successors. We intend this dedication to be an overt act of
|
|
|
|
* relinquishment in perpetuity of all present and future rights to this
|
|
|
|
* software under copyright law.
|
|
|
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
|
|
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
|
|
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
|
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
|
|
* OTHER DEALINGS IN THE SOFTWARE.
|
2014-12-04 15:31:29 +01:00
|
|
|
*
|
2014-07-03 07:48:39 +02:00
|
|
|
* For more information, please refer to <http://unlicense.org/>
|
|
|
|
*/
|
|
|
|
|
|
|
|
package org.mariotaku.querybuilder;
|
|
|
|
|
|
|
|
import org.mariotaku.querybuilder.query.SQLAlterTableQuery;
|
|
|
|
import org.mariotaku.querybuilder.query.SQLCreateTableQuery;
|
2014-12-04 15:31:29 +01:00
|
|
|
import org.mariotaku.querybuilder.query.SQLCreateTriggerQuery;
|
2014-07-03 07:48:39 +02:00
|
|
|
import org.mariotaku.querybuilder.query.SQLCreateViewQuery;
|
|
|
|
import org.mariotaku.querybuilder.query.SQLDropTableQuery;
|
2014-12-04 15:31:29 +01:00
|
|
|
import org.mariotaku.querybuilder.query.SQLDropTriggerQuery;
|
2014-07-03 07:48:39 +02:00
|
|
|
import org.mariotaku.querybuilder.query.SQLDropViewQuery;
|
2014-12-04 15:31:29 +01:00
|
|
|
import org.mariotaku.querybuilder.query.SQLInsertQuery;
|
2014-07-03 07:48:39 +02:00
|
|
|
import org.mariotaku.querybuilder.query.SQLSelectQuery;
|
|
|
|
|
|
|
|
public class SQLQueryBuilder {
|
|
|
|
|
2014-12-04 15:31:29 +01:00
|
|
|
private SQLQueryBuilder() {
|
|
|
|
throw new AssertionError("You can't create instance for this class");
|
|
|
|
}
|
2014-07-03 07:48:39 +02:00
|
|
|
|
2014-12-04 15:31:29 +01:00
|
|
|
public static SQLAlterTableQuery.Builder alterTable(final String table) {
|
|
|
|
return new SQLAlterTableQuery.Builder().alterTable(table);
|
|
|
|
}
|
2014-07-03 07:48:39 +02:00
|
|
|
|
2014-12-04 15:31:29 +01:00
|
|
|
public static SQLCreateTableQuery.Builder createTable(final boolean temporary, final boolean createIfNotExists,
|
|
|
|
final String name) {
|
|
|
|
return new SQLCreateTableQuery.Builder().createTable(temporary, createIfNotExists, name);
|
|
|
|
}
|
2014-07-03 07:48:39 +02:00
|
|
|
|
2014-12-04 15:31:29 +01:00
|
|
|
public static SQLCreateTableQuery.Builder createTable(final boolean createIfNotExists, final String name) {
|
|
|
|
return createTable(false, createIfNotExists, name);
|
|
|
|
}
|
2014-07-03 07:48:39 +02:00
|
|
|
|
2014-12-04 15:31:29 +01:00
|
|
|
public static SQLCreateTableQuery.Builder createTable(final String name) {
|
|
|
|
return createTable(false, false, name);
|
|
|
|
}
|
2014-07-03 07:48:39 +02:00
|
|
|
|
2014-12-04 15:31:29 +01:00
|
|
|
public static SQLCreateViewQuery.Builder createView(final boolean temporary, final boolean createIfNotExists,
|
|
|
|
final String name) {
|
|
|
|
return new SQLCreateViewQuery.Builder().createView(temporary, createIfNotExists, name);
|
|
|
|
}
|
2014-07-03 07:48:39 +02:00
|
|
|
|
|
|
|
|
2014-12-04 15:31:29 +01:00
|
|
|
public static SQLCreateTriggerQuery.Builder createTrigger(final boolean temporary, final boolean createIfNotExists,
|
|
|
|
final String name) {
|
|
|
|
return new SQLCreateTriggerQuery.Builder().createTrigger(temporary, createIfNotExists, name);
|
|
|
|
}
|
2014-07-03 07:48:39 +02:00
|
|
|
|
2014-12-04 15:31:29 +01:00
|
|
|
public static SQLCreateViewQuery.Builder createView(final boolean createIfNotExists, final String name) {
|
|
|
|
return createView(false, createIfNotExists, name);
|
|
|
|
}
|
2014-07-03 07:48:39 +02:00
|
|
|
|
2014-12-04 15:31:29 +01:00
|
|
|
public static SQLCreateViewQuery.Builder createView(final String name) {
|
|
|
|
return createView(false, false, name);
|
|
|
|
}
|
2014-07-03 07:48:39 +02:00
|
|
|
|
2014-12-04 15:31:29 +01:00
|
|
|
public static SQLDropTableQuery dropTable(final boolean dropIfExists, final String table) {
|
|
|
|
return new SQLDropTableQuery(dropIfExists, table);
|
|
|
|
}
|
2014-07-03 07:48:39 +02:00
|
|
|
|
2014-12-04 15:31:29 +01:00
|
|
|
public static SQLDropViewQuery dropView(final boolean dropIfExists, final String table) {
|
|
|
|
return new SQLDropViewQuery(dropIfExists, table);
|
|
|
|
}
|
2014-07-03 07:48:39 +02:00
|
|
|
|
2014-12-04 15:31:29 +01:00
|
|
|
public static SQLDropTriggerQuery dropTrigger(final boolean dropIfExists, final String table) {
|
|
|
|
return new SQLDropTriggerQuery(dropIfExists, table);
|
|
|
|
}
|
2014-07-03 07:48:39 +02:00
|
|
|
|
2014-12-04 15:31:29 +01:00
|
|
|
public static SQLInsertQuery.Builder insertInto(final OnConflict onConflict, final String table) {
|
|
|
|
return new SQLInsertQuery.Builder().insertInto(onConflict, table);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static SQLInsertQuery.Builder insertInto(final String table) {
|
|
|
|
return insertInto(null, table);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static SQLSelectQuery.Builder select(final boolean distinct, final Selectable select) {
|
|
|
|
return new SQLSelectQuery.Builder().select(distinct, select);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static SQLSelectQuery.Builder select(final Selectable select) {
|
|
|
|
return select(false, select);
|
|
|
|
}
|
2014-07-03 07:48:39 +02:00
|
|
|
}
|