常量抽离

main
youHong.ai 2023-03-03 17:32:32 +08:00
parent e5f001cd9e
commit 08a396fe40
2 changed files with 6 additions and 5 deletions

View File

@ -33,4 +33,7 @@ public class CommandConsTant {
public static final String VARIABLE_PREPARED_STATEMENT = "#{"; public static final String VARIABLE_PREPARED_STATEMENT = "#{";
public static final char[] COMMAND_PRE_FIX = new char[]{'m', 'y', '-'};
} }

View File

@ -22,8 +22,6 @@ import java.util.Objects;
*/ */
public class ParseSqlUtil { public class ParseSqlUtil {
private final char[] commandPrefix = new char[]{'m', 'y', '-'};
public final static ThreadLocal<Map<String, Object>> PARSE_PARAM_LOCALE = new ThreadLocal<>(); public final static ThreadLocal<Map<String, Object>> PARSE_PARAM_LOCALE = new ThreadLocal<>();
public final static ThreadLocal<Map<String, Object>> PARSE_TEMP_PARAM_LOCALE = new ThreadLocal<>(); public final static ThreadLocal<Map<String, Object>> PARSE_TEMP_PARAM_LOCALE = new ThreadLocal<>();
@ -75,7 +73,7 @@ public class ParseSqlUtil {
String tempSql = parseStatement(sqlBuilder.toString()); String tempSql = parseStatement(sqlBuilder.toString());
sqlBuilder.delete(0, sqlBuilder.length()); sqlBuilder.delete(0, sqlBuilder.length());
sqlBuilder.append(tempSql); sqlBuilder.append(tempSql);
i += commandPrefix.length + 1; i += CommandConsTant.COMMAND_PRE_FIX.length + 1;
SqlCommandDefinition commandDefinition = parseCommand(chars, i); SqlCommandDefinition commandDefinition = parseCommand(chars, i);
sqlBuilder.append(commandDefinition.getCommandContent()); sqlBuilder.append(commandDefinition.getCommandContent());
i += commandDefinition.getCommandLength(); i += commandDefinition.getCommandLength();
@ -139,10 +137,10 @@ public class ParseSqlUtil {
} }
private boolean checkCommand(char[] chars, int index) { private boolean checkCommand(char[] chars, int index) {
if (index + commandPrefix.length + 1 >= chars.length) { if (index + CommandConsTant.COMMAND_PRE_FIX.length + 1 >= chars.length) {
return false; return false;
} }
for (char prefix : commandPrefix) { for (char prefix : CommandConsTant.COMMAND_PRE_FIX) {
if (prefix != chars[++index]) { if (prefix != chars[++index]) {
return false; return false;
} }