From 83052948719b4513a28fb8862a882a62c0a00cbd Mon Sep 17 00:00:00 2001 From: terrymanu Date: Tue, 16 Jan 2018 14:49:42 +0800 Subject: [PATCH] for #540 --- .../parser/clause/GroupByClauseParser.java | 8 +-- .../clause/InsertValuesClauseParser.java | 8 +-- .../parser/clause/OrderByClauseParser.java | 8 +-- .../parser/clause/SelectListClauseParser.java | 13 ++--- .../clause/TableReferencesClauseParser.java | 18 ++++--- .../clause/UpdateSetItemsClauseParser.java | 8 +-- .../parser/clause/WhereClauseParser.java | 30 ++++++----- .../AliasExpressionParser.java} | 10 ++-- .../BasicExpressionParser.java} | 10 ++-- .../dialect/AliasClauseParserFactory.java | 40 --------------- .../dialect/ExpressionParserFactory.java | 51 +++++++++++++++++++ .../MySQLAliasExpressionParser.java} | 8 +-- .../oracle/clause/OracleForClauseParser.java | 9 ++-- .../OracleAliasExpressionParser.java} | 8 +-- .../PostgreSQLAliasExpressionParser.java} | 8 +-- .../SQLServerSelectListClauseParser.java | 2 +- .../clause/SQLServerTopClauseParser.java | 9 ++-- .../SQLServerAliasExpressionParser.java} | 8 +-- .../shardingjdbc/core/util/AllUtilTests.java | 2 +- ...a => InlineBasicExpressionParserTest.java} | 4 +- 20 files changed, 144 insertions(+), 118 deletions(-) rename sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/clause/{AliasClauseParser.java => expression/AliasExpressionParser.java} (94%) rename sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/clause/{ExpressionClauseParser.java => expression/BasicExpressionParser.java} (96%) delete mode 100644 sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/AliasClauseParserFactory.java create mode 100644 sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/ExpressionParserFactory.java rename sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/mysql/clause/{MySQLAliasClauseParser.java => expression/MySQLAliasExpressionParser.java} (62%) rename sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/oracle/clause/{OracleAliasClauseParser.java => expression/OracleAliasExpressionParser.java} (62%) rename sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/postgresql/clause/{PostgreSQLAliasClauseParser.java => expression/PostgreSQLAliasExpressionParser.java} (61%) rename sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/sqlserver/clause/{SQLServerAliasClauseParser.java => expression/SQLServerAliasExpressionParser.java} (61%) rename sharding-jdbc-core/src/test/java/io/shardingjdbc/core/util/{InlineExpressionParserTest.java => InlineBasicExpressionParserTest.java} (96%) diff --git a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/clause/GroupByClauseParser.java b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/clause/GroupByClauseParser.java index fbb40bb6d0143..da05abbd76cd7 100644 --- a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/clause/GroupByClauseParser.java +++ b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/clause/GroupByClauseParser.java @@ -5,7 +5,9 @@ import io.shardingjdbc.core.parsing.lexer.token.DefaultKeyword; import io.shardingjdbc.core.parsing.lexer.token.Keyword; import io.shardingjdbc.core.parsing.lexer.token.Symbol; +import io.shardingjdbc.core.parsing.parser.clause.expression.BasicExpressionParser; import io.shardingjdbc.core.parsing.parser.context.OrderItem; +import io.shardingjdbc.core.parsing.parser.dialect.ExpressionParserFactory; import io.shardingjdbc.core.parsing.parser.expression.SQLExpression; import io.shardingjdbc.core.parsing.parser.expression.SQLIdentifierExpression; import io.shardingjdbc.core.parsing.parser.expression.SQLIgnoreExpression; @@ -22,11 +24,11 @@ public class GroupByClauseParser implements SQLClauseParser { private final LexerEngine lexerEngine; - private final ExpressionClauseParser expressionClauseParser; + private final BasicExpressionParser basicExpressionParser; public GroupByClauseParser(final LexerEngine lexerEngine) { this.lexerEngine = lexerEngine; - expressionClauseParser = new ExpressionClauseParser(lexerEngine); + basicExpressionParser = ExpressionParserFactory.createBasicExpressionParser(lexerEngine); } /** @@ -40,7 +42,7 @@ public final void parse(final SelectStatement selectStatement) { } lexerEngine.accept(DefaultKeyword.BY); while (true) { - addGroupByItem(expressionClauseParser.parse(selectStatement), selectStatement); + addGroupByItem(basicExpressionParser.parse(selectStatement), selectStatement); if (!lexerEngine.equalAny(Symbol.COMMA)) { break; } diff --git a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/clause/InsertValuesClauseParser.java b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/clause/InsertValuesClauseParser.java index c0668e0a7a867..990169470730e 100644 --- a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/clause/InsertValuesClauseParser.java +++ b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/clause/InsertValuesClauseParser.java @@ -1,5 +1,7 @@ package io.shardingjdbc.core.parsing.parser.clause; +import io.shardingjdbc.core.parsing.parser.clause.expression.BasicExpressionParser; +import io.shardingjdbc.core.parsing.parser.dialect.ExpressionParserFactory; import io.shardingjdbc.core.rule.ShardingRule; import io.shardingjdbc.core.exception.ShardingJdbcException; import io.shardingjdbc.core.parsing.lexer.LexerEngine; @@ -32,12 +34,12 @@ public class InsertValuesClauseParser implements SQLClauseParser { private final LexerEngine lexerEngine; - private final ExpressionClauseParser expressionClauseParser; + private final BasicExpressionParser basicExpressionParser; public InsertValuesClauseParser(final ShardingRule shardingRule, final LexerEngine lexerEngine) { this.shardingRule = shardingRule; this.lexerEngine = lexerEngine; - expressionClauseParser = new ExpressionClauseParser(lexerEngine); + basicExpressionParser = ExpressionParserFactory.createBasicExpressionParser(lexerEngine); } /** @@ -66,7 +68,7 @@ private void parseValues(final InsertStatement insertStatement) { lexerEngine.accept(Symbol.LEFT_PAREN); List sqlExpressions = new LinkedList<>(); do { - sqlExpressions.add(expressionClauseParser.parse(insertStatement)); + sqlExpressions.add(basicExpressionParser.parse(insertStatement)); } while (lexerEngine.skipIfEqual(Symbol.COMMA)); insertStatement.setValuesListLastPosition(lexerEngine.getCurrentToken().getEndPosition() - lexerEngine.getCurrentToken().getLiterals().length()); int count = 0; diff --git a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/clause/OrderByClauseParser.java b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/clause/OrderByClauseParser.java index babbef0ae3c43..7de5c8ce36b22 100644 --- a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/clause/OrderByClauseParser.java +++ b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/clause/OrderByClauseParser.java @@ -4,7 +4,9 @@ import io.shardingjdbc.core.parsing.lexer.LexerEngine; import io.shardingjdbc.core.parsing.lexer.token.DefaultKeyword; import io.shardingjdbc.core.parsing.lexer.token.Symbol; +import io.shardingjdbc.core.parsing.parser.clause.expression.BasicExpressionParser; import io.shardingjdbc.core.parsing.parser.context.OrderItem; +import io.shardingjdbc.core.parsing.parser.dialect.ExpressionParserFactory; import io.shardingjdbc.core.parsing.parser.exception.SQLParsingException; import io.shardingjdbc.core.parsing.parser.expression.SQLExpression; import io.shardingjdbc.core.parsing.parser.expression.SQLIdentifierExpression; @@ -28,11 +30,11 @@ public class OrderByClauseParser implements SQLClauseParser { @Getter private final LexerEngine lexerEngine; - private final ExpressionClauseParser expressionClauseParser; + private final BasicExpressionParser basicExpressionParser; public OrderByClauseParser(final LexerEngine lexerEngine) { this.lexerEngine = lexerEngine; - expressionClauseParser = new ExpressionClauseParser(lexerEngine); + basicExpressionParser = ExpressionParserFactory.createBasicExpressionParser(lexerEngine); } /** @@ -55,7 +57,7 @@ public final void parse(final SelectStatement selectStatement) { } private OrderItem parseSelectOrderByItem(final SelectStatement selectStatement) { - SQLExpression sqlExpression = expressionClauseParser.parse(selectStatement); + SQLExpression sqlExpression = basicExpressionParser.parse(selectStatement); OrderType orderByType = OrderType.ASC; if (lexerEngine.skipIfEqual(DefaultKeyword.ASC)) { orderByType = OrderType.ASC; diff --git a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/clause/SelectListClauseParser.java b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/clause/SelectListClauseParser.java index 846da1e27ca5b..c45eee5f4cd67 100644 --- a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/clause/SelectListClauseParser.java +++ b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/clause/SelectListClauseParser.java @@ -1,6 +1,7 @@ package io.shardingjdbc.core.parsing.parser.clause; -import io.shardingjdbc.core.parsing.parser.dialect.AliasClauseParserFactory; +import io.shardingjdbc.core.parsing.parser.clause.expression.AliasExpressionParser; +import io.shardingjdbc.core.parsing.parser.dialect.ExpressionParserFactory; import io.shardingjdbc.core.rule.ShardingRule; import io.shardingjdbc.core.constant.AggregationType; import io.shardingjdbc.core.parsing.lexer.LexerEngine; @@ -31,12 +32,12 @@ public class SelectListClauseParser implements SQLClauseParser { private final LexerEngine lexerEngine; - private final AliasClauseParser aliasClauseParser; + private final AliasExpressionParser aliasExpressionParser; public SelectListClauseParser(final ShardingRule shardingRule, final LexerEngine lexerEngine) { this.shardingRule = shardingRule; this.lexerEngine = lexerEngine; - aliasClauseParser = AliasClauseParserFactory.createInstance(lexerEngine); + aliasExpressionParser = ExpressionParserFactory.createAliasExpressionParser(lexerEngine); } /** @@ -65,7 +66,7 @@ private SelectItem parseSelectItem(final SelectStatement selectStatement) { result = parseAggregationSelectItem(selectStatement); parseRestSelectItem(selectStatement); } else { - result = new CommonSelectItem(SQLUtil.getExactlyValue(parseCommonSelectItem(selectStatement) + parseRestSelectItem(selectStatement)), aliasClauseParser.parse()); + result = new CommonSelectItem(SQLUtil.getExactlyValue(parseCommonSelectItem(selectStatement) + parseRestSelectItem(selectStatement)), aliasExpressionParser.parse()); } return result; } @@ -88,7 +89,7 @@ private boolean isStarSelectItem() { private SelectItem parseStarSelectItem() { lexerEngine.nextToken(); - aliasClauseParser.parse(); + aliasExpressionParser.parse(); return new StarSelectItem(Optional.absent()); } @@ -99,7 +100,7 @@ private boolean isAggregationSelectItem() { private SelectItem parseAggregationSelectItem(final SelectStatement selectStatement) { AggregationType aggregationType = AggregationType.valueOf(lexerEngine.getCurrentToken().getLiterals().toUpperCase()); lexerEngine.nextToken(); - return new AggregationSelectItem(aggregationType, lexerEngine.skipParentheses(selectStatement), aliasClauseParser.parse()); + return new AggregationSelectItem(aggregationType, lexerEngine.skipParentheses(selectStatement), aliasExpressionParser.parse()); } private String parseCommonSelectItem(final SelectStatement selectStatement) { diff --git a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/clause/TableReferencesClauseParser.java b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/clause/TableReferencesClauseParser.java index fba99cd8386fc..e10382d8c6a52 100644 --- a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/clause/TableReferencesClauseParser.java +++ b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/clause/TableReferencesClauseParser.java @@ -1,7 +1,9 @@ package io.shardingjdbc.core.parsing.parser.clause; import com.google.common.base.Strings; -import io.shardingjdbc.core.parsing.parser.dialect.AliasClauseParserFactory; +import io.shardingjdbc.core.parsing.parser.clause.expression.AliasExpressionParser; +import io.shardingjdbc.core.parsing.parser.clause.expression.BasicExpressionParser; +import io.shardingjdbc.core.parsing.parser.dialect.ExpressionParserFactory; import io.shardingjdbc.core.rule.ShardingRule; import io.shardingjdbc.core.parsing.lexer.LexerEngine; import io.shardingjdbc.core.parsing.lexer.token.DefaultKeyword; @@ -30,15 +32,15 @@ public class TableReferencesClauseParser implements SQLClauseParser { @Getter private final LexerEngine lexerEngine; - private final AliasClauseParser aliasClauseParser; + private final AliasExpressionParser aliasExpressionParser; - private final ExpressionClauseParser expressionClauseParser; + private final BasicExpressionParser basicExpressionParser; public TableReferencesClauseParser(final ShardingRule shardingRule, final LexerEngine lexerEngine) { this.shardingRule = shardingRule; this.lexerEngine = lexerEngine; - aliasClauseParser = AliasClauseParserFactory.createInstance(lexerEngine); - expressionClauseParser = new ExpressionClauseParser(lexerEngine); + aliasExpressionParser = ExpressionParserFactory.createAliasExpressionParser(lexerEngine); + basicExpressionParser = ExpressionParserFactory.createBasicExpressionParser(lexerEngine); } /** @@ -68,7 +70,7 @@ protected final void parseTableFactor(final SQLStatement sqlStatement, final boo if (Strings.isNullOrEmpty(tableName)) { return; } - Optional alias = aliasClauseParser.parse(); + Optional alias = aliasExpressionParser.parse(); if (isSingleTableOnly || shardingRule.tryFindTableRule(tableName).isPresent() || shardingRule.findBindingTableRule(tableName).isPresent() || shardingRule.getDataSourceMap().containsKey(shardingRule.getDefaultDataSourceName())) { sqlStatement.getSqlTokens().add(new TableToken(beginPosition, literals)); @@ -110,9 +112,9 @@ protected Keyword[] getKeywordsForJoinType() { private void parseJoinCondition(final SQLStatement sqlStatement) { if (lexerEngine.skipIfEqual(DefaultKeyword.ON)) { do { - expressionClauseParser.parse(sqlStatement); + basicExpressionParser.parse(sqlStatement); lexerEngine.accept(Symbol.EQ); - expressionClauseParser.parse(sqlStatement); + basicExpressionParser.parse(sqlStatement); } while (lexerEngine.skipIfEqual(DefaultKeyword.AND)); } else if (lexerEngine.skipIfEqual(DefaultKeyword.USING)) { lexerEngine.skipParentheses(sqlStatement); diff --git a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/clause/UpdateSetItemsClauseParser.java b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/clause/UpdateSetItemsClauseParser.java index 948c34f820952..2d5c941e9eb2a 100644 --- a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/clause/UpdateSetItemsClauseParser.java +++ b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/clause/UpdateSetItemsClauseParser.java @@ -3,6 +3,8 @@ import io.shardingjdbc.core.parsing.lexer.LexerEngine; import io.shardingjdbc.core.parsing.lexer.token.DefaultKeyword; import io.shardingjdbc.core.parsing.lexer.token.Symbol; +import io.shardingjdbc.core.parsing.parser.clause.expression.BasicExpressionParser; +import io.shardingjdbc.core.parsing.parser.dialect.ExpressionParserFactory; import io.shardingjdbc.core.parsing.parser.sql.dml.DMLStatement; import io.shardingjdbc.core.parsing.parser.token.TableToken; import io.shardingjdbc.core.util.SQLUtil; @@ -16,11 +18,11 @@ public final class UpdateSetItemsClauseParser implements SQLClauseParser { private final LexerEngine lexerEngine; - private final ExpressionClauseParser expressionClauseParser; + private final BasicExpressionParser basicExpressionParser; public UpdateSetItemsClauseParser(final LexerEngine lexerEngine) { this.lexerEngine = lexerEngine; - expressionClauseParser = new ExpressionClauseParser(lexerEngine); + basicExpressionParser = ExpressionParserFactory.createBasicExpressionParser(lexerEngine); } /** @@ -58,6 +60,6 @@ private void parseSetColumn(final DMLStatement updateStatement) { } private void parseSetValue(final DMLStatement updateStatement) { - expressionClauseParser.parse(updateStatement); + basicExpressionParser.parse(updateStatement); } } diff --git a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/clause/WhereClauseParser.java b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/clause/WhereClauseParser.java index a4a72c45d988e..7dbcf460e15f8 100644 --- a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/clause/WhereClauseParser.java +++ b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/clause/WhereClauseParser.java @@ -1,7 +1,9 @@ package io.shardingjdbc.core.parsing.parser.clause; import io.shardingjdbc.core.constant.DatabaseType; -import io.shardingjdbc.core.parsing.parser.dialect.AliasClauseParserFactory; +import io.shardingjdbc.core.parsing.parser.clause.expression.AliasExpressionParser; +import io.shardingjdbc.core.parsing.parser.clause.expression.BasicExpressionParser; +import io.shardingjdbc.core.parsing.parser.dialect.ExpressionParserFactory; import io.shardingjdbc.core.rule.ShardingRule; import io.shardingjdbc.core.parsing.lexer.LexerEngine; import io.shardingjdbc.core.parsing.lexer.token.DefaultKeyword; @@ -42,15 +44,15 @@ public class WhereClauseParser implements SQLClauseParser { private final LexerEngine lexerEngine; - private final AliasClauseParser aliasClauseParser; + private final AliasExpressionParser aliasExpressionParser; - private final ExpressionClauseParser expressionClauseParser; + private final BasicExpressionParser basicExpressionParser; public WhereClauseParser(final DatabaseType databaseType, final LexerEngine lexerEngine) { this.databaseType = databaseType; this.lexerEngine = lexerEngine; - aliasClauseParser = AliasClauseParserFactory.createInstance(lexerEngine); - expressionClauseParser = new ExpressionClauseParser(lexerEngine); + aliasExpressionParser = ExpressionParserFactory.createAliasExpressionParser(lexerEngine); + basicExpressionParser = ExpressionParserFactory.createBasicExpressionParser(lexerEngine); } /** @@ -61,7 +63,7 @@ public WhereClauseParser(final DatabaseType databaseType, final LexerEngine lexe * @param items select items */ public void parse(final ShardingRule shardingRule, final SQLStatement sqlStatement, final List items) { - aliasClauseParser.parse(); + aliasExpressionParser.parse(); if (lexerEngine.skipIfEqual(DefaultKeyword.WHERE)) { parseConditions(shardingRule, sqlStatement, items); } @@ -76,7 +78,7 @@ private void parseConditions(final ShardingRule shardingRule, final SQLStatement private void parseComparisonCondition(final ShardingRule shardingRule, final SQLStatement sqlStatement, final List items) { lexerEngine.skipIfEqual(Symbol.LEFT_PAREN); - SQLExpression left = expressionClauseParser.parse(sqlStatement); + SQLExpression left = basicExpressionParser.parse(sqlStatement); if (lexerEngine.skipIfEqual(Symbol.EQ)) { parseEqualCondition(shardingRule, sqlStatement, left); lexerEngine.skipIfEqual(Symbol.RIGHT_PAREN); @@ -126,7 +128,7 @@ private void parseComparisonCondition(final ShardingRule shardingRule, final SQL } private void parseEqualCondition(final ShardingRule shardingRule, final SQLStatement sqlStatement, final SQLExpression left) { - SQLExpression right = expressionClauseParser.parse(sqlStatement); + SQLExpression right = basicExpressionParser.parse(sqlStatement); // TODO if have more tables, and cannot find column belong to, should not add to condition, should parse binding table rule. if ((sqlStatement.getTables().isSingleTable() || left instanceof SQLPropertyExpression) && (right instanceof SQLNumberExpression || right instanceof SQLTextExpression || right instanceof SQLPlaceholderExpression)) { @@ -142,7 +144,7 @@ private void parseInCondition(final ShardingRule shardingRule, final SQLStatemen List rights = new LinkedList<>(); do { lexerEngine.skipIfEqual(Symbol.COMMA); - rights.add(expressionClauseParser.parse(sqlStatement)); + rights.add(basicExpressionParser.parse(sqlStatement)); } while (!lexerEngine.equalAny(Symbol.RIGHT_PAREN)); Optional column = find(sqlStatement.getTables(), left); if (column.isPresent()) { @@ -153,9 +155,9 @@ private void parseInCondition(final ShardingRule shardingRule, final SQLStatemen private void parseBetweenCondition(final ShardingRule shardingRule, final SQLStatement sqlStatement, final SQLExpression left) { List rights = new LinkedList<>(); - rights.add(expressionClauseParser.parse(sqlStatement)); + rights.add(basicExpressionParser.parse(sqlStatement)); lexerEngine.accept(DefaultKeyword.AND); - rights.add(expressionClauseParser.parse(sqlStatement)); + rights.add(basicExpressionParser.parse(sqlStatement)); Optional column = find(sqlStatement.getTables(), left); if (column.isPresent()) { sqlStatement.getConditions().add(new Condition(column.get(), rights.get(0), rights.get(1)), shardingRule); @@ -177,7 +179,7 @@ protected boolean isRowNumberCondition(final List items, final Strin } private void parseRowCountCondition(final SelectStatement selectStatement, final boolean includeRowCount) { - SQLExpression sqlExpression = expressionClauseParser.parse(selectStatement); + SQLExpression sqlExpression = basicExpressionParser.parse(selectStatement); if (null == selectStatement.getLimit()) { selectStatement.setLimit(new Limit(databaseType)); } @@ -192,7 +194,7 @@ private void parseRowCountCondition(final SelectStatement selectStatement, final } private void parseOffsetCondition(final SelectStatement selectStatement, final boolean includeOffset) { - SQLExpression sqlExpression = expressionClauseParser.parse(selectStatement); + SQLExpression sqlExpression = basicExpressionParser.parse(selectStatement); if (null == selectStatement.getLimit()) { selectStatement.setLimit(new Limit(databaseType)); } @@ -211,7 +213,7 @@ protected Keyword[] getCustomizedOtherConditionOperators() { } private void parseOtherCondition(final SQLStatement sqlStatement) { - expressionClauseParser.parse(sqlStatement); + basicExpressionParser.parse(sqlStatement); } private Optional find(final Tables tables, final SQLExpression sqlExpression) { diff --git a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/clause/AliasClauseParser.java b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/clause/expression/AliasExpressionParser.java similarity index 94% rename from sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/clause/AliasClauseParser.java rename to sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/clause/expression/AliasExpressionParser.java index c0719332028cb..249fb1a117476 100644 --- a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/clause/AliasClauseParser.java +++ b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/clause/expression/AliasExpressionParser.java @@ -1,21 +1,21 @@ -package io.shardingjdbc.core.parsing.parser.clause; +package io.shardingjdbc.core.parsing.parser.clause.expression; +import com.google.common.base.Optional; +import io.shardingjdbc.core.parsing.lexer.LexerEngine; import io.shardingjdbc.core.parsing.lexer.token.DefaultKeyword; import io.shardingjdbc.core.parsing.lexer.token.Literals; import io.shardingjdbc.core.parsing.lexer.token.Symbol; -import io.shardingjdbc.core.parsing.lexer.LexerEngine; import io.shardingjdbc.core.parsing.lexer.token.TokenType; import io.shardingjdbc.core.util.SQLUtil; -import com.google.common.base.Optional; import lombok.RequiredArgsConstructor; /** - * Alias clause parser. + * Alias expression parser. * * @author zhangliang */ @RequiredArgsConstructor -public class AliasClauseParser implements SQLClauseParser { +public class AliasExpressionParser { private final LexerEngine lexerEngine; diff --git a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/clause/ExpressionClauseParser.java b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/clause/expression/BasicExpressionParser.java similarity index 96% rename from sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/clause/ExpressionClauseParser.java rename to sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/clause/expression/BasicExpressionParser.java index d34ce71e3955a..d8320c748f785 100644 --- a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/clause/ExpressionClauseParser.java +++ b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/clause/expression/BasicExpressionParser.java @@ -1,8 +1,8 @@ -package io.shardingjdbc.core.parsing.parser.clause; +package io.shardingjdbc.core.parsing.parser.clause.expression; +import io.shardingjdbc.core.parsing.lexer.LexerEngine; import io.shardingjdbc.core.parsing.lexer.token.Literals; import io.shardingjdbc.core.parsing.lexer.token.Symbol; -import io.shardingjdbc.core.parsing.lexer.LexerEngine; import io.shardingjdbc.core.parsing.parser.expression.SQLExpression; import io.shardingjdbc.core.parsing.parser.expression.SQLIdentifierExpression; import io.shardingjdbc.core.parsing.parser.expression.SQLIgnoreExpression; @@ -17,12 +17,12 @@ import lombok.RequiredArgsConstructor; /** - * Expression clause parser. + * Basic expression parser. * * @author zhangliang */ @RequiredArgsConstructor -public final class ExpressionClauseParser implements SQLClauseParser { +public final class BasicExpressionParser { private final LexerEngine lexerEngine; @@ -30,7 +30,7 @@ public final class ExpressionClauseParser implements SQLClauseParser { * Parse expression. * * @param sqlStatement SQL statement - * @return 表达式 + * @return expression */ public SQLExpression parse(final SQLStatement sqlStatement) { int beginPosition = lexerEngine.getCurrentToken().getEndPosition(); diff --git a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/AliasClauseParserFactory.java b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/AliasClauseParserFactory.java deleted file mode 100644 index 415e674809e06..0000000000000 --- a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/AliasClauseParserFactory.java +++ /dev/null @@ -1,40 +0,0 @@ -package io.shardingjdbc.core.parsing.parser.dialect; - -import io.shardingjdbc.core.parsing.lexer.LexerEngine; -import io.shardingjdbc.core.parsing.parser.clause.AliasClauseParser; -import io.shardingjdbc.core.parsing.parser.dialect.mysql.clause.MySQLAliasClauseParser; -import io.shardingjdbc.core.parsing.parser.dialect.oracle.clause.OracleAliasClauseParser; -import io.shardingjdbc.core.parsing.parser.dialect.postgresql.clause.PostgreSQLAliasClauseParser; -import io.shardingjdbc.core.parsing.parser.dialect.sqlserver.clause.SQLServerAliasClauseParser; -import lombok.AccessLevel; -import lombok.NoArgsConstructor; - -/** - * Alias clause parser factory. - * - * @author zhangliang - */ -@NoArgsConstructor(access = AccessLevel.PRIVATE) -public final class AliasClauseParserFactory { - - /** - * Create alias clause parser instance. - * - * @param lexerEngine lexical analysis engine. - * @return alias clause parser instance - */ - public static AliasClauseParser createInstance(final LexerEngine lexerEngine) { - switch (lexerEngine.getDatabaseType()) { - case MySQL: - return new MySQLAliasClauseParser(lexerEngine); - case Oracle: - return new OracleAliasClauseParser(lexerEngine); - case SQLServer: - return new SQLServerAliasClauseParser(lexerEngine); - case PostgreSQL: - return new PostgreSQLAliasClauseParser(lexerEngine); - default: - throw new UnsupportedOperationException(String.format("Cannot support database type: %s", lexerEngine.getDatabaseType())); - } - } -} diff --git a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/ExpressionParserFactory.java b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/ExpressionParserFactory.java new file mode 100644 index 0000000000000..ac0403df3c16c --- /dev/null +++ b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/ExpressionParserFactory.java @@ -0,0 +1,51 @@ +package io.shardingjdbc.core.parsing.parser.dialect; + +import io.shardingjdbc.core.parsing.lexer.LexerEngine; +import io.shardingjdbc.core.parsing.parser.clause.expression.AliasExpressionParser; +import io.shardingjdbc.core.parsing.parser.clause.expression.BasicExpressionParser; +import io.shardingjdbc.core.parsing.parser.dialect.mysql.clause.expression.MySQLAliasExpressionParser; +import io.shardingjdbc.core.parsing.parser.dialect.oracle.clause.expression.OracleAliasExpressionParser; +import io.shardingjdbc.core.parsing.parser.dialect.postgresql.clause.expression.PostgreSQLAliasExpressionParser; +import io.shardingjdbc.core.parsing.parser.dialect.sqlserver.clause.expression.SQLServerAliasExpressionParser; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; + +/** + * Expression parser factory. + * + * @author zhangliang + */ +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public final class ExpressionParserFactory { + + /** + * Create alias parser instance. + * + * @param lexerEngine lexical analysis engine. + * @return alias parser instance + */ + public static AliasExpressionParser createAliasExpressionParser(final LexerEngine lexerEngine) { + switch (lexerEngine.getDatabaseType()) { + case MySQL: + return new MySQLAliasExpressionParser(lexerEngine); + case Oracle: + return new OracleAliasExpressionParser(lexerEngine); + case SQLServer: + return new SQLServerAliasExpressionParser(lexerEngine); + case PostgreSQL: + return new PostgreSQLAliasExpressionParser(lexerEngine); + default: + throw new UnsupportedOperationException(String.format("Cannot support database type: %s", lexerEngine.getDatabaseType())); + } + } + + /** + * Create expression parser instance. + * + * @param lexerEngine lexical analysis engine. + * @return expression parser instance + */ + public static BasicExpressionParser createBasicExpressionParser(final LexerEngine lexerEngine) { + return new BasicExpressionParser(lexerEngine); + } +} diff --git a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/mysql/clause/MySQLAliasClauseParser.java b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/mysql/clause/expression/MySQLAliasExpressionParser.java similarity index 62% rename from sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/mysql/clause/MySQLAliasClauseParser.java rename to sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/mysql/clause/expression/MySQLAliasExpressionParser.java index 49f20dd433986..45ed812256e50 100644 --- a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/mysql/clause/MySQLAliasClauseParser.java +++ b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/mysql/clause/expression/MySQLAliasExpressionParser.java @@ -1,17 +1,17 @@ -package io.shardingjdbc.core.parsing.parser.dialect.mysql.clause; +package io.shardingjdbc.core.parsing.parser.dialect.mysql.clause.expression; import io.shardingjdbc.core.parsing.lexer.LexerEngine; import io.shardingjdbc.core.parsing.lexer.token.TokenType; -import io.shardingjdbc.core.parsing.parser.clause.AliasClauseParser; +import io.shardingjdbc.core.parsing.parser.clause.expression.AliasExpressionParser; /** * Alias clause parser for MySQL. * * @author zhangliang */ -public final class MySQLAliasClauseParser extends AliasClauseParser { +public final class MySQLAliasExpressionParser extends AliasExpressionParser { - public MySQLAliasClauseParser(final LexerEngine lexerEngine) { + public MySQLAliasExpressionParser(final LexerEngine lexerEngine) { super(lexerEngine); } diff --git a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/oracle/clause/OracleForClauseParser.java b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/oracle/clause/OracleForClauseParser.java index 02a0688188ae0..544ff9670b251 100644 --- a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/oracle/clause/OracleForClauseParser.java +++ b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/oracle/clause/OracleForClauseParser.java @@ -4,8 +4,9 @@ import io.shardingjdbc.core.parsing.lexer.dialect.oracle.OracleKeyword; import io.shardingjdbc.core.parsing.lexer.token.DefaultKeyword; import io.shardingjdbc.core.parsing.lexer.token.Symbol; -import io.shardingjdbc.core.parsing.parser.clause.ExpressionClauseParser; +import io.shardingjdbc.core.parsing.parser.clause.expression.BasicExpressionParser; import io.shardingjdbc.core.parsing.parser.clause.SQLClauseParser; +import io.shardingjdbc.core.parsing.parser.dialect.ExpressionParserFactory; import io.shardingjdbc.core.parsing.parser.sql.dql.select.SelectStatement; /** @@ -17,11 +18,11 @@ public final class OracleForClauseParser implements SQLClauseParser { private final LexerEngine lexerEngine; - private final ExpressionClauseParser expressionClauseParser; + private final BasicExpressionParser basicExpressionParser; public OracleForClauseParser(final LexerEngine lexerEngine) { this.lexerEngine = lexerEngine; - expressionClauseParser = new ExpressionClauseParser(lexerEngine); + basicExpressionParser = ExpressionParserFactory.createBasicExpressionParser(lexerEngine); } /** @@ -36,7 +37,7 @@ public void parse(final SelectStatement selectStatement) { lexerEngine.accept(DefaultKeyword.UPDATE); if (lexerEngine.skipIfEqual(DefaultKeyword.OF)) { do { - expressionClauseParser.parse(selectStatement); + basicExpressionParser.parse(selectStatement); } while (lexerEngine.skipIfEqual(Symbol.COMMA)); } if (lexerEngine.equalAny(OracleKeyword.NOWAIT, OracleKeyword.WAIT)) { diff --git a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/oracle/clause/OracleAliasClauseParser.java b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/oracle/clause/expression/OracleAliasExpressionParser.java similarity index 62% rename from sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/oracle/clause/OracleAliasClauseParser.java rename to sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/oracle/clause/expression/OracleAliasExpressionParser.java index 6981b046ba7d1..bbd2518849c08 100644 --- a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/oracle/clause/OracleAliasClauseParser.java +++ b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/oracle/clause/expression/OracleAliasExpressionParser.java @@ -1,17 +1,17 @@ -package io.shardingjdbc.core.parsing.parser.dialect.oracle.clause; +package io.shardingjdbc.core.parsing.parser.dialect.oracle.clause.expression; import io.shardingjdbc.core.parsing.lexer.LexerEngine; import io.shardingjdbc.core.parsing.lexer.token.TokenType; -import io.shardingjdbc.core.parsing.parser.clause.AliasClauseParser; +import io.shardingjdbc.core.parsing.parser.clause.expression.AliasExpressionParser; /** * Alias clause parser for Oracle. * * @author zhangliang */ -public final class OracleAliasClauseParser extends AliasClauseParser { +public final class OracleAliasExpressionParser extends AliasExpressionParser { - public OracleAliasClauseParser(final LexerEngine lexerEngine) { + public OracleAliasExpressionParser(final LexerEngine lexerEngine) { super(lexerEngine); } diff --git a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/postgresql/clause/PostgreSQLAliasClauseParser.java b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/postgresql/clause/expression/PostgreSQLAliasExpressionParser.java similarity index 61% rename from sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/postgresql/clause/PostgreSQLAliasClauseParser.java rename to sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/postgresql/clause/expression/PostgreSQLAliasExpressionParser.java index d7b0433bf73e0..ed2652754af9d 100644 --- a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/postgresql/clause/PostgreSQLAliasClauseParser.java +++ b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/postgresql/clause/expression/PostgreSQLAliasExpressionParser.java @@ -1,17 +1,17 @@ -package io.shardingjdbc.core.parsing.parser.dialect.postgresql.clause; +package io.shardingjdbc.core.parsing.parser.dialect.postgresql.clause.expression; import io.shardingjdbc.core.parsing.lexer.LexerEngine; import io.shardingjdbc.core.parsing.lexer.token.TokenType; -import io.shardingjdbc.core.parsing.parser.clause.AliasClauseParser; +import io.shardingjdbc.core.parsing.parser.clause.expression.AliasExpressionParser; /** * Alias clause parser for PostgreSQL. * * @author zhangliang */ -public final class PostgreSQLAliasClauseParser extends AliasClauseParser { +public final class PostgreSQLAliasExpressionParser extends AliasExpressionParser { - public PostgreSQLAliasClauseParser(final LexerEngine lexerEngine) { + public PostgreSQLAliasExpressionParser(final LexerEngine lexerEngine) { super(lexerEngine); } diff --git a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/sqlserver/clause/SQLServerSelectListClauseParser.java b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/sqlserver/clause/SQLServerSelectListClauseParser.java index 0b086f9c2cd7d..56e3ceedd292e 100644 --- a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/sqlserver/clause/SQLServerSelectListClauseParser.java +++ b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/sqlserver/clause/SQLServerSelectListClauseParser.java @@ -38,6 +38,6 @@ protected SelectItem parseRowNumberSelectItem(final SelectStatement selectStatem getLexerEngine().unsupportedIfEqual(SQLServerKeyword.PARTITION); orderByClauseParser.parse(selectStatement); getLexerEngine().accept(Symbol.RIGHT_PAREN); - return new CommonSelectItem(SQLServerKeyword.ROW_NUMBER.name(), getAliasClauseParser().parse()); + return new CommonSelectItem(SQLServerKeyword.ROW_NUMBER.name(), getAliasExpressionParser().parse()); } } diff --git a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/sqlserver/clause/SQLServerTopClauseParser.java b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/sqlserver/clause/SQLServerTopClauseParser.java index 70063014cbf08..feca351b9b98e 100644 --- a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/sqlserver/clause/SQLServerTopClauseParser.java +++ b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/sqlserver/clause/SQLServerTopClauseParser.java @@ -22,10 +22,11 @@ import io.shardingjdbc.core.parsing.lexer.dialect.sqlserver.SQLServerKeyword; import io.shardingjdbc.core.parsing.lexer.token.DefaultKeyword; import io.shardingjdbc.core.parsing.lexer.token.Symbol; -import io.shardingjdbc.core.parsing.parser.clause.ExpressionClauseParser; +import io.shardingjdbc.core.parsing.parser.clause.expression.BasicExpressionParser; import io.shardingjdbc.core.parsing.parser.clause.SQLClauseParser; import io.shardingjdbc.core.parsing.parser.context.limit.Limit; import io.shardingjdbc.core.parsing.parser.context.limit.LimitValue; +import io.shardingjdbc.core.parsing.parser.dialect.ExpressionParserFactory; import io.shardingjdbc.core.parsing.parser.exception.SQLParsingException; import io.shardingjdbc.core.parsing.parser.expression.SQLExpression; import io.shardingjdbc.core.parsing.parser.expression.SQLNumberExpression; @@ -42,11 +43,11 @@ public final class SQLServerTopClauseParser implements SQLClauseParser { private final LexerEngine lexerEngine; - private final ExpressionClauseParser expressionClauseParser; + private final BasicExpressionParser basicExpressionParser; public SQLServerTopClauseParser(final LexerEngine lexerEngine) { this.lexerEngine = lexerEngine; - expressionClauseParser = new ExpressionClauseParser(lexerEngine); + basicExpressionParser = ExpressionParserFactory.createBasicExpressionParser(lexerEngine); } /** @@ -62,7 +63,7 @@ public void parse(final SelectStatement selectStatement) { if (!lexerEngine.skipIfEqual(Symbol.LEFT_PAREN)) { beginPosition = lexerEngine.getCurrentToken().getEndPosition() - lexerEngine.getCurrentToken().getLiterals().length(); } - SQLExpression sqlExpression = expressionClauseParser.parse(selectStatement); + SQLExpression sqlExpression = basicExpressionParser.parse(selectStatement); lexerEngine.skipIfEqual(Symbol.RIGHT_PAREN); LimitValue rowCountValue; if (sqlExpression instanceof SQLNumberExpression) { diff --git a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/sqlserver/clause/SQLServerAliasClauseParser.java b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/sqlserver/clause/expression/SQLServerAliasExpressionParser.java similarity index 61% rename from sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/sqlserver/clause/SQLServerAliasClauseParser.java rename to sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/sqlserver/clause/expression/SQLServerAliasExpressionParser.java index 64f9759c8b8e4..2243d9b6efc5f 100644 --- a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/sqlserver/clause/SQLServerAliasClauseParser.java +++ b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/dialect/sqlserver/clause/expression/SQLServerAliasExpressionParser.java @@ -1,17 +1,17 @@ -package io.shardingjdbc.core.parsing.parser.dialect.sqlserver.clause; +package io.shardingjdbc.core.parsing.parser.dialect.sqlserver.clause.expression; import io.shardingjdbc.core.parsing.lexer.LexerEngine; import io.shardingjdbc.core.parsing.lexer.token.TokenType; -import io.shardingjdbc.core.parsing.parser.clause.AliasClauseParser; +import io.shardingjdbc.core.parsing.parser.clause.expression.AliasExpressionParser; /** * Alias clause parser for SQLServer. * * @author zhangliang */ -public final class SQLServerAliasClauseParser extends AliasClauseParser { +public final class SQLServerAliasExpressionParser extends AliasExpressionParser { - public SQLServerAliasClauseParser(final LexerEngine lexerEngine) { + public SQLServerAliasExpressionParser(final LexerEngine lexerEngine) { super(lexerEngine); } diff --git a/sharding-jdbc-core/src/test/java/io/shardingjdbc/core/util/AllUtilTests.java b/sharding-jdbc-core/src/test/java/io/shardingjdbc/core/util/AllUtilTests.java index c9971d492a6d7..812753af26535 100644 --- a/sharding-jdbc-core/src/test/java/io/shardingjdbc/core/util/AllUtilTests.java +++ b/sharding-jdbc-core/src/test/java/io/shardingjdbc/core/util/AllUtilTests.java @@ -24,7 +24,7 @@ @Suite.SuiteClasses({ NumberUtilTest.class, StringUtilTest.class, - InlineExpressionParserTest.class, + InlineBasicExpressionParserTest.class, SQLUtilTest.class, EventBusInstanceTest.class, DataSourceUtilTest.class diff --git a/sharding-jdbc-core/src/test/java/io/shardingjdbc/core/util/InlineExpressionParserTest.java b/sharding-jdbc-core/src/test/java/io/shardingjdbc/core/util/InlineBasicExpressionParserTest.java similarity index 96% rename from sharding-jdbc-core/src/test/java/io/shardingjdbc/core/util/InlineExpressionParserTest.java rename to sharding-jdbc-core/src/test/java/io/shardingjdbc/core/util/InlineBasicExpressionParserTest.java index a538534902a70..51f52509c09c1 100644 --- a/sharding-jdbc-core/src/test/java/io/shardingjdbc/core/util/InlineExpressionParserTest.java +++ b/sharding-jdbc-core/src/test/java/io/shardingjdbc/core/util/InlineBasicExpressionParserTest.java @@ -8,7 +8,7 @@ import static org.hamcrest.core.IsCollectionContaining.hasItems; import static org.junit.Assert.assertThat; -public final class InlineExpressionParserTest { +public final class InlineBasicExpressionParserTest { @Test public void assertEvaluateForSimpleString() { @@ -64,7 +64,7 @@ public void assertEvaluateForLong() { StringBuilder expression = new StringBuilder(); for (int i = 0; i < 1024; i++) { expression.append("ds_"); - expression.append(i/64); + expression.append(i / 64); expression.append(".t_user_"); expression.append(i); if (i != 1023) {