getAllKeywords(File file) throws Exception {
return getAllKeywordsUsingRegex(file);
}
- private static void replaceInFile(File file, Pattern pattern, String replacement) throws IOException {
+ private static void replaceInFile(File file, Pattern pattern, String replacement)
+ throws IOException {
Path path = file.toPath();
Charset charset = Charset.defaultCharset();
@@ -322,7 +279,8 @@ public static void writeKeywordsDocumentationFile(File file) throws IOException
builder.append("***********************\n");
builder.append("\n");
- builder.append("The following Keywords are **restricted** in JSQLParser-|JSQLPARSER_VERSION| and must not be used for **Naming Objects**: \n");
+ builder.append(
+ "The following Keywords are **restricted** in JSQLParser-|JSQLPARSER_VERSION| and must not be used for **Naming Objects**: \n");
builder.append("\n");
builder.append("+----------------------+-------------+-----------+\n");
@@ -330,11 +288,14 @@ public static void writeKeywordsDocumentationFile(File file) throws IOException
builder.append("+----------------------+-------------+-----------+\n");
for (Object[] keywordDefinition : ALL_RESERVED_KEYWORDS) {
- builder.append("| ").append(rightPadding(keywordDefinition[0].toString(), ' ', 20)).append(" | ");
+ builder.append("| ").append(rightPadding(keywordDefinition[0].toString(), ' ', 20))
+ .append(" | ");
int value = (int) keywordDefinition[1];
int restriction = RESTRICTED_JSQLPARSER;
- String s = (value & restriction) == restriction || (restriction & value) == value ? "Yes" : "";
+ String s =
+ (value & restriction) == restriction || (restriction & value) == value ? "Yes"
+ : "";
builder.append(rightPadding(s, ' ', 11)).append(" | ");
restriction = RESTRICTED_SQL2016;
diff --git a/src/main/java/net/sf/jsqlparser/parser/feature/Feature.java b/src/main/java/net/sf/jsqlparser/parser/feature/Feature.java
index d9fbe1811..7d7e94a72 100644
--- a/src/main/java/net/sf/jsqlparser/parser/feature/Feature.java
+++ b/src/main/java/net/sf/jsqlparser/parser/feature/Feature.java
@@ -44,7 +44,6 @@
import net.sf.jsqlparser.statement.execute.Execute;
import net.sf.jsqlparser.statement.grant.Grant;
import net.sf.jsqlparser.statement.merge.Merge;
-import net.sf.jsqlparser.statement.replace.Replace;
import net.sf.jsqlparser.statement.select.Fetch;
import net.sf.jsqlparser.statement.select.First;
import net.sf.jsqlparser.statement.select.KSQLWindow;
@@ -53,17 +52,14 @@
import net.sf.jsqlparser.statement.select.OptimizeFor;
import net.sf.jsqlparser.statement.select.Pivot;
import net.sf.jsqlparser.statement.select.PivotXml;
-import net.sf.jsqlparser.statement.select.SelectExpressionItem;
import net.sf.jsqlparser.statement.select.Skip;
import net.sf.jsqlparser.statement.select.TableFunction;
import net.sf.jsqlparser.statement.select.Top;
import net.sf.jsqlparser.statement.select.UnPivot;
-import net.sf.jsqlparser.statement.select.ValuesList;
-import net.sf.jsqlparser.statement.show.ShowTablesStatement;
+import net.sf.jsqlparser.statement.show.*;
import net.sf.jsqlparser.statement.truncate.Truncate;
import net.sf.jsqlparser.statement.update.Update;
import net.sf.jsqlparser.statement.upsert.Upsert;
-import net.sf.jsqlparser.statement.values.ValuesStatement;
public enum Feature {
@@ -113,6 +109,7 @@ public enum Feature {
limitOffset,
/**
* "OFFSET offset"
+ *
* @see Offset
*/
offset,
@@ -129,12 +126,12 @@ public enum Feature {
fetch,
/**
* "FETCH FIRST row_count (ROW | ROWS) ONLY"
+ *
* @see Fetch#isFetchParamFirst()
*/
fetchFirst,
/**
- * "FETCH NEXT row_count (ROW | ROWS) ONLY"
- * if not {@link #fetchFirst}
+ * "FETCH NEXT row_count (ROW | ROWS) ONLY" if not {@link #fetchFirst}
*
* @see Fetch#isFetchParamFirst()
*/
@@ -193,8 +190,7 @@ public enum Feature {
*/
joinApply,
- joinWindow,
- joinUsingColumns,
+ joinWindow, joinUsingColumns,
/**
* "SKIP variable" | "SKIP ?" | "SKIP rowCount"
@@ -203,9 +199,7 @@ public enum Feature {
*/
skip,
/**
- * "FIRST" \?|[0-9]+|variable
- * or
- * "LIMIT" \?|[0-9]+|variable
+ * "FIRST" \?|[0-9]+|variable or "LIMIT" \?|[0-9]+|variable
*
* @see First
*/
@@ -298,7 +292,7 @@ public enum Feature {
/**
* "RETURNING expr(, expr)*"
*
- * @see SelectExpressionItem
+ * @see net.sf.jsqlparser.expression.operators.relational.ExpressionList
*/
insertReturningExpressionList,
@@ -307,7 +301,7 @@ public enum Feature {
*/
insertValues,
/**
- * @see ValuesStatement
+ * @see net.sf.jsqlparser.statement.select.Values
*/
values,
@@ -328,13 +322,11 @@ public enum Feature {
/**
* UPDATE table SET (col, ...) = (SELECT col, ... )"
*/
- updateUseSelect,
- updateOrderBy,
- updateLimit,
+ updateUseSelect, updateOrderBy, updateLimit,
/**
* "RETURNING expr(, expr)*"
*
- * @see SelectExpressionItem
+ * @see net.sf.jsqlparser.statement.select.SelectItem
*/
updateReturning,
/**
@@ -362,7 +354,7 @@ public enum Feature {
/**
* "RETURNING expr(, expr)*"
*
- * @see SelectExpressionItem
+ * @see net.sf.jsqlparser.statement.select.SelectItem
*/
deleteReturningExpressionList,
@@ -429,8 +421,7 @@ public enum Feature {
*
* @see Execute
*/
- execute,
- executeExec, executeCall, executeExecute,
+ execute, executeExec, executeCall, executeExecute,
/**
* SQL "EXECUTE" statement is allowed
@@ -445,7 +436,6 @@ public enum Feature {
/**
* SQL "REPLACE" statement is allowed
*
- * @see Replace
*/
@Deprecated
replace,
@@ -454,13 +444,7 @@ public enum Feature {
*
* @see Drop
*/
- drop,
- dropTable,
- dropIndex,
- dropView,
- dropSchema,
- dropSequence,
- dropTableIfExists, dropIndexIfExists, dropViewIfExists, dropSchemaIfExists, dropSequenceIfExists,
+ drop, dropTable, dropIndex, dropView, dropSchema, dropSequence, dropTableIfExists, dropIndexIfExists, dropViewIfExists, dropSchemaIfExists, dropSequenceIfExists,
/**
* SQL "CREATE SCHEMA" statement is allowed
@@ -650,21 +634,16 @@ public enum Feature {
*/
pivotXml,
- setOperation,
- setOperationUnion,
- setOperationIntersect,
- setOperationExcept,
- setOperationMinus,
+ setOperation, setOperationUnion, setOperationIntersect, setOperationExcept, setOperationMinus,
/**
* "WITH name query"
*/
- withItem,
- withItemRecursive,
+ withItem, withItemRecursive,
lateralSubSelect,
/**
- * @see ValuesList
+ * @see net.sf.jsqlparser.statement.select.Values
*/
valuesList,
/**
@@ -722,14 +701,11 @@ public enum Feature {
*
* @see OracleHierarchicalExpression
*/
- oracleHierarchicalExpression,
- oracleOrderBySiblings,
+ oracleHierarchicalExpression, oracleOrderBySiblings,
// MYSQL
- mySqlHintStraightJoin,
- mysqlSqlCacheFlag,
- mysqlCalcFoundRows,
+ mySqlHintStraightJoin, mysqlSqlCacheFlag, mysqlCalcFoundRows,
// SQLSERVER
@@ -744,35 +720,33 @@ public enum Feature {
allowSquareBracketQuotation(false),
/**
- * allow parsing of RDBMS specific syntax by switching off SQL Standard
- * Compliant Syntax
+ * allow parsing of RDBMS specific syntax by switching off SQL Standard Compliant Syntax
*/
allowPostgresSpecificSyntax(false),
// PERFORMANCE
/**
- * allows complex expression parameters or named parameters for functions
- * will be switched off, when deep nesting of functions is detected
+ * allows complex expression parameters or named parameters for functions will be switched off,
+ * when deep nesting of functions is detected
*/
allowComplexParsing(true),
/**
- * allows passing through Unsupported Statements as a plain List of Tokens
- * needs to be switched off, when VALIDATING statements or parsing blocks
+ * allows passing through Unsupported Statements as a plain List of Tokens needs to be switched
+ * off, when VALIDATING statements or parsing blocks
*/
allowUnsupportedStatements(false),
- timeOut( 6000),
+ timeOut(8000),
/**
* allows Backslash '\' as Escape Character
*/
- allowBackslashEscapeCharacter(false),
- ;
+ allowBackslashEscapeCharacter(false),;
- private Object value;
- private boolean configurable;
+ private final Object value;
+ private final boolean configurable;
/**
* a feature which can't configured within the parser
@@ -785,7 +759,7 @@ public enum Feature {
/**
* a feature which can be configured by {@link FeatureConfiguration}
*
- * @param value
+ * @param value The Value Object of the Parameter.
*/
Feature(Object value) {
this.value = value;
diff --git a/src/main/java/net/sf/jsqlparser/parser/feature/FeatureConfiguration.java b/src/main/java/net/sf/jsqlparser/parser/feature/FeatureConfiguration.java
index a8aceb5ce..dc72652ba 100644
--- a/src/main/java/net/sf/jsqlparser/parser/feature/FeatureConfiguration.java
+++ b/src/main/java/net/sf/jsqlparser/parser/feature/FeatureConfiguration.java
@@ -61,8 +61,8 @@ public boolean getAsBoolean(Feature f) {
return Boolean.parseBoolean(String.valueOf(getValue(f)));
}
- public Integer getAsInteger(Feature f) {
- return Integer.valueOf(String.valueOf(getValue(f)));
+ public Long getAsLong(Feature f) {
+ return Long.valueOf(String.valueOf(getValue(f)));
}
public String getAsString(Feature f) {
diff --git a/src/main/java/net/sf/jsqlparser/schema/Column.java b/src/main/java/net/sf/jsqlparser/schema/Column.java
index 482489354..684e0faf5 100644
--- a/src/main/java/net/sf/jsqlparser/schema/Column.java
+++ b/src/main/java/net/sf/jsqlparser/schema/Column.java
@@ -9,11 +9,13 @@
*/
package net.sf.jsqlparser.schema;
-import java.util.List;
+import net.sf.jsqlparser.expression.ArrayConstructor;
import net.sf.jsqlparser.expression.Expression;
import net.sf.jsqlparser.expression.ExpressionVisitor;
import net.sf.jsqlparser.parser.ASTNodeAccessImpl;
+import java.util.List;
+
/**
* A column. It can have the table name it belongs to.
*/
@@ -21,9 +23,9 @@ public class Column extends ASTNodeAccessImpl implements Expression, MultiPartNa
private Table table;
private String columnName;
+ private ArrayConstructor arrayConstructor;
- public Column() {
- }
+ public Column() {}
public Column(Table table, String columnName) {
setTable(table);
@@ -39,28 +41,41 @@ public Column(String columnName) {
this(null, columnName);
}
+ public ArrayConstructor getArrayConstructor() {
+ return arrayConstructor;
+ }
+
+ public Column setArrayConstructor(ArrayConstructor arrayConstructor) {
+ this.arrayConstructor = arrayConstructor;
+ return this;
+ }
+
/**
- * Retrieve the information regarding the {@code Table} this {@code Column} does
- * belong to, if any can be inferred.
- *
- * The inference is based only on local information, and not on the whole SQL command.
- * For example, consider the following query:
- *
- * SELECT x FROM Foo
- *
- * Given the {@code Column} called {@code x}, this method would return {@code null},
- * and not the info about the table {@code Foo}.
- * On the other hand, consider:
- *
- * SELECT t.x FROM Foo t
- *
- * Here, we will get a {@code Table} object for a table called {@code t}.
- * But because the inference is local, such object will not know that {@code t} is
- * just an alias for {@code Foo}.
- *
- * @return an instance of {@link net.sf.jsqlparser.schema.Table} representing the
- * table this column does belong to, if it can be inferred. Can be {@code null}.
- */
+ * Retrieve the information regarding the {@code Table} this {@code Column} does belong to, if
+ * any can be inferred.
+ *
+ * The inference is based only on local information, and not on the whole SQL command. For
+ * example, consider the following query:
+ *
+ *
+ * SELECT x FROM Foo
+ *
+ *
+ *
Given the {@code Column} called {@code x}, this method would return
+ * {@code null}, and not the info about the table {@code Foo}. On the other hand, consider:
+ *
+ *
+ *
+ * SELECT t.x FROM Foo t
+ *
+ *
+ *
Here, we will get a {@code Table} object for a table called {@code t}. But
+ * because the inference is local, such object will not know that {@code t} is just an alias for
+ * {@code Foo}.
+ *
+ * @return an instance of {@link net.sf.jsqlparser.schema.Table} representing the table this
+ * column does belong to, if it can be inferred. Can be {@code null}.
+ */
public Table getTable() {
return table;
}
@@ -79,10 +94,10 @@ public void setColumnName(String string) {
@Override
public String getFullyQualifiedName() {
- return getName(false);
+ return getFullyQualifiedName(false);
}
- public String getName(boolean aliases) {
+ public String getFullyQualifiedName(boolean aliases) {
StringBuilder fqn = new StringBuilder();
if (table != null) {
@@ -98,9 +113,20 @@ public String getName(boolean aliases) {
if (columnName != null) {
fqn.append(columnName);
}
+
+ if (arrayConstructor != null) {
+ fqn.append(arrayConstructor);
+ }
+
return fqn.toString();
}
+ // old and confusing, don't use it!
+ @Deprecated
+ public String getName(boolean aliases) {
+ return columnName;
+ }
+
@Override
public void accept(ExpressionVisitor expressionVisitor) {
expressionVisitor.visit(this);
@@ -108,7 +134,7 @@ public void accept(ExpressionVisitor expressionVisitor) {
@Override
public String toString() {
- return getName(true);
+ return getFullyQualifiedName(true);
}
public Column withTable(Table table) {
diff --git a/src/main/java/net/sf/jsqlparser/schema/Sequence.java b/src/main/java/net/sf/jsqlparser/schema/Sequence.java
index 0f0ffba56..0997eefb8 100644
--- a/src/main/java/net/sf/jsqlparser/schema/Sequence.java
+++ b/src/main/java/net/sf/jsqlparser/schema/Sequence.java
@@ -1,20 +1,21 @@
-/*
+/*-
* #%L
* JSQLParser library
* %%
- * Copyright (C) 2004 - 2020 JSQLParser
+ * Copyright (C) 2004 - 2019 JSQLParser
* %%
* Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.schema;
+import net.sf.jsqlparser.parser.ASTNodeAccessImpl;
+
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
-import net.sf.jsqlparser.parser.ASTNodeAccessImpl;
/**
* Represents the database type for a {@code SEQUENCE}
@@ -29,8 +30,7 @@ public class Sequence extends ASTNodeAccessImpl implements MultiPartName {
private List parameters;
- public Sequence() {
- }
+ public Sequence() {}
public Sequence(List partItems) {
this.partItems = new ArrayList<>(partItems);
@@ -153,23 +153,11 @@ public Sequence addParameters(Collection extends Parameter> parameters) {
* The available parameters to a sequence
*/
public enum ParameterType {
- INCREMENT_BY,
- START_WITH,
- RESTART_WITH,
- MAXVALUE,
- NOMAXVALUE,
- MINVALUE,
- NOMINVALUE,
- CYCLE,
- NOCYCLE,
- CACHE,
- NOCACHE,
- ORDER,
- NOORDER,
- KEEP,
- NOKEEP,
- SESSION,
- GLOBAL
+ INCREMENT_BY, START_WITH, RESTART_WITH, MAXVALUE, NOMAXVALUE, MINVALUE, NOMINVALUE, CYCLE, NOCYCLE, CACHE, NOCACHE, ORDER, NOORDER, KEEP, NOKEEP, SESSION, GLOBAL;
+
+ public static ParameterType from(String type) {
+ return Enum.valueOf(ParameterType.class, type.toUpperCase());
+ }
}
/**
diff --git a/src/main/java/net/sf/jsqlparser/schema/Table.java b/src/main/java/net/sf/jsqlparser/schema/Table.java
index 0d248910f..744010ca4 100644
--- a/src/main/java/net/sf/jsqlparser/schema/Table.java
+++ b/src/main/java/net/sf/jsqlparser/schema/Table.java
@@ -20,6 +20,7 @@
import net.sf.jsqlparser.statement.select.FromItemVisitor;
import net.sf.jsqlparser.statement.select.IntoTableVisitor;
import net.sf.jsqlparser.statement.select.Pivot;
+import net.sf.jsqlparser.statement.select.SampleClause;
import net.sf.jsqlparser.statement.select.UnPivot;
/**
@@ -42,6 +43,8 @@ public class Table extends ASTNodeAccessImpl implements FromItem, MultiPartName
private Alias alias;
+ private SampleClause sampleClause;
+
private Pivot pivot;
private UnPivot unpivot;
@@ -50,8 +53,7 @@ public class Table extends ASTNodeAccessImpl implements FromItem, MultiPartName
private SQLServerHints sqlServerHints;
- public Table() {
- }
+ public Table() {}
public Table(String name) {
setName(name);
@@ -104,10 +106,10 @@ public void setSchemaName(String schemaName) {
public String getName() {
String name = getIndex(NAME_IDX);
- if (name!=null && name.contains("@")) {
+ if (name != null && name.contains("@")) {
int pos = name.lastIndexOf('@');
- if (pos>0) {
- name = name.substring(0, pos );
+ if (pos > 0) {
+ name = name.substring(0, pos);
}
}
return name;
@@ -115,10 +117,10 @@ public String getName() {
public String getDBLinkName() {
String name = getIndex(NAME_IDX);
- if (name!=null && name.contains("@")) {
+ if (name != null && name.contains("@")) {
int pos = name.lastIndexOf('@');
- if (pos>0 && name.length()>1) {
- name = name.substring(pos+1);
+ if (pos > 0 && name.length() > 1) {
+ name = name.substring(pos + 1);
}
}
return name;
@@ -232,12 +234,46 @@ public void setSqlServerHints(SQLServerHints sqlServerHints) {
this.sqlServerHints = sqlServerHints;
}
+ public SampleClause getSampleClause() {
+ return sampleClause;
+ }
+
+ public Table setSampleClause(SampleClause sampleClause) {
+ this.sampleClause = sampleClause;
+ return this;
+ }
+
+ public StringBuilder appendTo(StringBuilder builder) {
+ builder.append(getFullyQualifiedName());
+ if (alias != null) {
+ builder.append(alias);
+ }
+
+ if (sampleClause != null) {
+ sampleClause.appendTo(builder);
+ }
+
+ if (pivot != null) {
+ builder.append(" ").append(pivot);
+ }
+
+ if (unpivot != null) {
+ builder.append(" ").append(unpivot);
+ }
+
+ if (mysqlHints != null) {
+ builder.append(mysqlHints);
+ }
+
+ if (sqlServerHints != null) {
+ builder.append(sqlServerHints);
+ }
+ return builder;
+ }
+
@Override
public String toString() {
- return getFullyQualifiedName() + ((alias != null) ? alias.toString() : "")
- + ((pivot != null) ? " " + pivot : "") + ((unpivot != null) ? " " + unpivot : "")
- + ((mysqlHints != null) ? mysqlHints.toString() : "")
- + ((sqlServerHints != null) ? sqlServerHints.toString() : "");
+ return appendTo(new StringBuilder()).toString();
}
@Override
diff --git a/src/main/java/net/sf/jsqlparser/statement/DeclareType.java b/src/main/java/net/sf/jsqlparser/statement/DeclareType.java
index 8e0d7119c..c63c686a4 100644
--- a/src/main/java/net/sf/jsqlparser/statement/DeclareType.java
+++ b/src/main/java/net/sf/jsqlparser/statement/DeclareType.java
@@ -14,5 +14,9 @@
* @author tobens
*/
public enum DeclareType {
- TABLE, AS, TYPE
+ TABLE, AS, TYPE;
+
+ public static DeclareType from(String type) {
+ return Enum.valueOf(DeclareType.class, type.toUpperCase());
+ }
}
diff --git a/src/main/java/net/sf/jsqlparser/statement/ExplainStatement.java b/src/main/java/net/sf/jsqlparser/statement/ExplainStatement.java
index b360ac8a1..2957472db 100644
--- a/src/main/java/net/sf/jsqlparser/statement/ExplainStatement.java
+++ b/src/main/java/net/sf/jsqlparser/statement/ExplainStatement.java
@@ -53,8 +53,10 @@ public void addOption(Option option) {
/**
* Returns the first option that matches this optionType
+ *
* @param optionType the option type to retrieve an Option for
- * @return an option of that type, or null. In case of duplicate options, the first found option will be returned.
+ * @return an option of that type, or null. In case of duplicate options, the first found option
+ * will be returned.
*/
public Option getOption(OptionType optionType) {
if (options == null) {
@@ -68,7 +70,8 @@ public String toString() {
StringBuilder statementBuilder = new StringBuilder("EXPLAIN");
if (options != null) {
statementBuilder.append(" ");
- statementBuilder.append(options.values().stream().map(Option::formatOption).collect(Collectors.joining(" ")));
+ statementBuilder.append(options.values().stream().map(Option::formatOption)
+ .collect(Collectors.joining(" ")));
}
statementBuilder.append(" ");
@@ -82,11 +85,11 @@ public void accept(StatementVisitor statementVisitor) {
}
public enum OptionType {
- ANALYZE,
- VERBOSE,
- COSTS,
- BUFFERS,
- FORMAT
+ ANALYZE, VERBOSE, COSTS, BUFFERS, FORMAT;
+
+ public static OptionType from(String type) {
+ return Enum.valueOf(OptionType.class, type.toUpperCase());
+ }
}
public static class Option implements Serializable {
@@ -111,9 +114,9 @@ public void setValue(String value) {
}
public String formatOption() {
- return type.name() + ( value != null
- ? " " + value
- : "" );
+ return type.name() + (value != null
+ ? " " + value
+ : "");
}
public Option withValue(String value) {
diff --git a/src/main/java/net/sf/jsqlparser/statement/OutputClause.java b/src/main/java/net/sf/jsqlparser/statement/OutputClause.java
index 5d05ead92..fe2fd60ac 100644
--- a/src/main/java/net/sf/jsqlparser/statement/OutputClause.java
+++ b/src/main/java/net/sf/jsqlparser/statement/OutputClause.java
@@ -21,9 +21,11 @@
/**
* T-SQL Output Clause
*
- * @see OUTPUT Clause (Transact-SQL)
+ * @see OUTPUT
+ * Clause (Transact-SQL)
*
- *
+ *
* <OUTPUT_CLAUSE> ::=
* {
* [ OUTPUT <dml_select_list> INTO { @table_variable | output_table } [ ( column_list ) ] ]
@@ -36,26 +38,28 @@
* <column_name> ::=
* { DELETED | INSERTED | from_table_name } . { * | column_name }
* | $action
- *
+ *
*/
public class OutputClause implements Serializable {
- List selectItemList;
+ List> selectItemList;
UserVariable tableVariable;
Table outputTable;
List columnList;
- public OutputClause(List selectItemList, UserVariable tableVariable, Table outputTable, List columnList) {
- this.selectItemList = Objects.requireNonNull(selectItemList, "The Select List of the Output Clause must not be null.");
+ public OutputClause(List> selectItemList, UserVariable tableVariable,
+ Table outputTable, List columnList) {
+ this.selectItemList = Objects.requireNonNull(selectItemList,
+ "The Select List of the Output Clause must not be null.");
this.tableVariable = tableVariable;
this.outputTable = outputTable;
this.columnList = columnList;
}
- public List getSelectItemList() {
+ public List> getSelectItemList() {
return selectItemList;
}
- public void setSelectItemList(List selectItemList) {
+ public void setSelectItemList(List> selectItemList) {
this.selectItemList = selectItemList;
}
diff --git a/src/main/java/net/sf/jsqlparser/statement/PurgeObjectType.java b/src/main/java/net/sf/jsqlparser/statement/PurgeObjectType.java
index 999f29ea1..c9fecb849 100644
--- a/src/main/java/net/sf/jsqlparser/statement/PurgeObjectType.java
+++ b/src/main/java/net/sf/jsqlparser/statement/PurgeObjectType.java
@@ -14,5 +14,9 @@
* @author Andreas Reichel
*/
public enum PurgeObjectType {
- TABLE, INDEX, RECYCLEBIN, DBA_RECYCLEBIN, TABLESPACE;
+ TABLE, INDEX, RECYCLEBIN, DBA_RECYCLEBIN, TABLESPACE;
+
+ public static PurgeObjectType from(String type) {
+ return Enum.valueOf(PurgeObjectType.class, type.toUpperCase());
+ }
}
diff --git a/src/main/java/net/sf/jsqlparser/statement/ReferentialAction.java b/src/main/java/net/sf/jsqlparser/statement/ReferentialAction.java
index 353dafb03..16dc9427d 100644
--- a/src/main/java/net/sf/jsqlparser/statement/ReferentialAction.java
+++ b/src/main/java/net/sf/jsqlparser/statement/ReferentialAction.java
@@ -62,7 +62,8 @@ public int hashCode() {
@Override
public String toString() {
- return new StringBuilder(" ON ").append(getType().name()).append(" ").append(getAction().getAction())
+ return new StringBuilder(" ON ").append(getType().name()).append(" ")
+ .append(getAction().getAction())
.toString();
}
@@ -78,37 +79,38 @@ public boolean equals(Object obj) {
return false;
}
ReferentialAction other = (ReferentialAction) obj;
-// if (action != other.action) {
-// return false;
-// }
-// if (type != other.type) {
-// return false;
- return action==other.action && type == other.type;
+ // if (action != other.action) {
+ // return false;
+ // }
+ // if (type != other.type) {
+ // return false;
+ return action == other.action && type == other.type;
}
public enum Type {
- DELETE,
- UPDATE
+ DELETE, UPDATE;
+
+ public static Type from(String name) {
+ return Enum.valueOf(Type.class, name.toUpperCase());
+ }
}
public enum Action {
- CASCADE("CASCADE"),
- RESTRICT("RESTRICT"),
- NO_ACTION("NO ACTION"),
- SET_DEFAULT("SET DEFAULT"),
- SET_NULL("SET NULL");
+ CASCADE("CASCADE"), RESTRICT("RESTRICT"), NO_ACTION("NO ACTION"), SET_DEFAULT(
+ "SET DEFAULT"), SET_NULL("SET NULL");
+
+ private final String action;
Action(String action) {
this.action = action;
}
- private final String action;
-
/**
* @param action
* @return the {@link Action}, if found, otherwise null
*/
- public static Action byAction(String action) {
+ public static Action from(String action) {
+ // We can't use Enum.valueOf() since there White Space involved
for (Action a : values()) {
if (a.getAction().equals(action)) {
return a;
@@ -120,11 +122,6 @@ public static Action byAction(String action) {
public String getAction() {
return action;
}
-
- @Override
- public String toString() {
- return action;
- }
}
}
diff --git a/src/main/java/net/sf/jsqlparser/statement/ReturningClause.java b/src/main/java/net/sf/jsqlparser/statement/ReturningClause.java
new file mode 100644
index 000000000..3c7525b46
--- /dev/null
+++ b/src/main/java/net/sf/jsqlparser/statement/ReturningClause.java
@@ -0,0 +1,97 @@
+/*-
+ * #%L
+ * JSQLParser library
+ * %%
+ * Copyright (C) 2004 - 2023 JSQLParser
+ * %%
+ * Dual licensed under GNU LGPL 2.1 or Apache License 2.0
+ * #L%
+ */
+package net.sf.jsqlparser.statement;
+
+import net.sf.jsqlparser.statement.select.SelectItem;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * RETURNING clause according to Part of UPDATE, INSERT, DELETE statements
+ */
+
+public class ReturningClause extends ArrayList> {
+ enum Keyword {
+ RETURN, RETURNING;
+
+ public static Keyword from(String keyword) {
+ return Enum.valueOf(Keyword.class, keyword.toUpperCase());
+ }
+ }
+
+ private Keyword keyword;
+
+ /**
+ * List of output targets like Table or UserVariable
+ */
+ private final List