You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2020/10/22 10:26:09 UTC
[shardingsphere] branch master updated: Refactor
FormatSQLVisitorFacade (#7887)
This is an automated email from the ASF dual-hosted git repository.
panjuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 666c1e2 Refactor FormatSQLVisitorFacade (#7887)
666c1e2 is described below
commit 666c1e2a867682721fc5c5eb1b732c76cbd68e68
Author: Juan Pan(Trista) <pa...@apache.org>
AuthorDate: Thu Oct 22 18:25:46 2020 +0800
Refactor FormatSQLVisitorFacade (#7887)
---
.../sql/parser/mysql/MySQLParserConfiguration.java | 8 +--
.../MySQLSQLVisitorFacade.java} | 32 +++-------
.../visitor/format/MySQLFormatSQLVisitor.java} | 27 +++-----
.../format/MySQLFormatSQLVisitorFacade.java | 68 ++++++++++++++++++++
.../format/impl/MySQLDALFormatSQLVisitor.java} | 25 +++-----
.../format/impl/MySQLDCLFormatSQLVisitor.java} | 25 +++-----
.../format/impl/MySQLDDLFormatSQLVisitor.java} | 25 +++-----
.../format/impl/MySQLDMLFormatSQLVisitor.java} | 25 +++-----
.../format/impl/MySQLRLFormatSQLVisitor.java} | 25 +++-----
.../format/impl/MySQLTCLFormatSQLVisitor.java} | 25 +++-----
.../parser/oracle/OracleParserConfiguration.java | 8 +--
.../oracle/visitor/OracleSQLVisitorFacade.java} | 46 +++++---------
.../format/OracleFormatSQLVisitorFacade.java | 62 ++++++++++++++++++
.../OracleStatementSQLVisitorFacade.java | 2 +-
.../postgresql/PostgreSQLParserConfiguration.java | 8 +--
.../visitor/PostgreSQLSQLVisitorFacade.java} | 46 +++++---------
.../format/PostgreSQLFormatSQLVisitorFacade.java | 62 ++++++++++++++++++
.../PostgreSQLStatementSQLVisitorFacade.java | 2 +-
.../sql/parser/sql92/SQL92ParserConfiguration.java | 8 +--
.../sql92/visitor/SQL92SQLVisitorFacade.java} | 46 +++++---------
.../format/SQL92FormatSQLVisitorFacade.java | 62 ++++++++++++++++++
.../SQL92StatementSQLVisitorFacade.java | 2 +-
.../sqlserver/SQLServerParserConfiguration.java | 8 +--
.../visitor/SQLServerSQLVisitorFacade.java} | 46 +++++---------
.../format/SQLServerFormatSQLVisitorFacade.java | 62 ++++++++++++++++++
.../SQLServerStatementSQLVisitorFacade.java | 2 +-
...mentSQLVisitorRule.java => SQLVisitorRule.java} | 8 +--
.../FormatSQLVisitorFactory.java} | 18 +++---
.../statement/StatementSQLVisitorFactory.java | 10 +--
.../standard/StandardSQLParserEngine.java | 4 +-
...isitorRuleTest.java => SQLVisitorRuleTest.java} | 7 +--
.../visitor/SQLVisitorFacade.java} | 35 +++--------
.../sql/parser/api/visitor/SQLVisitorType.java} | 24 ++-----
.../api/visitor/format/FormatSQLVisitorFacade.java | 73 ++++++++++++++++++++++
.../visitor/format/impl/DALFormatSQLVisitor.java} | 24 ++-----
.../visitor/format/impl/DCLFormatSQLVisitor.java} | 24 ++-----
.../visitor/format/impl/DDLFormatSQLVisitor.java} | 24 ++-----
.../visitor/format/impl/DMLFormatSQLVisitor.java} | 24 ++-----
.../visitor/format/impl/RLFormatSQLVisitor.java} | 24 ++-----
.../visitor/format/impl/TCLFormatSQLVisitor.java} | 24 ++-----
.../sql/parser/spi/SQLParserConfiguration.java | 4 +-
41 files changed, 607 insertions(+), 477 deletions(-)
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/MySQLParserConfiguration.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/MySQLParserConfiguration.java
index 90f5dc6..f0ab873 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/MySQLParserConfiguration.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/MySQLParserConfiguration.java
@@ -19,10 +19,10 @@ package org.apache.shardingsphere.sql.parser.mysql;
import org.apache.shardingsphere.sql.parser.api.lexer.SQLLexer;
import org.apache.shardingsphere.sql.parser.api.parser.SQLParser;
-import org.apache.shardingsphere.sql.parser.api.visitor.statement.StatementSQLVisitorFacade;
+import org.apache.shardingsphere.sql.parser.api.visitor.SQLVisitorFacade;
import org.apache.shardingsphere.sql.parser.mysql.lexer.MySQLLexer;
import org.apache.shardingsphere.sql.parser.mysql.parser.MySQLParser;
-import org.apache.shardingsphere.sql.parser.mysql.visitor.statement.MySQLStatementSQLVisitorFacade;
+import org.apache.shardingsphere.sql.parser.mysql.visitor.MySQLSQLVisitorFacade;
import org.apache.shardingsphere.sql.parser.spi.SQLParserConfiguration;
/**
@@ -46,7 +46,7 @@ public final class MySQLParserConfiguration implements SQLParserConfiguration {
}
@Override
- public Class<? extends StatementSQLVisitorFacade> getVisitorFacadeClass() {
- return MySQLStatementSQLVisitorFacade.class;
+ public Class<? extends SQLVisitorFacade> getVisitorFacadeClass() {
+ return MySQLSQLVisitorFacade.class;
}
}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/MySQLParserConfiguration.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/MySQLSQLVisitorFacade.java
similarity index 55%
copy from shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/MySQLParserConfiguration.java
copy to shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/MySQLSQLVisitorFacade.java
index 90f5dc6..3a3ac04 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/MySQLParserConfiguration.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/MySQLSQLVisitorFacade.java
@@ -15,38 +15,26 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sql.parser.mysql;
+package org.apache.shardingsphere.sql.parser.mysql.visitor;
-import org.apache.shardingsphere.sql.parser.api.lexer.SQLLexer;
-import org.apache.shardingsphere.sql.parser.api.parser.SQLParser;
+import org.apache.shardingsphere.sql.parser.api.visitor.SQLVisitorFacade;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.FormatSQLVisitorFacade;
import org.apache.shardingsphere.sql.parser.api.visitor.statement.StatementSQLVisitorFacade;
-import org.apache.shardingsphere.sql.parser.mysql.lexer.MySQLLexer;
-import org.apache.shardingsphere.sql.parser.mysql.parser.MySQLParser;
+import org.apache.shardingsphere.sql.parser.mysql.visitor.format.MySQLFormatSQLVisitorFacade;
import org.apache.shardingsphere.sql.parser.mysql.visitor.statement.MySQLStatementSQLVisitorFacade;
-import org.apache.shardingsphere.sql.parser.spi.SQLParserConfiguration;
/**
- * SQL parser configuration for MySQL.
+ * MySQL SQL visitor facade.
*/
-public final class MySQLParserConfiguration implements SQLParserConfiguration {
+public final class MySQLSQLVisitorFacade implements SQLVisitorFacade {
@Override
- public String getDatabaseTypeName() {
- return "MySQL";
- }
-
- @Override
- public Class<? extends SQLLexer> getLexerClass() {
- return MySQLLexer.class;
- }
-
- @Override
- public Class<? extends SQLParser> getParserClass() {
- return MySQLParser.class;
+ public Class<? extends StatementSQLVisitorFacade> getStatementSQLVisitorFacadeClass() {
+ return MySQLStatementSQLVisitorFacade.class;
}
@Override
- public Class<? extends StatementSQLVisitorFacade> getVisitorFacadeClass() {
- return MySQLStatementSQLVisitorFacade.class;
+ public Class<? extends FormatSQLVisitorFacade> getFormatSQLVisitorFacadeClass() {
+ return MySQLFormatSQLVisitorFacade.class;
}
}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/StatementSQLVisitorRuleTest.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/format/MySQLFormatSQLVisitor.java
similarity index 52%
copy from shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/StatementSQLVisitorRuleTest.java
copy to shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/format/MySQLFormatSQLVisitor.java
index 6263b3a..9021a9c 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/StatementSQLVisitorRuleTest.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/format/MySQLFormatSQLVisitor.java
@@ -15,24 +15,15 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sql.parser.core.visitor;
+package org.apache.shardingsphere.sql.parser.mysql.visitor.format;
-import org.antlr.v4.runtime.tree.ParseTree;
-import org.apache.shardingsphere.sql.parser.core.visitor.statement.StatementSQLVisitorRule;
-import org.junit.Test;
+import lombok.AccessLevel;
+import lombok.Getter;
+import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementBaseVisitor;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-public final class StatementSQLVisitorRuleTest {
-
- @Test
- public void assertValueOfParseTreeClassSuccess() {
- assertThat(StatementSQLVisitorRule.valueOf(SelectContext.class), is(StatementSQLVisitorRule.SELECT));
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void assertValueOfParseTreeClassFailure() {
- StatementSQLVisitorRule.valueOf(ParseTree.class);
- }
+/**
+ * MySQL Format SQL visitor.
+ */
+@Getter(AccessLevel.PROTECTED)
+public abstract class MySQLFormatSQLVisitor extends MySQLStatementBaseVisitor<String> {
}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/format/MySQLFormatSQLVisitorFacade.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/format/MySQLFormatSQLVisitorFacade.java
new file mode 100644
index 0000000..732884c
--- /dev/null
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/format/MySQLFormatSQLVisitorFacade.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.sql.parser.mysql.visitor.format;
+
+import org.apache.shardingsphere.sql.parser.api.visitor.format.FormatSQLVisitorFacade;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.impl.DALFormatSQLVisitor;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.impl.DCLFormatSQLVisitor;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.impl.DDLFormatSQLVisitor;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.impl.DMLFormatSQLVisitor;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.impl.RLFormatSQLVisitor;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.impl.TCLFormatSQLVisitor;
+import org.apache.shardingsphere.sql.parser.mysql.visitor.format.impl.MySQLDALFormatSQLVisitor;
+import org.apache.shardingsphere.sql.parser.mysql.visitor.format.impl.MySQLDCLFormatSQLVisitor;
+import org.apache.shardingsphere.sql.parser.mysql.visitor.format.impl.MySQLDDLFormatSQLVisitor;
+import org.apache.shardingsphere.sql.parser.mysql.visitor.format.impl.MySQLDMLFormatSQLVisitor;
+import org.apache.shardingsphere.sql.parser.mysql.visitor.format.impl.MySQLRLFormatSQLVisitor;
+import org.apache.shardingsphere.sql.parser.mysql.visitor.format.impl.MySQLTCLFormatSQLVisitor;
+
+/**
+ * Format SQL Visitor facade for MySQL.
+ */
+public final class MySQLFormatSQLVisitorFacade implements FormatSQLVisitorFacade {
+
+ @Override
+ public Class<? extends DMLFormatSQLVisitor> getDMLVisitorClass() {
+ return MySQLDMLFormatSQLVisitor.class;
+ }
+
+ @Override
+ public Class<? extends DDLFormatSQLVisitor> getDDLVisitorClass() {
+ return MySQLDDLFormatSQLVisitor.class;
+ }
+
+ @Override
+ public Class<? extends TCLFormatSQLVisitor> getTCLVisitorClass() {
+ return MySQLTCLFormatSQLVisitor.class;
+ }
+
+ @Override
+ public Class<? extends DCLFormatSQLVisitor> getDCLVisitorClass() {
+ return MySQLDCLFormatSQLVisitor.class;
+ }
+
+ @Override
+ public Class<? extends DALFormatSQLVisitor> getDALVisitorClass() {
+ return MySQLDALFormatSQLVisitor.class;
+ }
+
+ @Override
+ public Class<? extends RLFormatSQLVisitor> getRLVisitorClass() {
+ return MySQLRLFormatSQLVisitor.class;
+ }
+}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/StatementSQLVisitorRuleTest.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/format/impl/MySQLDALFormatSQLVisitor.java
similarity index 52%
copy from shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/StatementSQLVisitorRuleTest.java
copy to shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/format/impl/MySQLDALFormatSQLVisitor.java
index 6263b3a..3985947 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/StatementSQLVisitorRuleTest.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/format/impl/MySQLDALFormatSQLVisitor.java
@@ -15,24 +15,13 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sql.parser.core.visitor;
+package org.apache.shardingsphere.sql.parser.mysql.visitor.format.impl;
-import org.antlr.v4.runtime.tree.ParseTree;
-import org.apache.shardingsphere.sql.parser.core.visitor.statement.StatementSQLVisitorRule;
-import org.junit.Test;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.impl.DALFormatSQLVisitor;
+import org.apache.shardingsphere.sql.parser.mysql.visitor.format.MySQLFormatSQLVisitor;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-public final class StatementSQLVisitorRuleTest {
-
- @Test
- public void assertValueOfParseTreeClassSuccess() {
- assertThat(StatementSQLVisitorRule.valueOf(SelectContext.class), is(StatementSQLVisitorRule.SELECT));
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void assertValueOfParseTreeClassFailure() {
- StatementSQLVisitorRule.valueOf(ParseTree.class);
- }
+/**
+ * DAL Format SQL visitor for MySQL.
+ */
+public final class MySQLDALFormatSQLVisitor extends MySQLFormatSQLVisitor implements DALFormatSQLVisitor {
}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/StatementSQLVisitorRuleTest.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/format/impl/MySQLDCLFormatSQLVisitor.java
similarity index 52%
copy from shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/StatementSQLVisitorRuleTest.java
copy to shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/format/impl/MySQLDCLFormatSQLVisitor.java
index 6263b3a..253319a 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/StatementSQLVisitorRuleTest.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/format/impl/MySQLDCLFormatSQLVisitor.java
@@ -15,24 +15,13 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sql.parser.core.visitor;
+package org.apache.shardingsphere.sql.parser.mysql.visitor.format.impl;
-import org.antlr.v4.runtime.tree.ParseTree;
-import org.apache.shardingsphere.sql.parser.core.visitor.statement.StatementSQLVisitorRule;
-import org.junit.Test;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.impl.DCLFormatSQLVisitor;
+import org.apache.shardingsphere.sql.parser.mysql.visitor.format.MySQLFormatSQLVisitor;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-public final class StatementSQLVisitorRuleTest {
-
- @Test
- public void assertValueOfParseTreeClassSuccess() {
- assertThat(StatementSQLVisitorRule.valueOf(SelectContext.class), is(StatementSQLVisitorRule.SELECT));
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void assertValueOfParseTreeClassFailure() {
- StatementSQLVisitorRule.valueOf(ParseTree.class);
- }
+/**
+ * DCL Format SQL visitor for MySQL.
+ */
+public final class MySQLDCLFormatSQLVisitor extends MySQLFormatSQLVisitor implements DCLFormatSQLVisitor {
}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/StatementSQLVisitorRuleTest.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/format/impl/MySQLDDLFormatSQLVisitor.java
similarity index 52%
copy from shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/StatementSQLVisitorRuleTest.java
copy to shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/format/impl/MySQLDDLFormatSQLVisitor.java
index 6263b3a..4a84d82 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/StatementSQLVisitorRuleTest.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/format/impl/MySQLDDLFormatSQLVisitor.java
@@ -15,24 +15,13 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sql.parser.core.visitor;
+package org.apache.shardingsphere.sql.parser.mysql.visitor.format.impl;
-import org.antlr.v4.runtime.tree.ParseTree;
-import org.apache.shardingsphere.sql.parser.core.visitor.statement.StatementSQLVisitorRule;
-import org.junit.Test;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.impl.DDLFormatSQLVisitor;
+import org.apache.shardingsphere.sql.parser.mysql.visitor.format.MySQLFormatSQLVisitor;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-public final class StatementSQLVisitorRuleTest {
-
- @Test
- public void assertValueOfParseTreeClassSuccess() {
- assertThat(StatementSQLVisitorRule.valueOf(SelectContext.class), is(StatementSQLVisitorRule.SELECT));
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void assertValueOfParseTreeClassFailure() {
- StatementSQLVisitorRule.valueOf(ParseTree.class);
- }
+/**
+ * DDL Format SQL visitor for MySQL.
+ */
+public final class MySQLDDLFormatSQLVisitor extends MySQLFormatSQLVisitor implements DDLFormatSQLVisitor {
}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/StatementSQLVisitorRuleTest.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/format/impl/MySQLDMLFormatSQLVisitor.java
similarity index 52%
copy from shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/StatementSQLVisitorRuleTest.java
copy to shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/format/impl/MySQLDMLFormatSQLVisitor.java
index 6263b3a..11413fa 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/StatementSQLVisitorRuleTest.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/format/impl/MySQLDMLFormatSQLVisitor.java
@@ -15,24 +15,13 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sql.parser.core.visitor;
+package org.apache.shardingsphere.sql.parser.mysql.visitor.format.impl;
-import org.antlr.v4.runtime.tree.ParseTree;
-import org.apache.shardingsphere.sql.parser.core.visitor.statement.StatementSQLVisitorRule;
-import org.junit.Test;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.impl.DMLFormatSQLVisitor;
+import org.apache.shardingsphere.sql.parser.mysql.visitor.format.MySQLFormatSQLVisitor;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-public final class StatementSQLVisitorRuleTest {
-
- @Test
- public void assertValueOfParseTreeClassSuccess() {
- assertThat(StatementSQLVisitorRule.valueOf(SelectContext.class), is(StatementSQLVisitorRule.SELECT));
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void assertValueOfParseTreeClassFailure() {
- StatementSQLVisitorRule.valueOf(ParseTree.class);
- }
+/**
+ * DML Format SQL visitor for MySQL.
+ */
+public final class MySQLDMLFormatSQLVisitor extends MySQLFormatSQLVisitor implements DMLFormatSQLVisitor {
}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/StatementSQLVisitorRuleTest.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/format/impl/MySQLRLFormatSQLVisitor.java
similarity index 52%
copy from shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/StatementSQLVisitorRuleTest.java
copy to shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/format/impl/MySQLRLFormatSQLVisitor.java
index 6263b3a..c925776 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/StatementSQLVisitorRuleTest.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/format/impl/MySQLRLFormatSQLVisitor.java
@@ -15,24 +15,13 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sql.parser.core.visitor;
+package org.apache.shardingsphere.sql.parser.mysql.visitor.format.impl;
-import org.antlr.v4.runtime.tree.ParseTree;
-import org.apache.shardingsphere.sql.parser.core.visitor.statement.StatementSQLVisitorRule;
-import org.junit.Test;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.impl.RLFormatSQLVisitor;
+import org.apache.shardingsphere.sql.parser.mysql.visitor.format.MySQLFormatSQLVisitor;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-public final class StatementSQLVisitorRuleTest {
-
- @Test
- public void assertValueOfParseTreeClassSuccess() {
- assertThat(StatementSQLVisitorRule.valueOf(SelectContext.class), is(StatementSQLVisitorRule.SELECT));
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void assertValueOfParseTreeClassFailure() {
- StatementSQLVisitorRule.valueOf(ParseTree.class);
- }
+/**
+ * RL Format SQL visitor for MySQL.
+ */
+public final class MySQLRLFormatSQLVisitor extends MySQLFormatSQLVisitor implements RLFormatSQLVisitor {
}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/StatementSQLVisitorRuleTest.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/format/impl/MySQLTCLFormatSQLVisitor.java
similarity index 52%
copy from shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/StatementSQLVisitorRuleTest.java
copy to shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/format/impl/MySQLTCLFormatSQLVisitor.java
index 6263b3a..efe472d 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/StatementSQLVisitorRuleTest.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/format/impl/MySQLTCLFormatSQLVisitor.java
@@ -15,24 +15,13 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sql.parser.core.visitor;
+package org.apache.shardingsphere.sql.parser.mysql.visitor.format.impl;
-import org.antlr.v4.runtime.tree.ParseTree;
-import org.apache.shardingsphere.sql.parser.core.visitor.statement.StatementSQLVisitorRule;
-import org.junit.Test;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.impl.TCLFormatSQLVisitor;
+import org.apache.shardingsphere.sql.parser.mysql.visitor.format.MySQLFormatSQLVisitor;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-public final class StatementSQLVisitorRuleTest {
-
- @Test
- public void assertValueOfParseTreeClassSuccess() {
- assertThat(StatementSQLVisitorRule.valueOf(SelectContext.class), is(StatementSQLVisitorRule.SELECT));
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void assertValueOfParseTreeClassFailure() {
- StatementSQLVisitorRule.valueOf(ParseTree.class);
- }
+/**
+ * TCL Format SQL visitor for MySQL.
+ */
+public final class MySQLTCLFormatSQLVisitor extends MySQLFormatSQLVisitor implements TCLFormatSQLVisitor {
}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/OracleParserConfiguration.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/OracleParserConfiguration.java
index b28dda3..27d14e7 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/OracleParserConfiguration.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/OracleParserConfiguration.java
@@ -19,10 +19,10 @@ package org.apache.shardingsphere.sql.parser.oracle;
import org.apache.shardingsphere.sql.parser.api.lexer.SQLLexer;
import org.apache.shardingsphere.sql.parser.api.parser.SQLParser;
-import org.apache.shardingsphere.sql.parser.api.visitor.statement.StatementSQLVisitorFacade;
+import org.apache.shardingsphere.sql.parser.api.visitor.SQLVisitorFacade;
import org.apache.shardingsphere.sql.parser.oracle.lexer.OracleLexer;
import org.apache.shardingsphere.sql.parser.oracle.parser.OracleParser;
-import org.apache.shardingsphere.sql.parser.oracle.visitor.OracleStatementSQLVisitorFacade;
+import org.apache.shardingsphere.sql.parser.oracle.visitor.OracleSQLVisitorFacade;
import org.apache.shardingsphere.sql.parser.spi.SQLParserConfiguration;
/**
@@ -46,7 +46,7 @@ public final class OracleParserConfiguration implements SQLParserConfiguration {
}
@Override
- public Class<? extends StatementSQLVisitorFacade> getVisitorFacadeClass() {
- return OracleStatementSQLVisitorFacade.class;
+ public Class<? extends SQLVisitorFacade> getVisitorFacadeClass() {
+ return OracleSQLVisitorFacade.class;
}
}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-spi/src/main/java/org/apache/shardingsphere/sql/parser/spi/SQLParserConfiguration.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/OracleSQLVisitorFacade.java
similarity index 52%
copy from shardingsphere-sql-parser/shardingsphere-sql-parser-spi/src/main/java/org/apache/shardingsphere/sql/parser/spi/SQLParserConfiguration.java
copy to shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/OracleSQLVisitorFacade.java
index 4725562..dbaf22a 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-spi/src/main/java/org/apache/shardingsphere/sql/parser/spi/SQLParserConfiguration.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/OracleSQLVisitorFacade.java
@@ -15,42 +15,26 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sql.parser.spi;
+package org.apache.shardingsphere.sql.parser.oracle.visitor;
-import org.apache.shardingsphere.sql.parser.api.lexer.SQLLexer;
-import org.apache.shardingsphere.sql.parser.api.parser.SQLParser;
+import org.apache.shardingsphere.sql.parser.api.visitor.SQLVisitorFacade;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.FormatSQLVisitorFacade;
import org.apache.shardingsphere.sql.parser.api.visitor.statement.StatementSQLVisitorFacade;
+import org.apache.shardingsphere.sql.parser.oracle.visitor.format.OracleFormatSQLVisitorFacade;
+import org.apache.shardingsphere.sql.parser.oracle.visitor.statement.OracleStatementSQLVisitorFacade;
/**
- * SQL parser configuration.
+ * Oracle SQL visitor facade.
*/
-public interface SQLParserConfiguration {
+public final class OracleSQLVisitorFacade implements SQLVisitorFacade {
- /**
- * Get name of database type.
- *
- * @return name of database type
- */
- String getDatabaseTypeName();
+ @Override
+ public Class<? extends StatementSQLVisitorFacade> getStatementSQLVisitorFacadeClass() {
+ return OracleStatementSQLVisitorFacade.class;
+ }
- /**
- * Get SQL lexer class type.
- *
- * @return SQL lexer class type
- */
- Class<? extends SQLLexer> getLexerClass();
-
- /**
- * Get SQL parser class type.
- *
- * @return SQL parser class type
- */
- Class<? extends SQLParser> getParserClass();
-
- /**
- * Get SQL visitor facade class.
- *
- * @return SQL visitor facade class
- */
- Class<? extends StatementSQLVisitorFacade> getVisitorFacadeClass();
+ @Override
+ public Class<? extends FormatSQLVisitorFacade> getFormatSQLVisitorFacadeClass() {
+ return OracleFormatSQLVisitorFacade.class;
+ }
}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/format/OracleFormatSQLVisitorFacade.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/format/OracleFormatSQLVisitorFacade.java
new file mode 100644
index 0000000..806fddf
--- /dev/null
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/format/OracleFormatSQLVisitorFacade.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.sql.parser.oracle.visitor.format;
+
+import org.apache.shardingsphere.sql.parser.api.visitor.format.FormatSQLVisitorFacade;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.impl.DALFormatSQLVisitor;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.impl.DCLFormatSQLVisitor;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.impl.DDLFormatSQLVisitor;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.impl.DMLFormatSQLVisitor;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.impl.RLFormatSQLVisitor;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.impl.TCLFormatSQLVisitor;
+
+/**
+ * Format SQL Visitor facade for MySQL.
+ */
+public final class OracleFormatSQLVisitorFacade implements FormatSQLVisitorFacade {
+
+ @Override
+ public Class<? extends DMLFormatSQLVisitor> getDMLVisitorClass() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Class<? extends DDLFormatSQLVisitor> getDDLVisitorClass() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Class<? extends TCLFormatSQLVisitor> getTCLVisitorClass() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Class<? extends DCLFormatSQLVisitor> getDCLVisitorClass() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Class<? extends DALFormatSQLVisitor> getDALVisitorClass() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Class<? extends RLFormatSQLVisitor> getRLVisitorClass() {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/OracleStatementSQLVisitorFacade.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/OracleStatementSQLVisitorFacade.java
similarity index 97%
rename from shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/OracleStatementSQLVisitorFacade.java
rename to shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/OracleStatementSQLVisitorFacade.java
index 3a34a1d..98774af 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/OracleStatementSQLVisitorFacade.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/OracleStatementSQLVisitorFacade.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sql.parser.oracle.visitor;
+package org.apache.shardingsphere.sql.parser.oracle.visitor.statement;
import org.apache.shardingsphere.sql.parser.api.visitor.statement.StatementSQLVisitorFacade;
import org.apache.shardingsphere.sql.parser.api.visitor.statement.impl.DALStatementSQLVisitor;
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/PostgreSQLParserConfiguration.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/PostgreSQLParserConfiguration.java
index 4d9aafb..6932311 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/PostgreSQLParserConfiguration.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/PostgreSQLParserConfiguration.java
@@ -19,10 +19,10 @@ package org.apache.shardingsphere.sql.parser.postgresql;
import org.apache.shardingsphere.sql.parser.api.lexer.SQLLexer;
import org.apache.shardingsphere.sql.parser.api.parser.SQLParser;
-import org.apache.shardingsphere.sql.parser.api.visitor.statement.StatementSQLVisitorFacade;
+import org.apache.shardingsphere.sql.parser.api.visitor.SQLVisitorFacade;
import org.apache.shardingsphere.sql.parser.postgresql.lexer.PostgreSQLLexer;
import org.apache.shardingsphere.sql.parser.postgresql.parser.PostgreSQLParser;
-import org.apache.shardingsphere.sql.parser.postgresql.visitor.PostgreSQLStatementSQLVisitorFacade;
+import org.apache.shardingsphere.sql.parser.postgresql.visitor.PostgreSQLSQLVisitorFacade;
import org.apache.shardingsphere.sql.parser.spi.SQLParserConfiguration;
/**
@@ -46,7 +46,7 @@ public final class PostgreSQLParserConfiguration implements SQLParserConfigurati
}
@Override
- public Class<? extends StatementSQLVisitorFacade> getVisitorFacadeClass() {
- return PostgreSQLStatementSQLVisitorFacade.class;
+ public Class<? extends SQLVisitorFacade> getVisitorFacadeClass() {
+ return PostgreSQLSQLVisitorFacade.class;
}
}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-spi/src/main/java/org/apache/shardingsphere/sql/parser/spi/SQLParserConfiguration.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/PostgreSQLSQLVisitorFacade.java
similarity index 51%
copy from shardingsphere-sql-parser/shardingsphere-sql-parser-spi/src/main/java/org/apache/shardingsphere/sql/parser/spi/SQLParserConfiguration.java
copy to shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/PostgreSQLSQLVisitorFacade.java
index 4725562..01cd099 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-spi/src/main/java/org/apache/shardingsphere/sql/parser/spi/SQLParserConfiguration.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/PostgreSQLSQLVisitorFacade.java
@@ -15,42 +15,26 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sql.parser.spi;
+package org.apache.shardingsphere.sql.parser.postgresql.visitor;
-import org.apache.shardingsphere.sql.parser.api.lexer.SQLLexer;
-import org.apache.shardingsphere.sql.parser.api.parser.SQLParser;
+import org.apache.shardingsphere.sql.parser.api.visitor.SQLVisitorFacade;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.FormatSQLVisitorFacade;
import org.apache.shardingsphere.sql.parser.api.visitor.statement.StatementSQLVisitorFacade;
+import org.apache.shardingsphere.sql.parser.postgresql.visitor.format.PostgreSQLFormatSQLVisitorFacade;
+import org.apache.shardingsphere.sql.parser.postgresql.visitor.statement.PostgreSQLStatementSQLVisitorFacade;
/**
- * SQL parser configuration.
+ * PostgreSQL SQL visitor facade.
*/
-public interface SQLParserConfiguration {
+public final class PostgreSQLSQLVisitorFacade implements SQLVisitorFacade {
- /**
- * Get name of database type.
- *
- * @return name of database type
- */
- String getDatabaseTypeName();
+ @Override
+ public Class<? extends StatementSQLVisitorFacade> getStatementSQLVisitorFacadeClass() {
+ return PostgreSQLStatementSQLVisitorFacade.class;
+ }
- /**
- * Get SQL lexer class type.
- *
- * @return SQL lexer class type
- */
- Class<? extends SQLLexer> getLexerClass();
-
- /**
- * Get SQL parser class type.
- *
- * @return SQL parser class type
- */
- Class<? extends SQLParser> getParserClass();
-
- /**
- * Get SQL visitor facade class.
- *
- * @return SQL visitor facade class
- */
- Class<? extends StatementSQLVisitorFacade> getVisitorFacadeClass();
+ @Override
+ public Class<? extends FormatSQLVisitorFacade> getFormatSQLVisitorFacadeClass() {
+ return PostgreSQLFormatSQLVisitorFacade.class;
+ }
}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/format/PostgreSQLFormatSQLVisitorFacade.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/format/PostgreSQLFormatSQLVisitorFacade.java
new file mode 100644
index 0000000..82daf12
--- /dev/null
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/format/PostgreSQLFormatSQLVisitorFacade.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.sql.parser.postgresql.visitor.format;
+
+import org.apache.shardingsphere.sql.parser.api.visitor.format.FormatSQLVisitorFacade;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.impl.DALFormatSQLVisitor;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.impl.DCLFormatSQLVisitor;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.impl.DDLFormatSQLVisitor;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.impl.DMLFormatSQLVisitor;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.impl.RLFormatSQLVisitor;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.impl.TCLFormatSQLVisitor;
+
+/**
+ * Format SQL Visitor facade for MySQL.
+ */
+public final class PostgreSQLFormatSQLVisitorFacade implements FormatSQLVisitorFacade {
+
+ @Override
+ public Class<? extends DMLFormatSQLVisitor> getDMLVisitorClass() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Class<? extends DDLFormatSQLVisitor> getDDLVisitorClass() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Class<? extends TCLFormatSQLVisitor> getTCLVisitorClass() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Class<? extends DCLFormatSQLVisitor> getDCLVisitorClass() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Class<? extends DALFormatSQLVisitor> getDALVisitorClass() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Class<? extends RLFormatSQLVisitor> getRLVisitorClass() {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/PostgreSQLStatementSQLVisitorFacade.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/PostgreSQLStatementSQLVisitorFacade.java
similarity index 97%
rename from shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/PostgreSQLStatementSQLVisitorFacade.java
rename to shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/PostgreSQLStatementSQLVisitorFacade.java
index fec7c1e..4738993 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/PostgreSQLStatementSQLVisitorFacade.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/PostgreSQLStatementSQLVisitorFacade.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sql.parser.postgresql.visitor;
+package org.apache.shardingsphere.sql.parser.postgresql.visitor.statement;
import org.apache.shardingsphere.sql.parser.api.visitor.statement.StatementSQLVisitorFacade;
import org.apache.shardingsphere.sql.parser.api.visitor.statement.impl.DALStatementSQLVisitor;
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sql92/src/main/java/org/apache/shardingsphere/sql/parser/sql92/SQL92ParserConfiguration.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sql92/src/main/java/org/apache/shardingsphere/sql/parser/sql92/SQL92ParserConfiguration.java
index dc64917..066071a 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sql92/src/main/java/org/apache/shardingsphere/sql/parser/sql92/SQL92ParserConfiguration.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sql92/src/main/java/org/apache/shardingsphere/sql/parser/sql92/SQL92ParserConfiguration.java
@@ -19,11 +19,11 @@ package org.apache.shardingsphere.sql.parser.sql92;
import org.apache.shardingsphere.sql.parser.api.lexer.SQLLexer;
import org.apache.shardingsphere.sql.parser.api.parser.SQLParser;
-import org.apache.shardingsphere.sql.parser.api.visitor.statement.StatementSQLVisitorFacade;
+import org.apache.shardingsphere.sql.parser.api.visitor.SQLVisitorFacade;
import org.apache.shardingsphere.sql.parser.spi.SQLParserConfiguration;
import org.apache.shardingsphere.sql.parser.sql92.lexer.SQL92Lexer;
import org.apache.shardingsphere.sql.parser.sql92.parser.SQL92Parser;
-import org.apache.shardingsphere.sql.parser.sql92.visitor.SQL92StatementSQLVisitorFacade;
+import org.apache.shardingsphere.sql.parser.sql92.visitor.SQL92SQLVisitorFacade;
/**
* SQL parser configuration for SQL92.
@@ -46,7 +46,7 @@ public final class SQL92ParserConfiguration implements SQLParserConfiguration {
}
@Override
- public Class<? extends StatementSQLVisitorFacade> getVisitorFacadeClass() {
- return SQL92StatementSQLVisitorFacade.class;
+ public Class<? extends SQLVisitorFacade> getVisitorFacadeClass() {
+ return SQL92SQLVisitorFacade.class;
}
}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-spi/src/main/java/org/apache/shardingsphere/sql/parser/spi/SQLParserConfiguration.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sql92/src/main/java/org/apache/shardingsphere/sql/parser/sql92/visitor/SQL92SQLVisitorFacade.java
similarity index 52%
copy from shardingsphere-sql-parser/shardingsphere-sql-parser-spi/src/main/java/org/apache/shardingsphere/sql/parser/spi/SQLParserConfiguration.java
copy to shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sql92/src/main/java/org/apache/shardingsphere/sql/parser/sql92/visitor/SQL92SQLVisitorFacade.java
index 4725562..0d8b674 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-spi/src/main/java/org/apache/shardingsphere/sql/parser/spi/SQLParserConfiguration.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sql92/src/main/java/org/apache/shardingsphere/sql/parser/sql92/visitor/SQL92SQLVisitorFacade.java
@@ -15,42 +15,26 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sql.parser.spi;
+package org.apache.shardingsphere.sql.parser.sql92.visitor;
-import org.apache.shardingsphere.sql.parser.api.lexer.SQLLexer;
-import org.apache.shardingsphere.sql.parser.api.parser.SQLParser;
+import org.apache.shardingsphere.sql.parser.api.visitor.SQLVisitorFacade;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.FormatSQLVisitorFacade;
import org.apache.shardingsphere.sql.parser.api.visitor.statement.StatementSQLVisitorFacade;
+import org.apache.shardingsphere.sql.parser.sql92.visitor.format.SQL92FormatSQLVisitorFacade;
+import org.apache.shardingsphere.sql.parser.sql92.visitor.statement.SQL92StatementSQLVisitorFacade;
/**
- * SQL parser configuration.
+ * SQL92 SQL visitor facade.
*/
-public interface SQLParserConfiguration {
+public final class SQL92SQLVisitorFacade implements SQLVisitorFacade {
- /**
- * Get name of database type.
- *
- * @return name of database type
- */
- String getDatabaseTypeName();
+ @Override
+ public Class<? extends StatementSQLVisitorFacade> getStatementSQLVisitorFacadeClass() {
+ return SQL92StatementSQLVisitorFacade.class;
+ }
- /**
- * Get SQL lexer class type.
- *
- * @return SQL lexer class type
- */
- Class<? extends SQLLexer> getLexerClass();
-
- /**
- * Get SQL parser class type.
- *
- * @return SQL parser class type
- */
- Class<? extends SQLParser> getParserClass();
-
- /**
- * Get SQL visitor facade class.
- *
- * @return SQL visitor facade class
- */
- Class<? extends StatementSQLVisitorFacade> getVisitorFacadeClass();
+ @Override
+ public Class<? extends FormatSQLVisitorFacade> getFormatSQLVisitorFacadeClass() {
+ return SQL92FormatSQLVisitorFacade.class;
+ }
}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sql92/src/main/java/org/apache/shardingsphere/sql/parser/sql92/visitor/format/SQL92FormatSQLVisitorFacade.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sql92/src/main/java/org/apache/shardingsphere/sql/parser/sql92/visitor/format/SQL92FormatSQLVisitorFacade.java
new file mode 100644
index 0000000..9c51d8a
--- /dev/null
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sql92/src/main/java/org/apache/shardingsphere/sql/parser/sql92/visitor/format/SQL92FormatSQLVisitorFacade.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.sql.parser.sql92.visitor.format;
+
+import org.apache.shardingsphere.sql.parser.api.visitor.format.FormatSQLVisitorFacade;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.impl.DALFormatSQLVisitor;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.impl.DCLFormatSQLVisitor;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.impl.DDLFormatSQLVisitor;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.impl.DMLFormatSQLVisitor;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.impl.RLFormatSQLVisitor;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.impl.TCLFormatSQLVisitor;
+
+/**
+ * Format SQL Visitor facade for MySQL.
+ */
+public final class SQL92FormatSQLVisitorFacade implements FormatSQLVisitorFacade {
+
+ @Override
+ public Class<? extends DMLFormatSQLVisitor> getDMLVisitorClass() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Class<? extends DDLFormatSQLVisitor> getDDLVisitorClass() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Class<? extends TCLFormatSQLVisitor> getTCLVisitorClass() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Class<? extends DCLFormatSQLVisitor> getDCLVisitorClass() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Class<? extends DALFormatSQLVisitor> getDALVisitorClass() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Class<? extends RLFormatSQLVisitor> getRLVisitorClass() {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sql92/src/main/java/org/apache/shardingsphere/sql/parser/sql92/visitor/SQL92StatementSQLVisitorFacade.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sql92/src/main/java/org/apache/shardingsphere/sql/parser/sql92/visitor/statement/SQL92StatementSQLVisitorFacade.java
similarity index 97%
rename from shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sql92/src/main/java/org/apache/shardingsphere/sql/parser/sql92/visitor/SQL92StatementSQLVisitorFacade.java
rename to shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sql92/src/main/java/org/apache/shardingsphere/sql/parser/sql92/visitor/statement/SQL92StatementSQLVisitorFacade.java
index 2b87c99..abb46fd 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sql92/src/main/java/org/apache/shardingsphere/sql/parser/sql92/visitor/SQL92StatementSQLVisitorFacade.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sql92/src/main/java/org/apache/shardingsphere/sql/parser/sql92/visitor/statement/SQL92StatementSQLVisitorFacade.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sql.parser.sql92.visitor;
+package org.apache.shardingsphere.sql.parser.sql92.visitor.statement;
import org.apache.shardingsphere.sql.parser.api.visitor.statement.StatementSQLVisitorFacade;
import org.apache.shardingsphere.sql.parser.api.visitor.statement.impl.DALStatementSQLVisitor;
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/SQLServerParserConfiguration.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/SQLServerParserConfiguration.java
index a4cae75..6e298d9 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/SQLServerParserConfiguration.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/SQLServerParserConfiguration.java
@@ -19,11 +19,11 @@ package org.apache.shardingsphere.sql.parser.sqlserver;
import org.apache.shardingsphere.sql.parser.api.lexer.SQLLexer;
import org.apache.shardingsphere.sql.parser.api.parser.SQLParser;
-import org.apache.shardingsphere.sql.parser.api.visitor.statement.StatementSQLVisitorFacade;
+import org.apache.shardingsphere.sql.parser.api.visitor.SQLVisitorFacade;
import org.apache.shardingsphere.sql.parser.spi.SQLParserConfiguration;
import org.apache.shardingsphere.sql.parser.sqlserver.lexer.SQLServerLexer;
import org.apache.shardingsphere.sql.parser.sqlserver.parser.SQLServerParser;
-import org.apache.shardingsphere.sql.parser.sqlserver.visitor.SQLServerStatementSQLVisitorFacade;
+import org.apache.shardingsphere.sql.parser.sqlserver.visitor.SQLServerSQLVisitorFacade;
/**
* SQL parser configuration for SQLServer.
@@ -46,7 +46,7 @@ public final class SQLServerParserConfiguration implements SQLParserConfiguratio
}
@Override
- public Class<? extends StatementSQLVisitorFacade> getVisitorFacadeClass() {
- return SQLServerStatementSQLVisitorFacade.class;
+ public Class<? extends SQLVisitorFacade> getVisitorFacadeClass() {
+ return SQLServerSQLVisitorFacade.class;
}
}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-spi/src/main/java/org/apache/shardingsphere/sql/parser/spi/SQLParserConfiguration.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/visitor/SQLServerSQLVisitorFacade.java
similarity index 51%
copy from shardingsphere-sql-parser/shardingsphere-sql-parser-spi/src/main/java/org/apache/shardingsphere/sql/parser/spi/SQLParserConfiguration.java
copy to shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/visitor/SQLServerSQLVisitorFacade.java
index 4725562..ab74835 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-spi/src/main/java/org/apache/shardingsphere/sql/parser/spi/SQLParserConfiguration.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/visitor/SQLServerSQLVisitorFacade.java
@@ -15,42 +15,26 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sql.parser.spi;
+package org.apache.shardingsphere.sql.parser.sqlserver.visitor;
-import org.apache.shardingsphere.sql.parser.api.lexer.SQLLexer;
-import org.apache.shardingsphere.sql.parser.api.parser.SQLParser;
+import org.apache.shardingsphere.sql.parser.api.visitor.SQLVisitorFacade;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.FormatSQLVisitorFacade;
import org.apache.shardingsphere.sql.parser.api.visitor.statement.StatementSQLVisitorFacade;
+import org.apache.shardingsphere.sql.parser.sqlserver.visitor.format.SQLServerFormatSQLVisitorFacade;
+import org.apache.shardingsphere.sql.parser.sqlserver.visitor.statement.SQLServerStatementSQLVisitorFacade;
/**
- * SQL parser configuration.
+ * SQLServer SQL visitor facade.
*/
-public interface SQLParserConfiguration {
+public final class SQLServerSQLVisitorFacade implements SQLVisitorFacade {
- /**
- * Get name of database type.
- *
- * @return name of database type
- */
- String getDatabaseTypeName();
+ @Override
+ public Class<? extends StatementSQLVisitorFacade> getStatementSQLVisitorFacadeClass() {
+ return SQLServerStatementSQLVisitorFacade.class;
+ }
- /**
- * Get SQL lexer class type.
- *
- * @return SQL lexer class type
- */
- Class<? extends SQLLexer> getLexerClass();
-
- /**
- * Get SQL parser class type.
- *
- * @return SQL parser class type
- */
- Class<? extends SQLParser> getParserClass();
-
- /**
- * Get SQL visitor facade class.
- *
- * @return SQL visitor facade class
- */
- Class<? extends StatementSQLVisitorFacade> getVisitorFacadeClass();
+ @Override
+ public Class<? extends FormatSQLVisitorFacade> getFormatSQLVisitorFacadeClass() {
+ return SQLServerFormatSQLVisitorFacade.class;
+ }
}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/visitor/format/SQLServerFormatSQLVisitorFacade.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/visitor/format/SQLServerFormatSQLVisitorFacade.java
new file mode 100644
index 0000000..2e4d646
--- /dev/null
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/visitor/format/SQLServerFormatSQLVisitorFacade.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.sql.parser.sqlserver.visitor.format;
+
+import org.apache.shardingsphere.sql.parser.api.visitor.format.FormatSQLVisitorFacade;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.impl.DALFormatSQLVisitor;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.impl.DCLFormatSQLVisitor;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.impl.DDLFormatSQLVisitor;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.impl.DMLFormatSQLVisitor;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.impl.RLFormatSQLVisitor;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.impl.TCLFormatSQLVisitor;
+
+/**
+ * Format SQL Visitor facade for MySQL.
+ */
+public final class SQLServerFormatSQLVisitorFacade implements FormatSQLVisitorFacade {
+
+ @Override
+ public Class<? extends DMLFormatSQLVisitor> getDMLVisitorClass() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Class<? extends DDLFormatSQLVisitor> getDDLVisitorClass() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Class<? extends TCLFormatSQLVisitor> getTCLVisitorClass() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Class<? extends DCLFormatSQLVisitor> getDCLVisitorClass() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Class<? extends DALFormatSQLVisitor> getDALVisitorClass() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Class<? extends RLFormatSQLVisitor> getRLVisitorClass() {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/visitor/SQLServerStatementSQLVisitorFacade.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/visitor/statement/SQLServerStatementSQLVisitorFacade.java
similarity index 97%
rename from shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/visitor/SQLServerStatementSQLVisitorFacade.java
rename to shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/visitor/statement/SQLServerStatementSQLVisitorFacade.java
index b455fe2..5b31fc0 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/visitor/SQLServerStatementSQLVisitorFacade.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/visitor/statement/SQLServerStatementSQLVisitorFacade.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sql.parser.sqlserver.visitor;
+package org.apache.shardingsphere.sql.parser.sqlserver.visitor.statement;
import org.apache.shardingsphere.sql.parser.api.visitor.statement.StatementSQLVisitorFacade;
import org.apache.shardingsphere.sql.parser.api.visitor.statement.impl.DALStatementSQLVisitor;
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/visitor/statement/StatementSQLVisitorRule.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/visitor/SQLVisitorRule.java
similarity index 95%
rename from shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/visitor/statement/StatementSQLVisitorRule.java
rename to shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/visitor/SQLVisitorRule.java
index 6f7c24d..1ade093 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/visitor/statement/StatementSQLVisitorRule.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/visitor/SQLVisitorRule.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sql.parser.core.visitor.statement;
+package org.apache.shardingsphere.sql.parser.core.visitor;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
@@ -26,7 +26,7 @@ import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatementTyp
* Statement SQL Visitor rule.
*/
@RequiredArgsConstructor
-public enum StatementSQLVisitorRule {
+public enum SQLVisitorRule {
SELECT("Select", SQLStatementType.DML),
@@ -201,9 +201,9 @@ public enum StatementSQLVisitorRule {
* @param parseTreeClass parse tree class
* @return visitor rule
*/
- public static StatementSQLVisitorRule valueOf(final Class<? extends ParseTree> parseTreeClass) {
+ public static SQLVisitorRule valueOf(final Class<? extends ParseTree> parseTreeClass) {
String parseTreeClassName = parseTreeClass.getSimpleName();
- for (StatementSQLVisitorRule each : values()) {
+ for (SQLVisitorRule each : values()) {
if (each.getContextName().equals(parseTreeClassName)) {
return each;
}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/visitor/statement/StatementSQLVisitorFactory.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/visitor/format/FormatSQLVisitorFactory.java
similarity index 82%
copy from shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/visitor/statement/StatementSQLVisitorFactory.java
copy to shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/visitor/format/FormatSQLVisitorFactory.java
index 4b36de7..5df65db 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/visitor/statement/StatementSQLVisitorFactory.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/visitor/format/FormatSQLVisitorFactory.java
@@ -15,38 +15,40 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sql.parser.core.visitor.statement;
+package org.apache.shardingsphere.sql.parser.core.visitor.format;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import lombok.SneakyThrows;
import org.antlr.v4.runtime.tree.ParseTreeVisitor;
-import org.apache.shardingsphere.sql.parser.api.visitor.statement.StatementSQLVisitorFacade;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.FormatSQLVisitorFacade;
import org.apache.shardingsphere.sql.parser.core.SQLParserConfigurationRegistry;
+import org.apache.shardingsphere.sql.parser.core.visitor.SQLVisitorRule;
import org.apache.shardingsphere.sql.parser.exception.SQLParsingException;
import org.apache.shardingsphere.sql.parser.spi.SQLParserConfiguration;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatementType;
/**
- * Statement SQL visitor factory.
+ * Format SQL visitor factory.
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class StatementSQLVisitorFactory {
+public final class FormatSQLVisitorFactory {
/**
* New instance of statement SQL visitor.
*
* @param databaseTypeName name of database type
- * @param statementSQLVisitorRule visitor rule
+ * @param SQLVisitorRule visitor rule
* @return parse tree visitor
*/
- public static ParseTreeVisitor newInstance(final String databaseTypeName, final StatementSQLVisitorRule statementSQLVisitorRule) {
- return createParseTreeVisitor(SQLParserConfigurationRegistry.getInstance().getSQLParserConfiguration(databaseTypeName), statementSQLVisitorRule.getType());
+ public static ParseTreeVisitor newInstance(final String databaseTypeName, final SQLVisitorRule SQLVisitorRule) {
+ return createParseTreeVisitor(SQLParserConfigurationRegistry.getInstance().getSQLParserConfiguration(databaseTypeName), SQLVisitorRule.getType());
}
@SneakyThrows(ReflectiveOperationException.class)
private static ParseTreeVisitor createParseTreeVisitor(final SQLParserConfiguration config, final SQLStatementType type) {
- StatementSQLVisitorFacade visitorFacade = config.getVisitorFacadeClass().getConstructor().newInstance();
+ FormatSQLVisitorFacade visitorFacade =
+ config.getVisitorFacadeClass().getConstructor().newInstance().getFormatSQLVisitorFacadeClass().getConstructor().newInstance();
switch (type) {
case DML:
return (ParseTreeVisitor) visitorFacade.getDMLVisitorClass().getConstructor().newInstance();
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/visitor/statement/StatementSQLVisitorFactory.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/visitor/statement/StatementSQLVisitorFactory.java
index 4b36de7..db8aa04 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/visitor/statement/StatementSQLVisitorFactory.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/visitor/statement/StatementSQLVisitorFactory.java
@@ -23,6 +23,7 @@ import lombok.SneakyThrows;
import org.antlr.v4.runtime.tree.ParseTreeVisitor;
import org.apache.shardingsphere.sql.parser.api.visitor.statement.StatementSQLVisitorFacade;
import org.apache.shardingsphere.sql.parser.core.SQLParserConfigurationRegistry;
+import org.apache.shardingsphere.sql.parser.core.visitor.SQLVisitorRule;
import org.apache.shardingsphere.sql.parser.exception.SQLParsingException;
import org.apache.shardingsphere.sql.parser.spi.SQLParserConfiguration;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatementType;
@@ -37,16 +38,17 @@ public final class StatementSQLVisitorFactory {
* New instance of statement SQL visitor.
*
* @param databaseTypeName name of database type
- * @param statementSQLVisitorRule visitor rule
+ * @param SQLVisitorRule visitor rule
* @return parse tree visitor
*/
- public static ParseTreeVisitor newInstance(final String databaseTypeName, final StatementSQLVisitorRule statementSQLVisitorRule) {
- return createParseTreeVisitor(SQLParserConfigurationRegistry.getInstance().getSQLParserConfiguration(databaseTypeName), statementSQLVisitorRule.getType());
+ public static ParseTreeVisitor newInstance(final String databaseTypeName, final SQLVisitorRule SQLVisitorRule) {
+ return createParseTreeVisitor(SQLParserConfigurationRegistry.getInstance().getSQLParserConfiguration(databaseTypeName), SQLVisitorRule.getType());
}
@SneakyThrows(ReflectiveOperationException.class)
private static ParseTreeVisitor createParseTreeVisitor(final SQLParserConfiguration config, final SQLStatementType type) {
- StatementSQLVisitorFacade visitorFacade = config.getVisitorFacadeClass().getConstructor().newInstance();
+ StatementSQLVisitorFacade visitorFacade =
+ config.getVisitorFacadeClass().getConstructor().newInstance().getStatementSQLVisitorFacadeClass().getConstructor().newInstance();
switch (type) {
case DML:
return (ParseTreeVisitor) visitorFacade.getDMLVisitorClass().getConstructor().newInstance();
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/engine/statement/standard/StandardSQLParserEngine.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/engine/statement/standard/StandardSQLParserEngine.java
index ca6f0dc..6a87497 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/engine/statement/standard/StandardSQLParserEngine.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/engine/statement/standard/StandardSQLParserEngine.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.sql.parser.engine.statement.standard;
import lombok.RequiredArgsConstructor;
import org.antlr.v4.runtime.tree.ParseTree;
import org.apache.shardingsphere.sql.parser.core.visitor.statement.StatementSQLVisitorFactory;
-import org.apache.shardingsphere.sql.parser.core.visitor.statement.StatementSQLVisitorRule;
+import org.apache.shardingsphere.sql.parser.core.visitor.SQLVisitorRule;
import org.apache.shardingsphere.sql.parser.engine.statement.StatementSQLParserEngine;
import org.apache.shardingsphere.sql.parser.core.parser.SQLParserExecutor;
import org.apache.shardingsphere.sql.parser.hook.ParsingHookRegistry;
@@ -70,7 +70,7 @@ public final class StandardSQLParserEngine implements StatementSQLParserEngine {
}
}
ParseTree parseTree = new SQLParserExecutor(databaseTypeName, sql).execute().getRootNode();
- SQLStatement result = (SQLStatement) StatementSQLVisitorFactory.newInstance(databaseTypeName, StatementSQLVisitorRule.valueOf(parseTree.getClass())).visit(parseTree);
+ SQLStatement result = (SQLStatement) StatementSQLVisitorFactory.newInstance(databaseTypeName, SQLVisitorRule.valueOf(parseTree.getClass())).visit(parseTree);
if (useCache) {
cache.put(sql, result);
}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/StatementSQLVisitorRuleTest.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/SQLVisitorRuleTest.java
similarity index 79%
copy from shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/StatementSQLVisitorRuleTest.java
copy to shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/SQLVisitorRuleTest.java
index 6263b3a..24e454a 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/StatementSQLVisitorRuleTest.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/SQLVisitorRuleTest.java
@@ -18,21 +18,20 @@
package org.apache.shardingsphere.sql.parser.core.visitor;
import org.antlr.v4.runtime.tree.ParseTree;
-import org.apache.shardingsphere.sql.parser.core.visitor.statement.StatementSQLVisitorRule;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
-public final class StatementSQLVisitorRuleTest {
+public final class SQLVisitorRuleTest {
@Test
public void assertValueOfParseTreeClassSuccess() {
- assertThat(StatementSQLVisitorRule.valueOf(SelectContext.class), is(StatementSQLVisitorRule.SELECT));
+ assertThat(SQLVisitorRule.valueOf(SelectContext.class), is(SQLVisitorRule.SELECT));
}
@Test(expected = IllegalArgumentException.class)
public void assertValueOfParseTreeClassFailure() {
- StatementSQLVisitorRule.valueOf(ParseTree.class);
+ SQLVisitorRule.valueOf(ParseTree.class);
}
}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-spi/src/main/java/org/apache/shardingsphere/sql/parser/spi/SQLParserConfiguration.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-spi/src/main/java/org/apache/shardingsphere/sql/parser/api/visitor/SQLVisitorFacade.java
similarity index 54%
copy from shardingsphere-sql-parser/shardingsphere-sql-parser-spi/src/main/java/org/apache/shardingsphere/sql/parser/spi/SQLParserConfiguration.java
copy to shardingsphere-sql-parser/shardingsphere-sql-parser-spi/src/main/java/org/apache/shardingsphere/sql/parser/api/visitor/SQLVisitorFacade.java
index 4725562..4122dcf 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-spi/src/main/java/org/apache/shardingsphere/sql/parser/spi/SQLParserConfiguration.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-spi/src/main/java/org/apache/shardingsphere/sql/parser/api/visitor/SQLVisitorFacade.java
@@ -15,42 +15,27 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sql.parser.spi;
+package org.apache.shardingsphere.sql.parser.api.visitor;
-import org.apache.shardingsphere.sql.parser.api.lexer.SQLLexer;
-import org.apache.shardingsphere.sql.parser.api.parser.SQLParser;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.FormatSQLVisitorFacade;
import org.apache.shardingsphere.sql.parser.api.visitor.statement.StatementSQLVisitorFacade;
/**
- * SQL parser configuration.
+ * SQL visitor facade.
*/
-public interface SQLParserConfiguration {
+public interface SQLVisitorFacade {
/**
- * Get name of database type.
+ * Get Statement visitor facade class.
*
- * @return name of database type
+ * @return DML visitor class
*/
- String getDatabaseTypeName();
+ Class<? extends StatementSQLVisitorFacade> getStatementSQLVisitorFacadeClass();
/**
- * Get SQL lexer class type.
+ * Get Format visitor facade class.
*
- * @return SQL lexer class type
+ * @return DDL visitor class
*/
- Class<? extends SQLLexer> getLexerClass();
-
- /**
- * Get SQL parser class type.
- *
- * @return SQL parser class type
- */
- Class<? extends SQLParser> getParserClass();
-
- /**
- * Get SQL visitor facade class.
- *
- * @return SQL visitor facade class
- */
- Class<? extends StatementSQLVisitorFacade> getVisitorFacadeClass();
+ Class<? extends FormatSQLVisitorFacade> getFormatSQLVisitorFacadeClass();
}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/StatementSQLVisitorRuleTest.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-spi/src/main/java/org/apache/shardingsphere/sql/parser/api/visitor/SQLVisitorType.java
similarity index 53%
copy from shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/StatementSQLVisitorRuleTest.java
copy to shardingsphere-sql-parser/shardingsphere-sql-parser-spi/src/main/java/org/apache/shardingsphere/sql/parser/api/visitor/SQLVisitorType.java
index 6263b3a..5cc459d 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/StatementSQLVisitorRuleTest.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-spi/src/main/java/org/apache/shardingsphere/sql/parser/api/visitor/SQLVisitorType.java
@@ -15,24 +15,12 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sql.parser.core.visitor;
+package org.apache.shardingsphere.sql.parser.api.visitor;
-import org.antlr.v4.runtime.tree.ParseTree;
-import org.apache.shardingsphere.sql.parser.core.visitor.statement.StatementSQLVisitorRule;
-import org.junit.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-public final class StatementSQLVisitorRuleTest {
-
- @Test
- public void assertValueOfParseTreeClassSuccess() {
- assertThat(StatementSQLVisitorRule.valueOf(SelectContext.class), is(StatementSQLVisitorRule.SELECT));
- }
+/**
+ * SQL visitor type.
+ */
+public enum SQLVisitorType {
- @Test(expected = IllegalArgumentException.class)
- public void assertValueOfParseTreeClassFailure() {
- StatementSQLVisitorRule.valueOf(ParseTree.class);
- }
+ STATEMENT, FORMAT
}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-spi/src/main/java/org/apache/shardingsphere/sql/parser/api/visitor/format/FormatSQLVisitorFacade.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-spi/src/main/java/org/apache/shardingsphere/sql/parser/api/visitor/format/FormatSQLVisitorFacade.java
new file mode 100644
index 0000000..0b5ba33
--- /dev/null
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-spi/src/main/java/org/apache/shardingsphere/sql/parser/api/visitor/format/FormatSQLVisitorFacade.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.sql.parser.api.visitor.format;
+
+import org.apache.shardingsphere.sql.parser.api.visitor.format.impl.DALFormatSQLVisitor;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.impl.DCLFormatSQLVisitor;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.impl.DDLFormatSQLVisitor;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.impl.DMLFormatSQLVisitor;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.impl.RLFormatSQLVisitor;
+import org.apache.shardingsphere.sql.parser.api.visitor.format.impl.TCLFormatSQLVisitor;
+
+/**
+ * Format SQL visitor facade.
+ */
+public interface FormatSQLVisitorFacade {
+
+ /**
+ * Get DML visitor class.
+ *
+ * @return DML visitor class
+ */
+ Class<? extends DMLFormatSQLVisitor> getDMLVisitorClass();
+
+ /**
+ * Get DDL visitor class.
+ *
+ * @return DDL visitor class
+ */
+ Class<? extends DDLFormatSQLVisitor> getDDLVisitorClass();
+
+ /**
+ * Get TCL visitor class.
+ *
+ * @return TCL visitor class
+ */
+ Class<? extends TCLFormatSQLVisitor> getTCLVisitorClass();
+
+ /**
+ * Get DCL visitor class.
+ *
+ * @return DCL visitor class
+ */
+ Class<? extends DCLFormatSQLVisitor> getDCLVisitorClass();
+
+ /**
+ * Get DAL visitor class.
+ *
+ * @return DAL visitor class
+ */
+ Class<? extends DALFormatSQLVisitor> getDALVisitorClass();
+
+ /**
+ * Get RL visitor class.
+ *
+ * @return RL visitor class
+ */
+ Class<? extends RLFormatSQLVisitor> getRLVisitorClass();
+}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/StatementSQLVisitorRuleTest.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-spi/src/main/java/org/apache/shardingsphere/sql/parser/api/visitor/format/impl/DALFormatSQLVisitor.java
similarity index 52%
copy from shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/StatementSQLVisitorRuleTest.java
copy to shardingsphere-sql-parser/shardingsphere-sql-parser-spi/src/main/java/org/apache/shardingsphere/sql/parser/api/visitor/format/impl/DALFormatSQLVisitor.java
index 6263b3a..b773787 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/StatementSQLVisitorRuleTest.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-spi/src/main/java/org/apache/shardingsphere/sql/parser/api/visitor/format/impl/DALFormatSQLVisitor.java
@@ -15,24 +15,10 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sql.parser.core.visitor;
+package org.apache.shardingsphere.sql.parser.api.visitor.format.impl;
-import org.antlr.v4.runtime.tree.ParseTree;
-import org.apache.shardingsphere.sql.parser.core.visitor.statement.StatementSQLVisitorRule;
-import org.junit.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-public final class StatementSQLVisitorRuleTest {
-
- @Test
- public void assertValueOfParseTreeClassSuccess() {
- assertThat(StatementSQLVisitorRule.valueOf(SelectContext.class), is(StatementSQLVisitorRule.SELECT));
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void assertValueOfParseTreeClassFailure() {
- StatementSQLVisitorRule.valueOf(ParseTree.class);
- }
+/**
+ * DAL format SQL visitor.
+ */
+public interface DALFormatSQLVisitor {
}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/StatementSQLVisitorRuleTest.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-spi/src/main/java/org/apache/shardingsphere/sql/parser/api/visitor/format/impl/DCLFormatSQLVisitor.java
similarity index 52%
copy from shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/StatementSQLVisitorRuleTest.java
copy to shardingsphere-sql-parser/shardingsphere-sql-parser-spi/src/main/java/org/apache/shardingsphere/sql/parser/api/visitor/format/impl/DCLFormatSQLVisitor.java
index 6263b3a..9ebcba4 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/StatementSQLVisitorRuleTest.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-spi/src/main/java/org/apache/shardingsphere/sql/parser/api/visitor/format/impl/DCLFormatSQLVisitor.java
@@ -15,24 +15,10 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sql.parser.core.visitor;
+package org.apache.shardingsphere.sql.parser.api.visitor.format.impl;
-import org.antlr.v4.runtime.tree.ParseTree;
-import org.apache.shardingsphere.sql.parser.core.visitor.statement.StatementSQLVisitorRule;
-import org.junit.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-public final class StatementSQLVisitorRuleTest {
-
- @Test
- public void assertValueOfParseTreeClassSuccess() {
- assertThat(StatementSQLVisitorRule.valueOf(SelectContext.class), is(StatementSQLVisitorRule.SELECT));
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void assertValueOfParseTreeClassFailure() {
- StatementSQLVisitorRule.valueOf(ParseTree.class);
- }
+/**
+ * DCL format SQL visitor.
+ */
+public interface DCLFormatSQLVisitor {
}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/StatementSQLVisitorRuleTest.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-spi/src/main/java/org/apache/shardingsphere/sql/parser/api/visitor/format/impl/DDLFormatSQLVisitor.java
similarity index 52%
copy from shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/StatementSQLVisitorRuleTest.java
copy to shardingsphere-sql-parser/shardingsphere-sql-parser-spi/src/main/java/org/apache/shardingsphere/sql/parser/api/visitor/format/impl/DDLFormatSQLVisitor.java
index 6263b3a..adcd0c6 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/StatementSQLVisitorRuleTest.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-spi/src/main/java/org/apache/shardingsphere/sql/parser/api/visitor/format/impl/DDLFormatSQLVisitor.java
@@ -15,24 +15,10 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sql.parser.core.visitor;
+package org.apache.shardingsphere.sql.parser.api.visitor.format.impl;
-import org.antlr.v4.runtime.tree.ParseTree;
-import org.apache.shardingsphere.sql.parser.core.visitor.statement.StatementSQLVisitorRule;
-import org.junit.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-public final class StatementSQLVisitorRuleTest {
-
- @Test
- public void assertValueOfParseTreeClassSuccess() {
- assertThat(StatementSQLVisitorRule.valueOf(SelectContext.class), is(StatementSQLVisitorRule.SELECT));
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void assertValueOfParseTreeClassFailure() {
- StatementSQLVisitorRule.valueOf(ParseTree.class);
- }
+/**
+ * DDL format SQL visitor.
+ */
+public interface DDLFormatSQLVisitor {
}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/StatementSQLVisitorRuleTest.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-spi/src/main/java/org/apache/shardingsphere/sql/parser/api/visitor/format/impl/DMLFormatSQLVisitor.java
similarity index 52%
copy from shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/StatementSQLVisitorRuleTest.java
copy to shardingsphere-sql-parser/shardingsphere-sql-parser-spi/src/main/java/org/apache/shardingsphere/sql/parser/api/visitor/format/impl/DMLFormatSQLVisitor.java
index 6263b3a..ab207a0 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/StatementSQLVisitorRuleTest.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-spi/src/main/java/org/apache/shardingsphere/sql/parser/api/visitor/format/impl/DMLFormatSQLVisitor.java
@@ -15,24 +15,10 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sql.parser.core.visitor;
+package org.apache.shardingsphere.sql.parser.api.visitor.format.impl;
-import org.antlr.v4.runtime.tree.ParseTree;
-import org.apache.shardingsphere.sql.parser.core.visitor.statement.StatementSQLVisitorRule;
-import org.junit.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-public final class StatementSQLVisitorRuleTest {
-
- @Test
- public void assertValueOfParseTreeClassSuccess() {
- assertThat(StatementSQLVisitorRule.valueOf(SelectContext.class), is(StatementSQLVisitorRule.SELECT));
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void assertValueOfParseTreeClassFailure() {
- StatementSQLVisitorRule.valueOf(ParseTree.class);
- }
+/**
+ * DML format SQL visitor.
+ */
+public interface DMLFormatSQLVisitor {
}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/StatementSQLVisitorRuleTest.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-spi/src/main/java/org/apache/shardingsphere/sql/parser/api/visitor/format/impl/RLFormatSQLVisitor.java
similarity index 52%
copy from shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/StatementSQLVisitorRuleTest.java
copy to shardingsphere-sql-parser/shardingsphere-sql-parser-spi/src/main/java/org/apache/shardingsphere/sql/parser/api/visitor/format/impl/RLFormatSQLVisitor.java
index 6263b3a..398da19 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/StatementSQLVisitorRuleTest.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-spi/src/main/java/org/apache/shardingsphere/sql/parser/api/visitor/format/impl/RLFormatSQLVisitor.java
@@ -15,24 +15,10 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sql.parser.core.visitor;
+package org.apache.shardingsphere.sql.parser.api.visitor.format.impl;
-import org.antlr.v4.runtime.tree.ParseTree;
-import org.apache.shardingsphere.sql.parser.core.visitor.statement.StatementSQLVisitorRule;
-import org.junit.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-public final class StatementSQLVisitorRuleTest {
-
- @Test
- public void assertValueOfParseTreeClassSuccess() {
- assertThat(StatementSQLVisitorRule.valueOf(SelectContext.class), is(StatementSQLVisitorRule.SELECT));
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void assertValueOfParseTreeClassFailure() {
- StatementSQLVisitorRule.valueOf(ParseTree.class);
- }
+/**
+ * RL format SQL visitor.
+ */
+public interface RLFormatSQLVisitor {
}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/StatementSQLVisitorRuleTest.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-spi/src/main/java/org/apache/shardingsphere/sql/parser/api/visitor/format/impl/TCLFormatSQLVisitor.java
similarity index 52%
rename from shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/StatementSQLVisitorRuleTest.java
rename to shardingsphere-sql-parser/shardingsphere-sql-parser-spi/src/main/java/org/apache/shardingsphere/sql/parser/api/visitor/format/impl/TCLFormatSQLVisitor.java
index 6263b3a..ffe8f5d 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/test/java/org/apache/shardingsphere/sql/parser/core/visitor/StatementSQLVisitorRuleTest.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-spi/src/main/java/org/apache/shardingsphere/sql/parser/api/visitor/format/impl/TCLFormatSQLVisitor.java
@@ -15,24 +15,10 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sql.parser.core.visitor;
+package org.apache.shardingsphere.sql.parser.api.visitor.format.impl;
-import org.antlr.v4.runtime.tree.ParseTree;
-import org.apache.shardingsphere.sql.parser.core.visitor.statement.StatementSQLVisitorRule;
-import org.junit.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-public final class StatementSQLVisitorRuleTest {
-
- @Test
- public void assertValueOfParseTreeClassSuccess() {
- assertThat(StatementSQLVisitorRule.valueOf(SelectContext.class), is(StatementSQLVisitorRule.SELECT));
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void assertValueOfParseTreeClassFailure() {
- StatementSQLVisitorRule.valueOf(ParseTree.class);
- }
+/**
+ * TCL format SQL visitor.
+ */
+public interface TCLFormatSQLVisitor {
}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-spi/src/main/java/org/apache/shardingsphere/sql/parser/spi/SQLParserConfiguration.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-spi/src/main/java/org/apache/shardingsphere/sql/parser/spi/SQLParserConfiguration.java
index 4725562..a5e8b04 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-spi/src/main/java/org/apache/shardingsphere/sql/parser/spi/SQLParserConfiguration.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-spi/src/main/java/org/apache/shardingsphere/sql/parser/spi/SQLParserConfiguration.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.sql.parser.spi;
import org.apache.shardingsphere.sql.parser.api.lexer.SQLLexer;
import org.apache.shardingsphere.sql.parser.api.parser.SQLParser;
-import org.apache.shardingsphere.sql.parser.api.visitor.statement.StatementSQLVisitorFacade;
+import org.apache.shardingsphere.sql.parser.api.visitor.SQLVisitorFacade;
/**
* SQL parser configuration.
@@ -52,5 +52,5 @@ public interface SQLParserConfiguration {
*
* @return SQL visitor facade class
*/
- Class<? extends StatementSQLVisitorFacade> getVisitorFacadeClass();
+ Class<? extends SQLVisitorFacade> getVisitorFacadeClass();
}